本文整理汇总了Java中org.apache.tools.ant.util.FileNameMapper.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java FileNameMapper.setTo方法的具体用法?Java FileNameMapper.setTo怎么用?Java FileNameMapper.setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.util.FileNameMapper
的用法示例。
在下文中一共展示了FileNameMapper.setTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNested
import org.apache.tools.ant.util.FileNameMapper; //导入方法依赖的package包/类
@Test
public void testNested() {
Mapper mapper1 = new Mapper(project);
Mapper.MapperType mt = new Mapper.MapperType();
mt.setValue("glob");
mapper1.setType(mt);
mapper1.setFrom("from*");
mapper1.setTo("to*");
//mix element types
FileNameMapper mapper2 = new FlatFileNameMapper();
FileNameMapper mapper3 = new MergingMapper();
mapper3.setTo("mergefile");
Mapper container = new Mapper(project);
container.addConfiguredMapper(mapper1);
container.add(mapper2);
container.add(mapper3);
FileNameMapper fileNameMapper = container.getImplementation();
String[] targets = fileNameMapper.mapFileName("fromfilename");
assertNotNull("no filenames mapped", targets);
assertEquals("wrong number of filenames mapped", 3, targets.length);
List list = Arrays.asList(targets);
assertTrue("cannot find expected target \"tofilename\"",
list.contains("tofilename"));
assertTrue("cannot find expected target \"fromfilename\"",
list.contains("fromfilename"));
assertTrue("cannot find expected target \"mergefile\"",
list.contains("mergefile"));
}
示例2: getImplementation
import org.apache.tools.ant.util.FileNameMapper; //导入方法依赖的package包/类
/**
* Returns a fully configured FileNameMapper implementation.
* @return a FileNameMapper object to be configured
* @throws BuildException on error
*/
public FileNameMapper getImplementation() throws BuildException {
if (isReference()) {
dieOnCircularReference();
Reference r = getRefid();
Object o = r.getReferencedObject(getProject());
if (o instanceof FileNameMapper) {
return (FileNameMapper) o;
}
if (o instanceof Mapper) {
return ((Mapper) o).getImplementation();
}
String od = o == null ? "null" : o.getClass().getName();
throw new BuildException(od + " at reference '"
+ r.getRefId() + "' is not a valid mapper reference.");
}
if (type == null && classname == null && container == null) {
throw new BuildException(
"nested mapper or "
+ "one of the attributes type or classname is required");
}
if (container != null) {
return container;
}
if (type != null && classname != null) {
throw new BuildException(
"must not specify both type and classname attribute");
}
try {
FileNameMapper m = getImplementationClass().newInstance();
final Project p = getProject();
if (p != null) {
p.setProjectReference(m);
}
m.setFrom(from);
m.setTo(to);
return m;
} catch (BuildException be) {
throw be;
} catch (Throwable t) {
throw new BuildException(t);
}
}
示例3: testChained
import org.apache.tools.ant.util.FileNameMapper; //导入方法依赖的package包/类
@Test
public void testChained() {
// a --> b --> c --- def
// \-- ghi
FileNameMapper mapperAB = new GlobPatternMapper();
mapperAB.setFrom("a");
mapperAB.setTo("b");
FileNameMapper mapperBC = new GlobPatternMapper();
mapperBC.setFrom("b");
mapperBC.setTo("c");
//implicit composite
Mapper mapperCX = new Mapper(project);
FileNameMapper mapperDEF = new GlobPatternMapper();
mapperDEF.setFrom("c");
mapperDEF.setTo("def");
FileNameMapper mapperGHI = new GlobPatternMapper();
mapperGHI.setFrom("c");
mapperGHI.setTo("ghi");
mapperCX.add(mapperDEF);
mapperCX.add(mapperGHI);
Mapper chained = new Mapper(project);
chained.setClassname(ChainedMapper.class.getName());
chained.add(mapperAB);
chained.add(mapperBC);
chained.addConfiguredMapper(mapperCX);
FileNameMapper fileNameMapper = chained.getImplementation();
String[] targets = fileNameMapper.mapFileName("a");
assertNotNull("no filenames mapped", targets);
assertEquals("wrong number of filenames mapped", 2, targets.length);
List list = Arrays.asList(targets);
assertTrue("cannot find expected target \"def\"", list.contains("def"));
assertTrue("cannot find expected target \"ghi\"", list.contains("ghi"));
}