本文整理汇总了Java中org.apache.tools.ant.util.FileNameMapper类的典型用法代码示例。如果您正苦于以下问题:Java FileNameMapper类的具体用法?Java FileNameMapper怎么用?Java FileNameMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileNameMapper类属于org.apache.tools.ant.util包,在下文中一共展示了FileNameMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: iterator
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Fulfill the ResourceCollection interface.
* @return an Iterator of Resources.
* @since Ant 1.7
*/
@Override
public Iterator<Resource> iterator() {
if (isReference()) {
return getRef().iterator();
}
dieOnCircularReference();
Stream<Resource> result = getPropertyNames(getEffectiveProperties())
.stream().map(name -> new PropertyResource(getProject(), name));
Optional<FileNameMapper> m =
Optional.ofNullable(getMapper()).map(Mapper::getImplementation);
if (m.isPresent()) {
result = result.map(p -> new MappedResource(p, m.get()));
}
return result.iterator();
}
开发者ID:apache,项目名称:ant,代码行数:21,代码来源:PropertySet.java
示例2: selectOutOfDateResources
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
private Resource[] selectOutOfDateResources(final Resource[] initial,
final FileNameMapper mapper) {
final Resource[] rs = selectFileResources(initial);
Resource[] result =
ResourceUtils.selectOutOfDateSources(this, rs, mapper,
getZipScanner(),
ZIP_FILE_TIMESTAMP_GRANULARITY);
if (!doFilesonly) {
final Union u = new Union();
u.addAll(Arrays.asList(selectDirectoryResources(initial)));
final ResourceCollection rc =
ResourceUtils.selectSources(this, u, mapper,
getZipScanner(),
MISSING_DIR_PROVIDER);
if (!rc.isEmpty()) {
final List<Resource> newer = new ArrayList<>();
newer.addAll(Arrays.asList(((Union) rc).listResources()));
newer.addAll(Arrays.asList(result));
result = newer.toArray(result);
}
}
return result;
}
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:Zip.java
示例3: scanDir
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Scans the directory looking for class files to be compiled.
* The result is returned in the class variable compileList.
* @param baseDir the base direction
* @param files the list of files to scan
* @param mapper the mapper of files to target files
*/
protected void scanDir(File baseDir, String[] files, FileNameMapper mapper) {
String[] newFiles = files;
if (idl) {
log("will leave uptodate test to rmic implementation in idl mode.",
Project.MSG_VERBOSE);
} else if (iiop && iiopOpts != null && iiopOpts.indexOf("-always") > -1) {
log("no uptodate test as -always option has been specified",
Project.MSG_VERBOSE);
} else {
SourceFileScanner sfs = new SourceFileScanner(this);
newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper);
}
Stream.of(newFiles).map(s -> s.replace(File.separatorChar, '.'))
.map(s -> s.substring(0, s.lastIndexOf(".class")))
.forEach(compileList::add);
}
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:Rmic.java
示例4: expandStream
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* @since Ant 1.7
*/
private void expandStream(String name, InputStream stream, File dir)
throws IOException {
try (TarInputStream tis = new TarInputStream(
compression.decompress(name, new BufferedInputStream(stream)),
getEncoding())) {
log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
boolean empty = true;
FileNameMapper mapper = getMapper();
TarEntry te;
while ((te = tis.getNextEntry()) != null) {
empty = false;
extractFile(FileUtils.getFileUtils(), null, dir, tis,
te.getName(), te.getModTime(),
te.isDirectory(), mapper);
}
if (empty && getFailOnEmptyArchive()) {
throw new BuildException("archive '%s' is empty", name);
}
log("expand complete", Project.MSG_VERBOSE);
}
}
开发者ID:apache,项目名称:ant,代码行数:25,代码来源:Untar.java
示例5: getMapper
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Returns a file name mapper which maps source files to class
* files. This needs to stay in sync with Languages and file name
* extensions supported by Kawa.
*/
private FileNameMapper getMapper() {
if (language == null) {
// unspecified, use all
CompositeMapper mapper = new CompositeMapper();
mapper.add(getSchemeMapper());
mapper.add(getKrlMapper());
mapper.add(getBrlMapper());
mapper.add(getEmacsLispMapper());
mapper.add(getXQueryMapper());
mapper.add(getQ2Mapper());
mapper.add(getXsltMapper());
mapper.add(getCommonLispMapper());
return mapper;
} else if (languageMatches("scheme", ".scm", ".sc")) { // Scheme
return getSchemeMapper();
} else if (languageMatches("krl", ".krl")) {
return getKrlMapper();
} else if (languageMatches("brl", ".brl")) {
return getBrlMapper();
} else if (languageMatches("emacs", "elisp", "emacs-lisp", ".el")) {
return getEmacsLispMapper();
} else if (languageMatches("xquery", ".xquery", ".xq", ".xql")) {
return getXQueryMapper();
} else if (languageMatches("q2", ".q2")) {
return getQ2Mapper();
} else if (languageMatches("xslt", "xsl", ".xsl")) {
return getXsltMapper();
} else if (languageMatches("commonlisp", "common-lisp", "clisp",
"lisp", ".lisp", ".lsp", ".cl")) {
return getCommonLispMapper();
} else {
return null;
}
}
开发者ID:spurious,项目名称:kawa-mirror,代码行数:40,代码来源:Kawac.java
示例6: getPropertyMap
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
*
* @return Map
* @since 1.9.0
*/
private Map<String, Object> getPropertyMap() {
if (isReference()) {
return getRef().getPropertyMap();
}
dieOnCircularReference();
final Mapper myMapper = getMapper();
final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation();
final Map<String, Object> effectiveProperties = getEffectiveProperties();
final Set<String> propertyNames = getPropertyNames(effectiveProperties);
final Map<String, Object> result = new HashMap<>();
//iterate through the names, get the matching values
for (String name : propertyNames) {
Object value = effectiveProperties.get(name);
// TODO should we include null properties?
// TODO should we query the PropertyHelper for property value to grab potentially shadowed values?
if (value != null) {
// may be null if a system property has been added
// after the project instance has been initialized
if (m != null) {
//map the names
String[] newname = m.mapFileName(name);
if (newname != null) {
name = newname[0];
}
}
result.put(name, value);
}
}
return result;
}
开发者ID:apache,项目名称:ant,代码行数:39,代码来源:PropertySet.java
示例7: getCollection
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
private Collection<Resource> getCollection() {
FileNameMapper m =
mapper == null ? new IdentityMapper() : mapper.getImplementation();
Stream<MappedResource> stream;
if (enableMultipleMappings) {
stream = nested.stream()
.flatMap(r -> Stream.of(m.mapFileName(r.getName()))
.map(MergingMapper::new)
.map(mm -> new MappedResource(r, mm)));
} else {
stream = nested.stream().map(r -> new MappedResource(r, m));
}
return stream.collect(Collectors.toList());
}
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:MappedResourceCollection.java
示例8: addConfigured
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Add a configured FileNameMapper instance.
* @param fileNameMapper the FileNameMapper to add
* @throws BuildException if more than one mapper defined
* @since Ant 1.8.0
*/
public void addConfigured(final FileNameMapper fileNameMapper) {
if (map != null || mapperElement != null) {
throw new BuildException("Cannot define more than one mapper");
}
this.map = fileNameMapper;
}
开发者ID:apache,项目名称:ant,代码行数:13,代码来源:PresentSelector.java
示例9: addConfigured
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Add a configured FileNameMapper instance.
* @param fileNameMapper the FileNameMapper to add
* @throws BuildException if more than one mapper defined
* @since Ant 1.8.0
*/
public void addConfigured(FileNameMapper fileNameMapper) {
if (map != null || mapperElement != null) {
throw new BuildException("Cannot define more than one mapper");
}
this.map = fileNameMapper;
}
开发者ID:apache,项目名称:ant,代码行数:13,代码来源:MappingSelector.java
示例10: getImplementationClass
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Gets the Class object associated with the mapper implementation.
* @return <code>Class</code>.
* @throws ClassNotFoundException if the class cannot be found
*/
protected Class<? extends FileNameMapper> getImplementationClass() throws ClassNotFoundException {
String cName = this.classname;
if (type != null) {
cName = type.getImplementation();
}
ClassLoader loader = (classpath == null)
? getClass().getClassLoader()
// Memory leak in line below
: getProject().createClassLoader(classpath);
return Class.forName(cName, true, loader).asSubclass(FileNameMapper.class);
}
开发者ID:apache,项目名称:ant,代码行数:20,代码来源:Mapper.java
示例11: scanDir
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Scan a directory for files to check for "up to date"ness
* @param srcDir the directory
* @param files the files to scan for
* @return true if the files are up to date
*/
protected boolean scanDir(File srcDir, String[] files) {
SourceFileScanner sfs = new SourceFileScanner(this);
FileNameMapper mapper = getMapper();
File dir = srcDir;
if (mapperElement == null) {
dir = null;
}
return sfs.restrict(files, srcDir, dir, mapper).length == 0;
}
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:UpToDate.java
示例12: getMapper
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
private FileNameMapper getMapper() {
if (mapperElement == null) {
MergingMapper mm = new MergingMapper();
mm.setTo(targetFile.getAbsolutePath());
return mm;
}
return mapperElement.getImplementation();
}
开发者ID:apache,项目名称:ant,代码行数:9,代码来源:UpToDate.java
示例13: execute
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Executes the Task.
* @throws BuildException on error.
*/
@Override
public void execute() throws BuildException {
validateAttributes();
try {
File dest = (destDir != null) ? destDir : srcDir;
int writeCount = 0;
// build mapper
final FileNameMapper mapper = mapperElement == null
? new IdentityMapper() : mapperElement.getImplementation();
// deal with specified srcDir
if (srcDir != null) {
writeCount += processDir(srcDir,
super.getDirectoryScanner(srcDir).getIncludedFiles(), dest,
mapper);
}
// deal with the filesets
for (FileSet fs : filesets) {
writeCount += processDir(fs.getDir(getProject()),
fs.getDirectoryScanner(getProject()).getIncludedFiles(),
dest, mapper);
}
if (writeCount > 0) {
log("Processed " + writeCount + (writeCount == 1 ? " image." : " images."));
}
} catch (Exception err) {
log(StringUtils.getStackTrace(err), Project.MSG_ERR);
throw new BuildException(err.getMessage());
}
}
开发者ID:apache,项目名称:ant,代码行数:41,代码来源:Image.java
示例14: scan
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Compares source files to destination files to see if they should be
* copied.
*
* @param fromDir The source directory.
* @param toDir The destination directory.
* @param files A list of files to copy.
* @param dirs A list of directories to copy.
*/
protected void scan(final File fromDir, final File toDir, final String[] files,
final String[] dirs) {
final FileNameMapper mapper = getMapper();
buildMap(fromDir, toDir, files, mapper, fileCopyMap);
if (includeEmpty) {
buildMap(fromDir, toDir, dirs, mapper, dirCopyMap);
}
}
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:Copy.java
示例15: buildMap
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Add to a map of files/directories to copy.
*
* @param fromDir the source directory.
* @param toDir the destination directory.
* @param names a list of filenames.
* @param mapper a <code>FileNameMapper</code> value.
* @param map a map of source file to array of destination files.
*/
protected void buildMap(final File fromDir, final File toDir, final String[] names,
final FileNameMapper mapper, final Hashtable<String, String[]> map) {
String[] toCopy = null;
if (forceOverwrite) {
final Vector<String> v = new Vector<String>();
for (int i = 0; i < names.length; i++) {
if (mapper.mapFileName(names[i]) != null) {
v.addElement(names[i]);
}
}
toCopy = new String[v.size()];
v.copyInto(toCopy);
} else {
final SourceFileScanner ds = new SourceFileScanner(this);
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity);
}
for (int i = 0; i < toCopy.length; i++) {
final File src = new File(fromDir, toCopy[i]);
final String[] mappedFiles = mapper.mapFileName(toCopy[i]);
if (!enableMultipleMappings) {
map.put(src.getAbsolutePath(),
new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()});
} else {
// reuse the array created by the mapper
for (int k = 0; k < mappedFiles.length; k++) {
mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath();
}
map.put(src.getAbsolutePath(), mappedFiles);
}
}
}
开发者ID:apache,项目名称:ant,代码行数:42,代码来源:Copy.java
示例16: getMapper
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* returns the mapper to use based on nested elements or the
* flatten attribute.
*/
private FileNameMapper getMapper() {
FileNameMapper mapper = null;
if (mapperElement != null) {
mapper = mapperElement.getImplementation();
} else if (flatten) {
mapper = new FlatFileNameMapper();
} else {
mapper = new IdentityMapper();
}
return mapper;
}
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:Copy.java
示例17: add
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* Add a <code>FileNameMapper</code>.
* @param fileNameMapper the <code>FileNameMapper</code> to add.
* @since Ant 1.6.3
* @throws BuildException if multiple mappers are added.
*/
public void add(FileNameMapper fileNameMapper) throws BuildException {
if (this.fileNameMapper != null) {
throw new BuildException(
"Only one mapper may be added to the %s task.", getTaskName());
}
this.fileNameMapper = fileNameMapper;
}
开发者ID:apache,项目名称:ant,代码行数:14,代码来源:Touch.java
示例18: expandFile
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* This method is to be overridden by extending unarchival tasks.
*
* @param fileUtils the fileUtils
* @param srcF the source file
* @param dir the destination directory
*/
protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
FileNameMapper mapper = getMapper();
if (!srcF.exists()) {
throw new BuildException("Unable to expand "
+ srcF
+ " as the file does not exist",
getLocation());
}
try (
ZipFile
zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)){
boolean empty = true;
Enumeration<ZipEntry> e = zf.getEntries();
while (e.hasMoreElements()) {
empty = false;
ZipEntry ze = e.nextElement();
InputStream is = null;
log("extracting " + ze.getName(), Project.MSG_DEBUG);
try {
extractFile(fileUtils, srcF, dir,
is = zf.getInputStream(ze), //NOSONAR
ze.getName(), new Date(ze.getTime()),
ze.isDirectory(), mapper);
} finally {
FileUtils.close(is);
}
}
if (empty && getFailOnEmptyArchive()) {
throw new BuildException("archive '%s' is empty", srcF);
}
log("expand complete", Project.MSG_VERBOSE);
} catch (IOException ioe) {
throw new BuildException(
"Error while expanding " + srcF.getPath()
+ "\n" + ioe.toString(),
ioe);
}
}
开发者ID:apache,项目名称:ant,代码行数:47,代码来源:Expand.java
示例19: getMapper
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* get a mapper for a file
* @return a filenamemapper for a file
*/
protected FileNameMapper getMapper() {
if (mapperElement != null) {
return mapperElement.getImplementation();
}
return new IdentityMapper();
}
开发者ID:apache,项目名称:ant,代码行数:11,代码来源:Expand.java
示例20: add
import org.apache.tools.ant.util.FileNameMapper; //导入依赖的package包/类
/**
* add a mapper
*
* @param newmapper the mapper to add.
*/
public void add(FileNameMapper newmapper) {
if (mapper != null) {
throw new BuildException("Only one mapper allowed");
}
mapper = newmapper;
}
开发者ID:apache,项目名称:ant,代码行数:12,代码来源:CopyPath.java
注:本文中的org.apache.tools.ant.util.FileNameMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论