package org.apache.tools.ant;
public final class DefaultDefinitions {
private static final String IF_NAMESPACE = "ant:if";
private static final String UNLESS_NAMESPACE = "ant:unless";
private static final String OATA = "org.apache.tools.ant.";
private final ComponentHelper componentHelper;
public DefaultDefinitions(ComponentHelper componentHelper) {
this.componentHelper = componentHelper;
}
public void execute() {
attributeNamespaceDef(IF_NAMESPACE);
attributeNamespaceDef(UNLESS_NAMESPACE);
ifUnlessDef("true", "IfTrueAttribute");
ifUnlessDef("set", "IfSetAttribute");
ifUnlessDef("blank", "IfBlankAttribute");
}
private void attributeNamespaceDef(String ns) {
AntTypeDefinition def = new AntTypeDefinition();
def.setName(ProjectHelper.nsToComponentName(ns));
def.setClassName(OATA + "attribute.AttributeNamespace");
def.setClassLoader(getClass().getClassLoader());
def.setRestrict(true);
componentHelper.addDataTypeDefinition(def);
}
private void ifUnlessDef(String name, String base) {
String classname = OATA + "attribute." + base;
componentDef(IF_NAMESPACE, name, classname);
componentDef(UNLESS_NAMESPACE, name, classname + "$Unless");
}
private void componentDef(String ns, String name, String classname) {
AntTypeDefinition def = new AntTypeDefinition();
def.setName(ProjectHelper.genComponentName(ns, name));
def.setClassName(classname);
def.setClassLoader(getClass().getClassLoader());
def.setRestrict(true);
componentHelper.addDataTypeDefinition(def);
}
}