@Override public int compare(Object o1, Object o2) { TypeOrFeature tf = (TypeOrFeature) o2; return (tf.isType() == false && tf.getName().equals(o1)) ? 0 : 1; } };
@Override boolean visit(TypeOrFeature i_o) { if ((!i_o.isType()) && i_o.getName().equals(typePlusFeature)) { return true; } return false; } };
/** * Checks for type. * * @param items the items * @param name the name * @return true, if successful */ private boolean hasType(TypeOrFeature[] items, String name) { if (null == items) return false; for (int i = 0; i < items.length; i++) { if (items[i].isType() && items[i].getName().equals(name)) return true; } return false; }
@Override public int compare(Object o1, Object o2) { TypeOrFeature tf = (TypeOrFeature) o2; return ((tf.isType() == true && tf.getName().equals(o1)) || // remove features belong to type if type is removed tf.getName().startsWith(((String) o1) + ':')) ? 0 : 1; } };
@Override boolean visit(TypeOrFeature i_o) { if (i_o.isType() && i_o.getName().equals(sTypeName)) return true; else if (i_o.getName().startsWith(sTypeName_Colon)) return true; return false; } };
/** * Given a current list of inputs/ outputs, made up of "Types" and "features", make a new list * keeping all the types, and keeping all the features that belong to other types, and adding the * features that are passed in for one particular type in the "features" parameter. * * @param items the items * @param typeName the type name * @param features - * associated with the type * @return the type or feature[] */ private TypeOrFeature[] replaceFeaturesKeepingTypes(TypeOrFeature[] items, String typeName, List features) { List newItems = new ArrayList(); typeName = typeName + ':'; if (null != items) for (int i = 0; i < items.length; i++) { if (items[i].isType() || !items[i].getName().startsWith(typeName)) newItems.add(items[i]); } for (Iterator it = features.iterator(); it.hasNext();) { newItems.add(it.next()); } return (TypeOrFeature[]) newItems.toArray(new TypeOrFeature[newItems.size()]); }
@Override boolean visit(TypeOrFeature i_o) { if (!i_o.isType() && i_o.getName().equals(oldFullFeatureName)) { somethingChanged[0] = true; i_o.setName(newFullFeatureName); } return false; } };
@Override boolean visit(TypeOrFeature i_o) { if (i_o.isType() && i_o.getName().equals(sOldTypeName)) { capabilityChanged[0] = true; i_o.setName(sNewTypeName); } else if (!i_o.isType() && i_o.getName().startsWith(oldTypeName_colon)) { capabilityChanged[0] = true; i_o.setName(sNewTypeName + ':' + i_o.getName().substring(oldTypeName_colon.length())); } return false; } };
/** * @see org.apache.uima.analysis_engine.ResultSpecification#removeTypeOrFeature(org.apache.uima.analysis_engine.TypeOrFeature) * This removes the type or feature for all languages. * Beware: there are two possible ToFs one with allFeatures set or not (if they have different languages). */ public void removeTypeOrFeature(TypeOrFeature tof) { String name = tof.getName(); if (tof.isType()) { rsTypesMap.remove(name); } else { int i = name.indexOf(TypeSystem.FEATURE_SEPARATOR); rsTypesMap.remove(name.substring(0, i), name.substring(i+1)); } setCompileNeeded(); }
if (outputs[j].isType() && !annotationTypes.contains(outputs[j].getName())) { annotationTypes.add(outputs[j].getName());
if (outputs[j].isType() && !outputTypes.contains(outputs[j].getName())) { outputTypes.add(outputs[j].getName());
/** * return true if the type has a feature (except all-features) marked as INPUT (OUTPUT). * * @param typeName the type name * @param IO the io * @return true if the type has a feature (except all-features) marked as INPUT (OUTPUT) */ private boolean someFeatureOnType(String typeName, int IO) { // special case for all-features TypeOrFeature[] tofs = (IO == INPUT) ? capability.getInputs() : capability.getOutputs(); // you can remove the "INPUT" or "OUTPUT" designation from a type // even if it has the all-features flag on. String typeNamePlusColon = typeName + ':'; for (int i = 0; i < tofs.length; i++) { if (!tofs[i].isType() && tofs[i].getName().startsWith(typeNamePlusColon)) return true; } return false; }
if (outputs[j].isType() && !annotationTypes.contains(outputs[j].getName())) { annotationTypes.add(outputs[j].getName());
/** * Instantiates a new adds the capability feature dialog. * * @param aSection the a section * @param aSelectedType the a selected type * @param c the c */ public AddCapabilityFeatureDialog(AbstractSection aSection, Type aSelectedType, Capability c) { super( aSection, "Specify features input and / or output", "Designate by mouse clicking one or more features in the Input and/or Output column, to designate as Input and/or Output press \"OK\""); selectedType = aSelectedType; allFeatures = selectedType.getFeatures().toArray(featureArray0); Arrays.sort(allFeatures); capability = c; TypeOrFeature[] localInputs = c.getInputs(); String typeName = selectedType.getName(); if (null != localInputs) { for (int i = 0; i < localInputs.length; i++) { if (localInputs[i].isType() && typeName.equals(localInputs[i].getName())) { inputNotAllowed = false; break; } } } }
if (prevTof != null) { if (prevTof.isType()) { if (prevTof != null) { if (prevTof.isType()) { String name = (String) inpsList.nextElement(); TypeOrFeature tof = (TypeOrFeature) mergedInputs.get(name); if (tof.isType()) mergedCapability.addInputType(name, tof.isAllAnnotatorFeatures()); else String name = (String) outsList.nextElement(); TypeOrFeature tof = (TypeOrFeature) mergedOutputs.get(name); if (tof.isType()) mergedCapability.addOutputType(name, tof.isAllAnnotatorFeatures()); else
TypeOrFeature[] outputs = capabilities[i].getOutputs(); for (int j = 0; j < outputs.length; j++) { if (outputs[j].isType()) { outputTypes.add(outputs[j].getName());
/** * @see org.apache.uima.analysis_engine.ResultSpecification#addCapabilities(org.apache.uima.resource.metadata.Capability[], * boolean) */ public void addCapabilities(Capability[] capabilities, boolean outputs) { if (null == capabilities) { return; } for (Capability capability : capabilities) { TypeOrFeature[] tofs = outputs ? capability.getOutputs() : capability.getInputs(); for (TypeOrFeature tof : tofs) { String typeName = tof.getName(); if (!tof.isType()) { int i = typeName.indexOf(TypeSystem.FEATURE_SEPARATOR); String shortFeatName = typeName.substring(i+1); typeName = typeName.substring(0, i); rsTypesMap.add(typeName, shortFeatName, capability.getLanguagesSupported(), false); } else { rsTypesMap.add(typeName, tof.isAllAnnotatorFeatures(), capability.getLanguagesSupported(), false); } } } setCompileNeeded(); }
if (inputs != null) { for (int i = 0; i < inputs.length; i++) { if (inputs[i].isType()) { inputTypesList.add(section.formatName(inputs[i].getName())); if (outputs != null) { for (int i = 0; i < outputs.length; i++) { if (outputs[i].isType()) { outputTypesList.add(section.formatName(outputs[i].getName()));
private static void serializeResultSpecification(ResultSpecification rs, CASImpl cas, IntVector resultSpecTypes, IntVector resultSpecFeatures) { TypeOrFeature[] tofs = rs.getResultTypesAndFeatures(); TypeSystemImpl tsImpl = cas.getTypeSystemImpl(); for (int i = 0; i < tofs.length; ++i) { if (tofs[i].isType()) { TypeImpl t = (TypeImpl) tsImpl.getType(tofs[i].getName()); resultSpecTypes.add(t.getCode()); } else { FeatureImpl f = (FeatureImpl) tsImpl.getFeatureByFullName(tofs[i].getName()); resultSpecFeatures.add(f.getCode()); } } }