当前位置: 首页>>代码示例>>Java>>正文


Java CreoleResource类代码示例

本文整理汇总了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);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:32,代码来源:CreoleAnnotationHandler.java

示例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);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:40,代码来源:CreoleAnnotationHandler.java


注:本文中的gate.creole.metadata.CreoleResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。