Examples of FeatureDescription


Examples of org.apache.uima.resource.metadata.FeatureDescription

  // cases: removing a feature which is merged with an identical named imported feature
  // same - for built-in <could be created outside of the CDE>
  private void handleRemoveFeature(TableTreeItem item) {
    TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
    FeatureDescription fd = getFeatureDescriptionFromTableTreeItem(item);

    String featureName = fd.getName();

    boolean bFeatureInUseElsewhere = isFeatureInUseElsewhere(td, featureName);
    if (bFeatureInUseElsewhere) {
      String sCascadeDeleteTitle = CASCADE_DELETE_WARNING;
      String sCascadeDeleteMessage = CASCADE_MESSAGE;
      boolean bContinue = MessageDialog.openConfirm(getSection().getShell(), sCascadeDeleteTitle,
              sCascadeDeleteMessage);
      if (!bContinue)
        return;
    }
    TypeDescription localTd = getLocalTypeDefinition(td);
    FeatureDescription localFd = getLocalFeatureDefinition(td, fd);

    removeFeature(localTd, localFd);
    if (isImportedFeature(featureName, td))
      refresh(); // don't remove from merged set
    else {
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

        } else {
          td.setSupertypeName(newTypeName);
          updateGuiType(tt.getItems()[i], td);
        }
      }
      FeatureDescription fds[] = td.getFeatures();
      FeatureDescription localFds[] = (null == localTd) ? null : localTd.getFeatures();
      if (null != fds) {
        for (int j = 0; j < fds.length; j++) {
          FeatureDescription fd = fds[j];
          if (oldTypeName.equals(fd.getRangeTypeName())) {
            if (warnAndSkipIfImported(typeName))
              continue; // skipped if feature not present in local td, or no local td.

            setNamedFeatureDescriptionRange(localFds, fd.getName(), newTypeName);
            if (isImportedType(typeName)) {
              remergeNeeded = true;
              refreshNeeded = true;
            } else {
              fd.setRangeTypeName(newTypeName);
              updateGuiFeature(tt.getItems()[i].getItems()[j], fd, td);
            }
          }
        }
      }
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

  // this function to set the corresponding feature in the "local" type's fd array
  private void setNamedFeatureDescriptionRange(FeatureDescription[] localFds, String featureName,
          final String rangeName) {
    if (null != localFds) {
      for (int i = 0; i < localFds.length; i++) {
        FeatureDescription fd = localFds[i];
        if (fd.getName().equals(featureName)) {
          fd.setRangeTypeName(rangeName);
          return;
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

      desc.setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");

      TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
      TypeDescription type1 = typeSystem.addType("Type1", "Test Type One",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat1 = new FeatureDescription_impl();
      feat1.setName("Feature1");
      feat1.setRangeTypeName(CAS.TYPE_NAME_INTEGER);
      type1.setFeatures(new FeatureDescription[] { feat1 });
      TypeDescription type2 = typeSystem.addType("Type2", "Test Type Two",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat2 = new FeatureDescription_impl();
      feat2.setName("Feature2");
      feat2.setRangeTypeName("EnumType");
      type2.setFeatures(new FeatureDescription[] { feat2 });
      TypeDescription enumType = typeSystem.addType("EnumType", "Test Enumerated Type",
              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

      String rangeTypeName = aFeatures[i].getRangeTypeName();
      String elementTypeName = aFeatures[i].getElementType();
      Boolean multiRefsAllowed = aFeatures[i].getMultipleReferencesAllowed();

      // see if a feature already exists with this name
      FeatureDescription feat = null;
      for (int j = 0; j < existingFeatures.length; j++) {
        if (existingFeatures[j].getName().equals(featName)) {
          feat = existingFeatures[j];
          break;
        }
      }

      if (feat == null) {
        // doesn't exist; add it
        FeatureDescription featDesc = aType.addFeature(featName, aFeatures[i].getDescription(),
            rangeTypeName, elementTypeName, multiRefsAllowed);
        featDesc.setSourceUrl(aFeatures[i].getSourceUrl());
      } else {// feature does exist
        // check that the range types match
        if (!feat.getRangeTypeName().equals(rangeTypeName)) {
          throw new ResourceInitializationException(
              ResourceInitializationException.INCOMPATIBLE_RANGE_TYPES, new Object[] {
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

    if (!_Type) {

      FeatureDescription[] fds = td.getFeatures();
      for (int i = 0; i < fds.length; i++) {
        FeatureDescription fd = fds[i];
        if (null != typeSystem) {
          String rangeTypeNameCAS = fd.getRangeTypeName();
          Type rangeCasType = typeSystem.getType(rangeTypeNameCAS);
          if (typeSystem.subsumes(casStringType, rangeCasType))
            continue;
        }
        collectImport(fd.getRangeTypeName(), false);
        if (hasArrayRange(fd)) {
          collectImport(getJavaRangeArrayElementType(fd), false);
        }
      }
    }
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

    stringBuffer.append("(JCas jcas, int begin, int end) {\n    super(jcas);\n    setBegin(begin);\n    setEnd(end);\n    readObject();\n  }   \n");
  }
    stringBuffer.append("\n  /** <!-- begin-user-doc -->\n    * Write your own initialization here\n    * <!-- end-user-doc -->\n  @generated modifiable */\n  private void readObject() {/*default - does nothing empty block */}\n     \n");
   FeatureDescription [] fds = td.getFeatures();
   for (int i = 0; i < fds.length; i++) {
     FeatureDescription fd = fds[i];

     String featName = fd.getName();
     String featUName = jg.uc1(featName)// upper case first letter
   if (Jg.reservedFeatureNames.contains(featUName))
     jg.error.newError(IError.ERROR,
     jg.getString("reservedNameUsed", new Object[] { featName, td.getName() }),
     null);

     String featDesc = jg.nullBlank(fd.getDescription());
     String featDescCmt = featDesc;

     String rangeType = jg.getJavaRangeType(fd);
     String elemType = jg.getJavaRangeArrayElementType(fd);   

View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

    stringBuffer.append(".typeIndexID;\n  /** @generated \n     @modifiable */\n  @SuppressWarnings (\"hiding\")\n  public final static boolean featOkTst = JCasRegistry.getFeatOkTst(\"");
    stringBuffer.append(td.getName());
    stringBuffer.append("\");\n");
   FeatureDescription [] fds = td.getFeatures();
   for (int i = 0; i < fds.length; i++) {
     FeatureDescription fd = fds[i];

     String featName = fd.getName();
     String featUName = jg.uc1(featName)// upper case first letter

     String rangeType = jg.getJavaRangeType(fd);
     String getSetNamePart = jg.sc(rangeType);
     String returnType = getSetNamePart.equals("Ref") ? "int" : rangeType;
     String getSetArrayNamePart = jg.getGetSetArrayNamePart(fd);
    
     String elemType = jg.getJavaRangeArrayElementType(fd);   
     if (jg.sc(elemType).equals("Ref"))
       elemType = "int";  
     String casFeatCode = "casFeatCode_" + featName;

    stringBuffer.append(" \n  /** @generated */\n  final Feature casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(";\n  /** @generated */\n  final int     ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append(";\n  /** @generated */ \n  public ");
    stringBuffer.append(returnType);
    stringBuffer.append(" get");
    stringBuffer.append(featUName);
    stringBuffer.append("(int addr) {\n    ");
    stringBuffer.append("");
 
/* checks to insure that cas has the feature */

    stringBuffer.append("    if (featOkTst && casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(" == null)\n      jcas.throwFeatMissing(\"");
    stringBuffer.append(featName);
    stringBuffer.append("\", \"");
    stringBuffer.append(td.getName());
    stringBuffer.append("\");\n");
    stringBuffer.append("    return ll_cas.ll_get");
    stringBuffer.append(getSetNamePart);
    stringBuffer.append("Value(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append(");\n  }\n  /** @generated */    \n  public void set");
    stringBuffer.append(featUName);
    stringBuffer.append("(int addr, ");
    stringBuffer.append(returnType);
    stringBuffer.append(" v) {\n    ");
    stringBuffer.append("");
 
/* checks to insure that cas has the feature */

    stringBuffer.append("    if (featOkTst && casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(" == null)\n      jcas.throwFeatMissing(\"");
    stringBuffer.append(featName);
    stringBuffer.append("\", \"");
    stringBuffer.append(td.getName());
    stringBuffer.append("\");\n");
    stringBuffer.append("    ll_cas.ll_set");
    stringBuffer.append(getSetNamePart);
    stringBuffer.append("Value(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append(", v);}\n    \n ");
  if (jg.hasArrayRange(fd)) {
    stringBuffer.append("  /** @generated */\n  public ");
    stringBuffer.append(elemType);
    stringBuffer.append(" get");
    stringBuffer.append(featUName);
    stringBuffer.append("(int addr, int i) {\n    ");
    stringBuffer.append("");
 
/* checks to insure that cas has the feature */

    stringBuffer.append("    if (featOkTst && casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(" == null)\n      jcas.throwFeatMissing(\"");
    stringBuffer.append(featName);
    stringBuffer.append("\", \"");
    stringBuffer.append(td.getName());
    stringBuffer.append("\");\n");
    stringBuffer.append("    if (lowLevelTypeChecks)\n      return ll_cas.ll_get");
    stringBuffer.append(getSetArrayNamePart);
    stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i, true);\n    jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i);\n  return ll_cas.ll_get");
    stringBuffer.append(getSetArrayNamePart);
    stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i);\n  }\n   \n  /** @generated */ \n  public void set");
    stringBuffer.append(featUName);
    stringBuffer.append("(int addr, int i, ");
    stringBuffer.append(elemType);
    stringBuffer.append(" v) {\n    ");
    stringBuffer.append("");
 
/* checks to insure that cas has the feature */

    stringBuffer.append("    if (featOkTst && casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(" == null)\n      jcas.throwFeatMissing(\"");
    stringBuffer.append(featName);
    stringBuffer.append("\", \"");
    stringBuffer.append(td.getName());
    stringBuffer.append("\");\n");
    stringBuffer.append("    if (lowLevelTypeChecks)\n      ll_cas.ll_set");
    stringBuffer.append(getSetArrayNamePart);
    stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i, v, true);\n    jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i);\n    ll_cas.ll_set");
    stringBuffer.append(getSetArrayNamePart);
    stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
    stringBuffer.append(casFeatCode);
    stringBuffer.append("), i, v);\n  }\n");
   }
    stringBuffer.append(" \n");
   }
    stringBuffer.append("\n");
   if (td.getName().equals("uima.cas.Annotation")) {
    stringBuffer.append("  ");
    stringBuffer.append("  /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n    * @generated */ \n  public String getCoveredText(int inst) { \n    final CASImpl casView = ll_cas.ll_getSofaCasView(inst);\n    final String text = casView.getDocumentText();\n    if (text == null) {\n      return null;\n    }\n    return text.substring(getBegin(inst), getEnd(inst)); \n  }\n");
    stringBuffer.append("");
   } /* of Annotation if-statement */
    stringBuffer.append("\n\n  /** initialize variables to correspond with Cas Type and Features\n  * @generated */\n  public ");
    stringBuffer.append(typeName_Type);
    stringBuffer.append("(JCas jcas, Type casType) {\n    super(jcas, casType);\n    casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());\n\n");
   for (int i = 0; i < fds.length; i++) {
     FeatureDescription fd = fds[i];

     String featName = fd.getName();


    stringBuffer.append(" \n    casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(" = jcas.getRequiredFeatureDE(casType, \"");
    stringBuffer.append(featName);
    stringBuffer.append("\", \"");
    stringBuffer.append(fd.getRangeTypeName());
    stringBuffer.append("\", featOkTst);\n    casFeatCode_");
    stringBuffer.append(featName);
    stringBuffer.append("  = (null == casFeat_");
    stringBuffer.append(featName);
    stringBuffer.append(") ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_");
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

          // TODO create correct feature description! Works right now because the type is not
          // checked
          String type = each.getType();
          type = translate(type);
          type = expand(type);
          FeatureDescription f = new FeatureDescription_impl(each.getName(), "", type);
          feats.add(f);
          if (type.equals("INT") || type.equals("STRING") || type.equals("DOUBLE")
                  || type.equals("FLOAT") || type.equals("BOOLEAN")) {
            continue;
          }
View Full Code Here

Examples of org.apache.uima.resource.metadata.FeatureDescription

    try {
      super.setUp();

      TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
      TypeDescription type1 = typeSystem.addType("Fake", "A Fake Type", "Annotation");
      FeatureDescription feature1 = type1.addFeature("TestFeature", "For Testing Only",
              CAS.TYPE_NAME_STRING);
      TypeDescription enumType = typeSystem.addType("EnumType", "Test Enumerated Type",
              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.