本文整理汇总了Java中org.apache.tools.ant.ProjectHelper.genComponentName方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectHelper.genComponentName方法的具体用法?Java ProjectHelper.genComponentName怎么用?Java ProjectHelper.genComponentName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.ProjectHelper
的用法示例。
在下文中一共展示了ProjectHelper.genComponentName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
* Create a new ant type based on the embedded tasks and types.
*/
@Override
public void execute() {
if (nestedSequential == null) {
throw new BuildException("Missing sequential element");
}
if (name == null) {
throw new BuildException("Name not specified");
}
name = ProjectHelper.genComponentName(getURI(), name);
MyAntTypeDefinition def = new MyAntTypeDefinition(this);
def.setName(name);
def.setClass(MacroInstance.class);
ComponentHelper helper = ComponentHelper.getComponentHelper(
getProject());
helper.addDataTypeDefinition(def);
log("creating macro " + name, Project.MSG_VERBOSE);
}
示例2: doesTypeExist
import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
* test for a task or other ant type existing in the current project
* @param typename the name of the type
* @return true if the typename exists
*/
protected boolean doesTypeExist(String typename) {
ComponentHelper helper =
ComponentHelper.getComponentHelper(getProject());
String componentName = ProjectHelper.genComponentName(uri, typename);
AntTypeDefinition def = helper.getDefinition(componentName);
if (def == null) {
return false;
}
//now verify that the class has an implementation
boolean found = def.getExposedClass(getProject()) != null;
if (!found) {
String text = helper.diagnoseCreationFailure(componentName, "type");
log(text, Project.MSG_VERBOSE);
}
return found;
}
示例3: execute
import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
* Make a new definition.
*/
@Override
public void execute() {
if (nestedTask == null) {
throw new BuildException("Missing nested element");
}
if (name == null) {
throw new BuildException("Name not specified");
}
name = ProjectHelper.genComponentName(getURI(), name);
ComponentHelper helper = ComponentHelper.getComponentHelper(
getProject());
String componentName = ProjectHelper.genComponentName(
nestedTask.getNamespace(), nestedTask.getTag());
AntTypeDefinition def = helper.getDefinition(componentName);
if (def == null) {
throw new BuildException(
"Unable to find typedef %s", componentName);
}
PreSetDefinition newDef = new PreSetDefinition(def, nestedTask);
newDef.setName(name);
helper.addDataTypeDefinition(newDef);
log("defining preset " + name, Project.MSG_VERBOSE);
}
示例4: execute
import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
* Defines the script.
*/
@Override
public void execute() {
if (name == null) {
throw new BuildException(
"scriptdef requires a name attribute to name the script");
}
if (helper.getLanguage() == null) {
throw new BuildException(
"scriptdef requires a language attribute to specify the script language");
}
if (helper.getSrc() == null && helper.getEncoding() != null) {
throw new BuildException(
"scriptdef requires a src attribute if the encoding is set");
}
// Check if need to set the loader
if (getAntlibClassLoader() != null || hasCpDelegate()) {
helper.setClassLoader(createLoader());
}
attributeSet = new HashSet<>();
for (Attribute attribute : attributes) {
if (attribute.name == null) {
throw new BuildException(
"scriptdef <attribute> elements must specify an attribute name");
}
if (attributeSet.contains(attribute.name)) {
throw new BuildException(
"scriptdef <%s> declares the %s attribute more than once",
name, attribute.name);
}
attributeSet.add(attribute.name);
}
nestedElementMap = new HashMap<>();
for (NestedElement nestedElement : nestedElements) {
if (nestedElement.name == null) {
throw new BuildException(
"scriptdef <element> elements must specify an element name");
}
if (nestedElementMap.containsKey(nestedElement.name)) {
throw new BuildException(
"scriptdef <%s> declares the %s nested element more than once",
name, nestedElement.name);
}
if (nestedElement.className == null
&& nestedElement.type == null) {
throw new BuildException(
"scriptdef <element> elements must specify either a classname or type attribute");
}
if (nestedElement.className != null
&& nestedElement.type != null) {
throw new BuildException(
"scriptdef <element> elements must specify only one of the classname and type attributes");
}
nestedElementMap.put(nestedElement.name, nestedElement);
}
// find the script repository - it is stored in the project
Map<String, ScriptDef> scriptRepository = lookupScriptRepository();
name = ProjectHelper.genComponentName(getURI(), name);
scriptRepository.put(name, this);
AntTypeDefinition def = new AntTypeDefinition();
def.setName(name);
def.setClass(ScriptDefBase.class);
ComponentHelper.getComponentHelper(
getProject()).addDataTypeDefinition(def);
}
示例5: addDefinition
import org.apache.tools.ant.ProjectHelper; //导入方法依赖的package包/类
/**
* Add a definition using the attributes of Definer
*
* @param al the ClassLoader to use
* @param name the name of the definition
* @param classname the classname of the definition
* @exception BuildException if an error occurs
*/
protected void addDefinition(ClassLoader al, String name, String classname)
throws BuildException {
Class<?> cl = null;
try {
try {
name = ProjectHelper.genComponentName(getURI(), name);
if (onError != OnError.IGNORE) {
cl = Class.forName(classname, true, al);
}
if (adapter != null) {
adapterClass = Class.forName(adapter, true, al);
}
if (adaptTo != null) {
adaptToClass = Class.forName(adaptTo, true, al);
}
AntTypeDefinition def = new AntTypeDefinition();
def.setName(name);
def.setClassName(classname);
def.setClass(cl);
def.setAdapterClass(adapterClass);
def.setAdaptToClass(adaptToClass);
def.setRestrict(restrict);
def.setClassLoader(al);
if (cl != null) {
def.checkClass(getProject());
}
ComponentHelper.getComponentHelper(getProject())
.addDataTypeDefinition(def);
} catch (ClassNotFoundException cnfe) {
throw new BuildException(
getTaskName() + " class " + classname
+ " cannot be found\n using the classloader " + al,
cnfe, getLocation());
} catch (NoClassDefFoundError ncdfe) {
throw new BuildException(
getTaskName() + " A class needed by class " + classname
+ " cannot be found: " + ncdfe.getMessage()
+ "\n using the classloader " + al,
ncdfe, getLocation());
}
} catch (BuildException ex) {
switch (onError) {
case OnError.FAIL_ALL:
case OnError.FAIL:
throw ex;
case OnError.REPORT:
log(ex.getLocation() + "Warning: " + ex.getMessage(),
Project.MSG_WARN);
break;
default:
log(ex.getLocation() + ex.getMessage(),
Project.MSG_DEBUG);
}
}
}