/** * returns null if no feature by this name. * * @param name the name * @param td the td * @return the feature from type description */ public FeatureDescription getFeatureFromTypeDescription(String name, TypeDescription td) { FeatureDescription[] fds = td.getFeatures(); if (fds == null) return null; for (int i = 0; i < fds.length; i++) { if (name.equals(fds[i].getName())) return fds[i]; } return null; }
private Set<FeatureDescription> getAllDeclaredFeatures(TypeDescription typeDescription, Map<String, TypeDescription> typeMap) { Set<FeatureDescription> result = new HashSet<FeatureDescription>(); if (typeDescription == null) { return result; } FeatureDescription[] features = typeDescription.getFeatures(); if (features == null) { return result; } result.addAll(Arrays.asList(features)); String supertypeName = typeDescription.getSupertypeName(); if (supertypeName != null) { TypeDescription parent = typeMap.get(supertypeName); result.addAll(getAllDeclaredFeatures(parent, typeMap)); } return result; }
/** * Removes the feature. * * @param td the td * @param fd the fd */ private void removeFeature(TypeDescription td, FeatureDescription fd) { td.setFeatures((FeatureDescription[]) Utility.removeElementFromArray(td.getFeatures(), fd, FeatureDescription.class)); }
/** * 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; }
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; }
private void inferFeatureMap(TypeDescription type) { // 1 - Recursively add features of the super type TypeDescription superType = typeSystemDescription.getType(type.getSupertypeName()); if(superType != null) inferFeatureMap(superType); // 2 - Add features of this type for(FeatureDescription feature:type.getFeatures()) { String featureFQN = type.getName() + ":" + feature.getName(); featureMap.put(feature.getName(), featureFQN); featureMap.put(featureFQN, featureFQN); } }
/** * gets a feature description for a type, including supertypes. * * @param td the td * @param featureName the feature name * @return a feature description for a type, including supertypes */ public FeatureDescription getFeature(TypeDescription td, String featureName) { FeatureDescription[] features = td.getFeatures(); String supertypeName; if (null != features) for (int i = 0; i < features.length; i++) { if (featureName.equals(features[i].getName())) return features[i]; } if (null != (supertypeName = td.getSupertypeName())) if (!CAS.TYPE_NAME_TOP.equals(supertypeName)) { TypeDescription supertype = getMergedTypeSystemDescription().getType(supertypeName); if (null == supertype) supertype = (TypeDescription) BuiltInTypes.typeDescriptions.get(supertypeName); return getFeature(supertype, featureName); } return null; }
if (null == mergedTd) return typeFeature0; FeatureDescription[] locallyDefinedFeatures = localTd.getFeatures(); if (null == locallyDefinedFeatures || locallyDefinedFeatures.length == 0) return typeFeature0; FeatureDescription[] remainingFeatures = mergedTd.getFeatures(); ArrayList deletedFeatures = new ArrayList();
throw new ResourceInitializationException(ResourceInitializationException.COULD_NOT_INSTANTIATE, new String[] { annotationType }); FeatureDescription[] fds = typeDescription.getFeatures(); int f = 0;
boolean hasAllowedValues = false; if (null != existingTd) { hasFeatures = ((null != existingTd.getFeatures()) && (existingTd.getFeatures().length > 0)); hasAllowedValues = ((null != existingTd.getAllowedValues()) && (existingTd.getAllowedValues().length > 0)); if (hasAllowedValues) {
if (null != builtInFeatures) { generatedBuiltInTypes.add(td.getName()); List newFeatures = setDifference(td.getFeatures(), builtInFeatures); int newFeaturesSize = newFeatures.size(); if (newFeaturesSize > 0) {
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) { Type type = aTS.getType(aTD.getName()); for (FeatureDescription fd : aTD.getFeatures()) { Feature feat = type.getFeatureByBaseName(fd.getName()); // We do not need to set up built-in features if (isBuiltInFeature(feat)) { continue; } if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) { continue; } AnnotationFeature f = analyzeFeature(aTS, fd, feat); features.put(aLayer.getName(), f); } }
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) { Type type = aTS.getType(aTD.getName()); for (FeatureDescription fd : aTD.getFeatures()) { Feature feat = type.getFeatureByBaseName(fd.getName()); // We do not need to set up built-in features if (isBuiltInFeature(feat)) { continue; } if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) { continue; } AnnotationFeature f = analyzeFeature(aTS, fd, feat); features.put(aLayer.getName(), f); } }
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(); }
FeatureDescription[] fds = td.getFeatures(); for (int i = 0; i < fds.length; i++) { FeatureDescription fd = fds[i];
setItemColor(item, isLocalType(td)); FeatureDescription[] features = td.getFeatures(); addFeaturesToGui(td, item, features); FeatureDescription[] additionalBuiltInFeatures = setDifference(builtInTd.getFeatures(), td .getFeatures()); addFeaturesToGui(td, item, additionalBuiltInFeatures);
for (FeatureDescription fdesc : tdesc.getFeatures()) { Feature f = t.getFeatureByBaseName(fdesc.getName());
for (FeatureDescription fdesc : tdesc.getFeatures()) { Feature f = t.getFeatureByBaseName(fdesc.getName());