/** * Sets the all features. * * @param items Existing array of TypeOrFeature items (input or output) * @param typeName the type name * @param isAllFeatures AllFeatures value * @return the type or feature[] */ private TypeOrFeature[] setAllFeatures(TypeOrFeature[] items, String typeName, boolean isAllFeatures) { TypeOrFeature type = getTypeOrFeature(items, typeName); if (null != type) { type.setAllAnnotatorFeatures(isAllFeatures); return items; } // If get here, case = Type declared as Output(input) or not at all while all Features // declared as Input (output) // Need to add the Type and set the all annotator features value if (isAllFeatures) throw new InternalErrorCDE("invalid state"); return items; }
private TypeOrFeature createTypeOrFeature(String name, boolean isType, boolean aAllAnnotatorFeatures) { TypeOrFeature r = new TypeOrFeature_impl(); r.setType(isType); r.setName(name); if (isType) { r.setAllAnnotatorFeatures(aAllAnnotatorFeatures); } return r; }
/** * @see org.apache.uima.resource.metadata.Capability#addInputType(java.lang.String, * boolean) */ public void addInputType(String aTypeName, boolean aAllAnnotatorFeatures) { TypeOrFeature type = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature(); type.setType(true); type.setName(aTypeName); type.setAllAnnotatorFeatures(aAllAnnotatorFeatures); TypeOrFeature[] oldArr = getInputs(); TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1]; System.arraycopy(oldArr, 0, newArr, 0, oldArr.length); newArr[newArr.length - 1] = type; setInputs(newArr); }
/** * @see org.apache.uima.resource.metadata.Capability#addOutputType(java.lang.String, * boolean) */ public void addOutputType(String aTypeName, boolean aAllAnnotatorFeatures) { TypeOrFeature type = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature(); type.setType(true); type.setName(aTypeName); type.setAllAnnotatorFeatures(aAllAnnotatorFeatures); TypeOrFeature[] oldArr = getOutputs(); TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1]; System.arraycopy(oldArr, 0, newArr, 0, oldArr.length); newArr[newArr.length - 1] = type; setOutputs(newArr); }
/** * Removes the feature. * * @param c the c * @param removeItem the remove item */ private void removeFeature(Capability c, TableTreeItem removeItem) { String shortFeatureName = removeItem.getText(NAME_COL); if (shortFeatureName.equals(ALL_FEATURES)) { if (isInput(removeItem)) { TypeOrFeature tfItem = getTypeOrFeature(c.getInputs(), getFullyQualifiedName(removeItem .getParentItem())); tfItem.setAllAnnotatorFeatures(false); } if (isOutput(removeItem) /* || isUpdate(removeItem) */) { TypeOrFeature tfItem = getTypeOrFeature(c.getOutputs(), getFullyQualifiedName(removeItem .getParentItem())); tfItem.setAllAnnotatorFeatures(false); } } else { String featureNameToRemove = getFullyQualifiedName(removeItem.getParentItem()) + ":" + removeItem.getText(NAME_COL); if (isInput(removeItem)) c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), featureNameToRemove)); if (isOutput(removeItem) /* || isUpdate(removeItem) */) c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), featureNameToRemove)); } removeItem.dispose(); }