org.apache.tools.ant.types.Mapper Java Examples

The following examples show how to use org.apache.tools.ant.types.Mapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckLinks.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String normalize(String path, List<Mapper> mappers) throws IOException {
    try {
        for (Mapper m : mappers) {
            String[] nue = m.getImplementation().mapFileName(path);
            if (nue != null) {
                for (int i = 0; i < nue.length; i++) {
                    File f = new File(nue[i]);
                    if (f.isFile()) {
                        return new File(f.toURI().normalize()).getAbsolutePath();
                    }
                }
            }
        }
        return path;
    } catch (BuildException e) {
        throw new IOException(e.toString());
    }
}
 
Example #2
Source File: LicenseCheckTask.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a license mapper.
 */
public void addConfiguredLicenseMapper(Mapper mapper) {
  if (licenseMapper != null) {
    throw new BuildException("Only one license mapper is allowed.");
  }
  this.licenseMapper = mapper.getImplementation();
}
 
Example #3
Source File: IvyRetrieve.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Add a mapper to convert the file names.
 *
 * @param mapper
 *            a Mapper value.
 */
public void addMapper(Mapper mapper) {
    if (this.mapper != null) {
        throw new IllegalArgumentException("Cannot define more than one mapper");
    }
    this.mapper = mapper;
}
 
Example #4
Source File: YGuardBaseTask.java    From yGuard with MIT License 4 votes vote down vote up
public void add(Mapper mapper){
  this.mapper = mapper;
}
 
Example #5
Source File: ResolveList.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Mapper to be applied to each property in the list before its
 * value is taken
 */
public void addMapper(Mapper m) {
    this.mapper = m;
}
 
Example #6
Source File: CheckHelpSets.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void checkHelpSet(File hsfile) throws Exception {
    log("Checking helpset: " + hsfile);
    HelpSet hs = new HelpSet(null, hsfile.toURI().toURL());
    javax.help.Map map = hs.getCombinedMap();
    log("Parsed helpset, checking map IDs in TOC/Index navigators...");
    NavigatorView[] navs = hs.getNavigatorViews();
    for (int i = 0; i < navs.length; i++) {
        String name = navs[i].getName();
        File navfile = new File(hsfile.getParentFile(), (String)navs[i].getParameters().get("data"));
        if (! navfile.exists()) throw new BuildException("Navigator " + name + " not found", new Location(navfile.getAbsolutePath()));
        if (navs[i] instanceof IndexView) {
            log("Checking index navigator " + name, Project.MSG_VERBOSE);
            IndexView.parse(navfile.toURI().toURL(), hs, Locale.getDefault(), new VerifyTIFactory(hs, map, navfile, false));
        } else if (navs[i] instanceof TOCView) {
            log("Checking TOC navigator " + name, Project.MSG_VERBOSE);
            TOCView.parse(navfile.toURI().toURL(), hs, Locale.getDefault(), new VerifyTIFactory(hs, map, navfile, true));
        } else {
            log("Skipping non-TOC/Index view: " + name, Project.MSG_VERBOSE);
        }
    }
    log("Checking for duplicate map IDs...");
    HelpSet.parse(hsfile.toURI().toURL(), null, new VerifyHSFactory());
    log("Checking links from help map and between HTML files...");
    @SuppressWarnings("unchecked")
    Enumeration<javax.help.Map.ID> e = map.getAllIDs();
    Set<URI> okurls = new HashSet<>(1000);
    Set<URI> badurls = new HashSet<>(1000);
    Set<URI> cleanurls = new HashSet<>(1000);
    while (e.hasMoreElements()) {
        javax.help.Map.ID id = e.nextElement();
        URL u = map.getURLFromID(id);
        if (u == null) {
            throw new BuildException("Bogus map ID: " + id.id, new Location(hsfile.getAbsolutePath()));
        }
        log("Checking ID " + id.id, Project.MSG_VERBOSE);
        List<String> errors = new ArrayList<>();
        CheckLinks.scan(this, null, null, id.id, "", 
        u.toURI(), okurls, badurls, cleanurls, false, false, false, 2, 
        Collections.<Mapper>emptyList(), errors);
        for (String error : errors) {
            log(error, Project.MSG_WARN);
        }
    }
}
 
Example #7
Source File: CheckLinks.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Add a mapper to translate file names to the "originals".
 */
public Mapper createMapper() {
    Mapper m = new Mapper(getProject());
    mappers.add(m);
    return m;
}
 
Example #8
Source File: MapperAdapter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
MapperAdapter(Mapper mapper) {
    this.mapper = mapper;
}
 
Example #9
Source File: CheckLinks.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Scan for broken links.
 * @param task an Ant task to associate with this
 * @param referrer the referrer file path (or full URL if not file:)
 * @param referrerLocation the location in the referrer, e.g. ":38:12", or "" if unavailable
 * @param u the URI to check
 * @param okurls a set of URIs known to be fully checked (including all anchored variants etc.)
 * @param badurls a set of URIs known to be bogus
 * @param cleanurls a set of (base) URIs known to have had their contents checked
 * @param checkexternal if true, check external links (all protocols besides file:)
 * @param recurse one of:
 *                0 - just check that it can be opened;
 *                1 - check also that any links from it can be opened;
 *                2 - recurse
 * @param mappers a list of Mappers to apply to get source files from HTML files
 */
public static void scan
(Task task, ClassLoader globalClassLoader, java.util.Map<String,URLClassLoader> classLoaderMap,
 String referrer, String referrerLocation, 
 URI u, Set<URI> okurls, Set<URI> badurls, Set<URI> cleanurls, 
 boolean checkexternal, boolean checkspaces, boolean checkforbidden, int recurse, 
 List<Mapper> mappers, List<String> errors) throws IOException {
    scan (task, globalClassLoader, classLoaderMap,
    referrer, referrerLocation, u, okurls, badurls, cleanurls, checkexternal, checkspaces, checkforbidden, recurse, mappers, Collections.<Filter>emptyList(), errors);
}
 
Example #10
Source File: IvyRetrieve.java    From ant-ivy with Apache License 2.0 2 votes vote down vote up
/**
 * Add a nested filenamemapper.
 *
 * @param fileNameMapper
 *            the mapper to add.
 */
public void add(FileNameMapper fileNameMapper) {
    Mapper m = new Mapper(getProject());
    m.add(fileNameMapper);
    addMapper(m);
}