/** * Constructor for FSLeafIndexImpl. * @param cas - * @param type - * @param indexType - */ protected FSLeafIndexImpl(CASImpl cas, Type type, int indexType) { super(); this.indexType = indexType; this.lowLevelCAS = cas; this.type = type; this.typeCode = ((TypeImpl)type).getCode(); }
private SerializedString getSerializedTypeName(TypeImpl ti) { XmlElementName xe = cds.typeCode2namespaceNames[ti.getCode()]; if (null == xe) { // happens for supertypes which have no instantiations String typeName = ti.getName(); xe = uimaTypeName2XmiElementName(typeName); checkForNameCollision(xe); cds.typeCode2namespaceNames[ti.getCode()] = xe; } return getSerializedString(xe.qName); }
private void collectUsedSubtypes() { final TypeImpl[] tiArray = cds.getSortedUsedTypes(); for (TypeImpl ti : tiArray) { // all used types int subtypeCode = ti.getCode(); // loop up the super chain for this type, // add parent -> subtype entries (until try to add one that's already there) for (TypeImpl parent = (TypeImpl) ti.getSuperType(); parent != null; parent = (TypeImpl) parent.getSuperType()) { final int parentCode = parent.getCode(); // next comparator must match the one used for sorting the tiArray // https://issues.apache.org/jira/browse/UIMA-5171 // if parent not contained in tiArray if (Arrays.binarySearch(tiArray, parent, CasSerializerSupport.COMPARATOR_SHORT_TYPENAME) < 0 ) { if (!parentTypesWithNoInstances.contains(parent)) { parentTypesWithNoInstances.add(parent); } } boolean wasAdded = mapType2Subtypes.addSubtype(parentCode, subtypeCode); if (!wasAdded) { break; } subtypeCode = parentCode; } } }
/** * Add subtype information for used types limited to used subtypes * @throws IOException */ private void addJsonSubtypes(TypeImpl ti) throws IOException { IntVector iv = mapType2Subtypes.get(ti.getCode()); if (null != iv && iv.size() > 0) { jch.writeNlJustBeforeNext(); jg.writeFieldName(SUB_TYPES_NAME); jg.writeStartArray(); TypeSystemImpl tsi = ti.getTypeSystem(); for (int typeCode : iv.toArray()) { jg.writeString(getSerializedTypeName(tsi.getTypeForCode(typeCode))); } jg.writeEndArray(); } }
public TypeInfo(TypeImpl type, TypeSystemImpl ts) { List<Feature> features = type.getFeatures(); isArray = type.isArray(); // feature structure array types named type-of-fs[] isHeapStoredArray = (type == ts.intArrayType) || (type == ts.floatArrayType) || (type == ts.fsArrayType) || (type == ts.stringArrayType) || (TypeSystemImpl.isArrayTypeNameButNotBuiltIn(type.getName()));
public String toString() { return getName(); }
if (TypeSystemImpl.intTypeCode != ts.intType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.floatTypeCode != ts.floatType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.stringTypeCode != ts.stringType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.arrayBaseTypeCode != ts.arrayBaseType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.fsArrayTypeCode != fsArray.getCode()) throw new RuntimeException(); if (TypeSystemImpl.floatArrayTypeCode != floatArray.getCode()) throw new RuntimeException(); if (TypeSystemImpl.intArrayTypeCode != intArray.getCode()) throw new RuntimeException(); if (TypeSystemImpl.stringArrayTypeCode != stringArray.getCode()) throw new RuntimeException(); if (TypeSystemImpl.booleanTypeCode != ts.booleanType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.byteTypeCode != ts.byteType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.shortTypeCode != ts.shortType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.longTypeCode != ts.longType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.doubleTypeCode != ts.doubleType.getCode()) throw new RuntimeException(); if (TypeSystemImpl.booleanArrayTypeCode != booleanArray.getCode()) throw new RuntimeException(); if (TypeSystemImpl.byteArrayTypeCode != byteArray.getCode()) throw new RuntimeException();
if (type.isArray()) { int arrayLength = ((CommonArrayFS)fs).size(); SlotKind kind = type.getComponentSlotKind(); int nc = k2nc(kind); switch (kind) { this.children = new ArrayList<FSTreeNode>(type.getNumberOfFeatures()); FeatureImpl[] feats = type.getFeatureImpls(); for (FeatureImpl f : feats) { SlotKind kind = f.getSlotKind();
private static final void getFeatureDefiningSubtypes(Type type, String fName, List<Type> types) { TypeSystem ts = ((TypeImpl) type).getTypeSystem(); List<?> subtypes = ts.getDirectSubtypes(type); for (int i = 0; i < subtypes.size(); i++) { Type subtype = (Type) subtypes.get(i); if (subtype.getFeatureByBaseName(fName) != null) { types.add((Type) subtypes.get(i)); } else { getFeatureDefiningSubtypes(subtype, fName, types); } } }
@Override public Type getParent(Type t) { return ((TypeImpl) t).getSuperType(); }
/** * _feature_types : { "featName" : "_ref" or "_byte_array, ... } * * @param type the type for which to generate the feature context info * @throws IOException */ private void addJsonFeatContext(TypeImpl type) throws IOException { final FeatureImpl[] feats = type.getFeatureImpls(); startedFeatureTypes = false; for (FeatureImpl feat : feats) { final int fsClass = CasSerializerSupport.classifyType(feat.getRangeImpl()); SerializedString featKind = featureTypeLabel(fsClass); if (null != featKind) { maybeDoStartFeatureTypes(); jg.writeFieldName(getSerializedString(feat.getShortName())); jg.writeString(featKind); } } if (startedFeatureTypes) { jg.writeEndObject(); } }
public Type getComponentType() { if (!isArray()) { return null; } return this.ts.ll_getTypeForCode(this.ts.ll_getComponentType(this.code)); }
public TypeInfo(TypeImpl type) { List<Feature> features = type.getFeatures(); isArray = type.isArray(); // feature structure array types named || (TypeSystemImpl.isArrayTypeNameButNotBuiltIn(type.getName()));
/** * Show text popup. * * @param x the x * @param y the y */ @SuppressWarnings("unchecked") public void showTextPopup(int x, int y) { final int pos = this.textArea.getCaretPosition(); this.textPopup.removeAll(); JMenuItem item = new JMenuItem("Position: " + pos); item.setEnabled(false); this.textPopup.add(item); FSNode posAnnot; if (this.isAnnotationIndex) { List<FSNode> annots = ((FSTreeModel) this.fsTree.getModel()).getFSs(); ArrayList<FSNode> selAnnots = getAnnotationsAtPos(pos, annots); for (int i = 0; i < selAnnots.size(); i++) { posAnnot = selAnnots.get(i); item = new JMenuItem("[" + posAnnot.getArrayPos() + "] = " + posAnnot.getType().getName()); item.addActionListener(new PopupHandler(this, posAnnot.getArrayPos())); this.textPopup.add(item); } } this.textPopup.show(this.textArea, x, y); }
/** * @see org.apache.uima.cas.Type#isPrimitive() */ public boolean isPrimitive() { return !(this.getTypeSystem().getLowLevelTypeSystem().ll_isRefType(this.code)); }
/** * 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; }
private void writeFsOrLists(TOP fs, TypeImpl ti, boolean isListAsFSs) throws IOException { final FeatureImpl[] feats = ti.getFeatureImpls();
@Override public int ll_getCodeForType(Type type) { return ((TypeImpl) type).getCode(); }
private static int[] addTypes(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt) { Map<TypeImpl, TypeImpl> mSrc2Tgt = new LinkedHashMap<TypeImpl, TypeImpl>(); for (Iterator<Type> it = tsSrc.getTypeIterator(); it.hasNext();) { TypeImpl tSrc = (TypeImpl) it.next(); TypeImpl tTgt = (TypeImpl) tsTgt.getType(tSrc.getName()); if (tTgt != null) { mSrc2Tgt.put(tSrc, tTgt); } } int[] r = new int[tsSrc.getNumberOfTypes() + 1]; // type codes are numbered starting with 1 for (Entry<TypeImpl, TypeImpl> e : mSrc2Tgt.entrySet()) { r[e.getKey().getCode()] = e.getValue().getCode(); } return r; }
casName = t.getName(); String name_Type; if (builtInsWithNoJCas.contains(casName)) String nameBase = "org.apache.uima.jcas." + casName.substring(5); name_Type = nameBase + "_Type"; jcasTypes.put(nameBase, new LoadedJCasType<>(t.getName(), (Class<? extends TOP_Type>) Class .forName(name_Type, true, cl), cl)); } catch (ClassNotFoundException e1) { jcasTypes.put(casName, new LoadedJCasType<>(t.getName(), (Class<? extends TOP_Type>) Class.forName(name_Type, true, cl), cl));