本文整理汇总了Java中gate.creole.metadata.CreoleResource类的典型用法代码示例。如果您正苦于以下问题:Java CreoleResource类的具体用法?Java CreoleResource怎么用?Java CreoleResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreoleResource类属于gate.creole.metadata包,在下文中一共展示了CreoleResource类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processResourceData
import gate.creole.metadata.CreoleResource; //导入依赖的package包/类
/**
* Process the {@link CreoleResource} data for this class. This method first
* extracts the non-inheritable data (PRIVATE, MAIN_VIEWER, NAME and TOOL),
* then calls {@link #processInheritableResourceData} to process the
* inheritable data, then deals with any specified {@link AutoInstance}s.
*
* @param resourceClass
* the resource class to process, which must be annotated with
* {@link CreoleResource}.
* @param element
* the RESOURCE element to which data should be added.
*/
private void processResourceData(Class<?> resourceClass, Element element) {
CreoleResource cr = resourceClass.getAnnotation(CreoleResource.class);
if(cr.isPrivate() && element.getChild("PRIVATE") == null) {
element.addContent(new Element("PRIVATE"));
}
if(cr.mainViewer() && element.getChild("MAIN_VIEWER") == null) {
element.addContent(new Element("MAIN_VIEWER"));
}
if(cr.tool() && element.getChild("TOOL") == null) {
element.addContent(new Element("TOOL"));
}
// NAME is the name given in the annotation, or the simple name of
// the class if omitted
addElement(element, ("".equals(cr.name()))
? resourceClass.getSimpleName()
: cr.name(), "NAME");
processInheritableResourceData(resourceClass, element);
processAutoInstances(cr, element);
}
示例2: processInheritableResourceData
import gate.creole.metadata.CreoleResource; //导入依赖的package包/类
/**
* Recursive method to process the {@link CreoleResource} elements that can be
* inherited from superclasses and interfaces (everything except the PRIVATE
* and MAIN_VIEWER flags, the NAME and the AUTOINSTANCEs). Once data has been
* extracted from the current class the method calls itself recursively for
* the superclass and any implemented interfaces. For any given attribute, the
* first value specified wins (i.e. the one on the most specific class).
*
* @param clazz
* the class to process
* @param element
* the RESOURCE element to which data should be added.
*/
private void processInheritableResourceData(Class<?> clazz, Element element) {
CreoleResource cr = clazz.getAnnotation(CreoleResource.class);
if(cr != null) {
addElement(element, cr.comment(), "COMMENT");
addElement(element, cr.helpURL(), "HELPURL");
addElement(element, cr.interfaceName(), "INTERFACE");
addElement(element, cr.icon(), "ICON");
if(cr.guiType() != GuiType.NONE && element.getChild("GUI") == null) {
Element guiElement =
new Element("GUI").setAttribute("TYPE", cr.guiType().toString());
element.addContent(guiElement);
addElement(guiElement, cr.resourceDisplayed(), "RESOURCE_DISPLAYED");
}
addElement(element, cr.annotationTypeDisplayed(),
"ANNOTATION_TYPE_DISPLAYED");
}
Class<?> superclass = clazz.getSuperclass();
if(superclass != null) {
processInheritableResourceData(superclass, element);
}
for(Class<?> intf : clazz.getInterfaces()) {
processInheritableResourceData(intf, element);
}
}