boolean hasArrayRange(FeatureDescription fd) { TypeInfo bi = (TypeInfo) JcasGen.builtInTypes.get(fd.getRangeTypeName()); if (null == bi) return false; return bi.isArray; }
/** * Checks for array range. * * @param fd the fd * @return true, if successful */ boolean hasArrayRange(FeatureDescription fd) { TypeInfo bi = Jg.builtInTypes.get(fd.getRangeTypeName()); if (null == bi) return false; return bi.isArray; }
private Resource getRange(FeatureDescription feature) { String rangeTypeName = feature.getRangeTypeName(); Resource range; switch (rangeTypeName) {
protected boolean isSameFeatureDescription(FeatureDescription f1, FeatureDescription f2) { if (!f2.getName().equals(f1.getName())) return false; return f2.getRangeTypeName().equals(f1.getRangeTypeName()); }
/** * Checks if is same feature description. * * @param f1 the f 1 * @param f2 the f 2 * @return true, if is same feature description */ private boolean isSameFeatureDescription(FeatureDescription f1, FeatureDescription f2) { if (!f2.getName().equals(f1.getName())) return false; if (!f2.getRangeTypeName().equals(f1.getRangeTypeName())) return false; return true; }
private boolean checkFeatureKind(FeatureDescription f, int kind) { if (kind == -1) { return true; } String t = f.getRangeTypeName(); if (t.equals(CAS.TYPE_NAME_BOOLEAN) && RutaTypeConstants.RUTA_TYPE_B == kind) { return true; } else if (t.equals(CAS.TYPE_NAME_STRING) && RutaTypeConstants.RUTA_TYPE_S == kind) { return true; } else if ((t.equals(CAS.TYPE_NAME_BYTE) || t.equals(CAS.TYPE_NAME_DOUBLE) || t.equals(CAS.TYPE_NAME_FLOAT) || t.equals(CAS.TYPE_NAME_INTEGER) || t.equals(CAS.TYPE_NAME_LONG) || t.equals(CAS.TYPE_NAME_SHORT)) && RutaTypeConstants.RUTA_TYPE_N == kind) { return true; } else if (RutaTypeConstants.RUTA_TYPE_AT == kind) { return true; } return false; }
/** * Checks if is string subtype. * * @param fd the fd * @return true, if is string subtype */ boolean isStringSubtype(FeatureDescription fd) { if (null != typeSystem) { String rangeTypeName = fd.getRangeTypeName(); TypeImpl rangeType = (TypeImpl) typeSystem.getType(rangeTypeName); return rangeType.getSuperType() == ((TypeSystemImpl)typeSystem).stringType; } return false; }
/** * Type requires type. * * @param upstreamType the upstream type * @param typeName the type name * @return true, if successful */ private boolean typeRequiresType(TypeDescription upstreamType, String typeName) { if (null == typeName) return false; if (typeName.equals(upstreamType.getSupertypeName())) { return true; } FeatureDescription[] features = upstreamType.getFeatures(); if (features == null) { return false; } for (int i = 0; i < features.length; i++) { if (typeName.equals(features[i].getRangeTypeName())) { return true; } } return false; }
/** * Gets the java range type. * * @param fd the fd * @return the java range type */ String getJavaRangeType(FeatureDescription fd) { String rangeTypeNameCAS = fd.getRangeTypeName(); if (null != typeSystem) { Type rangeCasType = typeSystem.getType(rangeTypeNameCAS); if (rangeCasType instanceof TypeImpl_string) { // type is a subtype of string, make its java type = to string return "String"; } } return getJavaName(rangeTypeNameCAS); }
String getJavaRangeArrayElementType(FeatureDescription fd) { String arrayElementCasNameWithNameSpace = fd.getElementType(); TypeInfo bi = (TypeInfo) JcasGen.builtInTypes.get(fd.getRangeTypeName()); if (null == bi) { if (null == arrayElementCasNameWithNameSpace) return ""; return getJavaName(arrayElementCasNameWithNameSpace); } if (null != arrayElementCasNameWithNameSpace && !"".equals(arrayElementCasNameWithNameSpace)) { return getJavaName(arrayElementCasNameWithNameSpace); } return getJavaName(bi.arrayElNameWithPkg); }
String getJavaRangeType(FeatureDescription fd) { String rangeTypeNameCAS = fd.getRangeTypeName(); if (null != typeSystem) { Type rangeCasType = typeSystem.getType(rangeTypeNameCAS); if (typeSystem.subsumes(casStringType, rangeCasType)) { // type is a subtype of string, make its java type = to string return "String"; } } return getJavaName(rangeTypeNameCAS); }
/** * New Feature test: return null if OK, error message otherwise. * * @param td the td * @param dialog the dialog * @return error message or null */ private String newFeatureTests(TypeDescription td, AddFeatureDialog dialog) { FeatureDescription fd; if (isLocalFeature(dialog.featureName, td)) return "Duplicate Feature Name in this Descriptor"; if (isBuiltInFeature(dialog.featureName, td)) return "Feature Name duplicates built-in feature for this type"; if (null != (fd = getFeature(td, dialog.featureName))) // verify the range is the same if (!fd.getRangeTypeName().equals(dialog.featureRangeName)) return "Range Name not the same as the range from an imported type/feature description"; return null; }
/** * Checks if is possible index key. * * @param fd the fd * @return true, if is possible index key */ boolean isPossibleIndexKey(FeatureDescription fd) { String rangeTypeName = fd.getRangeTypeName(); // keys are primitives + string + string subtypes TypeImpl rangeType = (null == typeSystem) ? null : (TypeImpl) typeSystem.getType(rangeTypeName); return (null == typeSystem) || // default is to do checking rangeType.isStringSubtype() || BuiltinTypeKinds.primitiveTypeNames_contains(rangeTypeName); // includes String }
/** * Gets the java range array element type. * * @param fd the fd * @return the java range array element type */ String getJavaRangeArrayElementType(FeatureDescription fd) { String arrayElementCasNameWithNameSpace = fd.getElementType(); TypeInfo bi = Jg.builtInTypes.get(fd.getRangeTypeName()); if (null == bi) { if (null == arrayElementCasNameWithNameSpace) return ""; return getJavaName(arrayElementCasNameWithNameSpace); } if (null != arrayElementCasNameWithNameSpace && !"".equals(arrayElementCasNameWithNameSpace)) { return getJavaName(arrayElementCasNameWithNameSpace); } return getJavaName(bi.arrayElNameWithPkg); }
private String checkFSFeatureOfType(String featureName, String longTypeName) { TypeDescription t = typeDescriptionMap.get(longTypeName); if (t == null) { return null; } FeatureDescription[] features = t.getFeatures(); for (FeatureDescription featureDescription : features) { String name = featureDescription.getName(); String rangeTypeName = featureDescription.getRangeTypeName(); boolean isFS = isFeatureStructure(rangeTypeName); if (name.equals(featureName)) { if (isFS) { return rangeTypeName; } else if (StringUtils.equals(CAS.TYPE_NAME_FS_ARRAY, rangeTypeName)) { String elementType = featureDescription.getElementType(); if (elementType == null) { return CAS.TYPE_NAME_FS_ARRAY; } else { return elementType; } } } } return null; }
Collection collectImports(TypeDescription td, boolean _Type) { if (_Type) _imports.clear(); else imports.clear(); collectImport(td.getName(), _Type); collectImport(td.getSupertypeName(), _Type); 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); } } } return (_Type) ? _imports.values() : imports.values(); }
protected String makeAttribute(FeatureDescription fd) { String rangeTypeName = fd.getRangeTypeName(); Attribute attr = null; if (rangeTypeName.equals("uima.cas.String")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Integer")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Double")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Boolean")) { attr = new Attribute(fd.getName()); return fd.getName(); } // return attr; return null; }
/** * Handle hover. * * @param event the event */ public void handleHover(Event event) { // next getItem call requires that table have SWT.FULL_SELECTION Style TableTreeItem item = tt.getItem(new Point(event.x, event.y)); if (null != item) { Object o = item.getData(); if (null == o) throw new InternalErrorCDE("invalid state"); if (o instanceof TypeDescription) { setToolTipText(tt, ((TypeDescription) o).getDescription()); } else if (o instanceof FeatureDescription) { FeatureDescription fd = (FeatureDescription) o; if (item.getBounds(MULTIPLE_REF_OK_COL).contains(event.x, event.y) && isArrayOrListType(fd.getRangeTypeName())) { Boolean mra = fd.getMultipleReferencesAllowed(); setToolTipText(tt, (mra != null && mra.booleanValue()) ? "Multiple References Allowed" : "Multiple References Not Allowed"); } else setToolTipText(tt, fd.getDescription()); } else if (o instanceof AllowedValue) { setToolTipText(tt, ((AllowedValue) o).getDescription()); } } else tt.setToolTipText(""); }
/** * Update gui feature. * * @param fItem the f item * @param fd the fd * @param td the td */ private void updateGuiFeature(TableTreeItem fItem, FeatureDescription fd, TypeDescription td) { String rangeType; fItem.setText(NAME_COL, fd.getName()); fItem.setText(RANGE_COL, formatName(rangeType = fd.getRangeTypeName())); fItem.setData(fd); setItemColor(fItem, null != getLocalFeatureDefinition(td, fd)); if (isArrayOrListType(rangeType)) { Boolean mra = fd.getMultipleReferencesAllowed(); fItem.setImage(MULTIPLE_REF_OK_COL, (null != mra && mra.booleanValue()) ? TAEConfiguratorPlugin .getImage(TAEConfiguratorPlugin.IMAGE_MREFOK) : TAEConfiguratorPlugin .getImage(TAEConfiguratorPlugin.IMAGE_NOMREF)); } else { fItem.setImage(MULTIPLE_REF_OK_COL, null); } String ert = fd.getElementType(); fItem.setText(ELEMENT_TYPE_COL, (isFSArrayOrListType(rangeType) && ert != null) ? formatName(ert) : ""); }
/** * Feature update. * * @param fd the fd * @param dialog the dialog */ public void featureUpdate(FeatureDescription fd, AddFeatureDialog dialog) { valueChanged = false; String v = setValueChanged(dialog.featureName, fd.getName()); fd.setName(v); v = setValueChanged(multiLineFix(dialog.description), fd.getDescription()); fd.setDescription(v); String range = setValueChanged(dialog.featureRangeName, fd.getRangeTypeName()); fd.setRangeTypeName(range); if (isArrayOrListType(range)) { Boolean b = setValueChangedCapitalBoolean(dialog.multiRef, fd.getMultipleReferencesAllowed()); fd.setMultipleReferencesAllowed(b); if (isFSArrayOrListType(range)) { v = setValueChanged(dialog.elementRangeName, fd.getElementType()); fd.setElementType(v); } else { fd.setElementType(null); } } else { fd.setMultipleReferencesAllowed(null); fd.setElementType(null); } }