public static int getAddr(FeatureStructure aFS) { return ((CASImpl) aFS.getCAS()).ll_getFSRef(aFS); }
public static int getAddr(FeatureStructure aFS) { return ((CASImpl) aFS.getCAS()).ll_getFSRef(aFS); }
/** * @see org.apache.uima.cas.FSIndexRepository#removeFS(org.apache.uima.cas.FeatureStructure) */ public void removeFS(FeatureStructure fs) { ll_removeFS(this.cas.ll_getFSRef(fs)); // final int typeCode = // this.cas.ll_getFSRefType(this.cas.ll_getFSRef(fs)); // // final TypeImpl type = (TypeImpl) fs.getType(); // ArrayList idxList = this.indexArray[typeCode]; // final int max = idxList.size(); // incrementIllegalIndexUpdateDetector(typeCode); // for (int i = 0; i < max; i++) { // ((IndexIteratorCachePair) idxList.get(i)).index.deleteFS(fs); // } }
/** * @see org.apache.uima.cas.ArrayFS#set(int, FeatureStructure) */ public void set(int i, FeatureStructure fs) throws ArrayIndexOutOfBoundsException { this.casImpl.setArrayValue(this.addr, i, this.getCASImpl().ll_getFSRef(fs)); }
@Override public String getDocumentLanguage() { if (this == this.svd.baseCAS) { // base CAS has no document return null; } final int docAnnotAddr = ll_getFSRef(getDocumentAnnotation()); return ll_getStringValue(docAnnotAddr, TypeSystemImpl.langFeatCode); }
/** * @see org.apache.uima.cas.ArrayFS#copyFromArray(FeatureStructure[], int, * int, int) */ public void copyFromArray(FeatureStructure[] src, int srcOffset, int destOffset, int length) throws ArrayIndexOutOfBoundsException { if ((destOffset < 0) || ((destOffset + length) > size())) { throw new ArrayIndexOutOfBoundsException(); } destOffset += this.casImpl.getArrayStartAddress(this.addr); for (int i = 0; i < length; i++) { // cas.getHeap().heap[destOffset] = // ((FeatureStructureImpl)src[srcOffset]).getAddress(); this.casImpl.getHeap().heap[destOffset] = this.getCASImpl().ll_getFSRef(src[srcOffset]); ++destOffset; ++srcOffset; } }
public void addSofa(FeatureStructure sofa, String sofaName, String mimeType) { if (this.svd.sofaNameSet.contains(sofaName)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.SOFANAME_ALREADY_EXISTS, new String[] { sofaName }); throw e; } final int llsofa = ll_getFSRef(sofa); if (0 == ll_getIntValue(llsofa, TypeSystemImpl.sofaNumFeatCode)) { ll_setIntValue(llsofa, TypeSystemImpl.sofaNumFeatCode, ++this.svd.viewCount); } ll_setStringValue(llsofa, TypeSystemImpl.sofaIdFeatCode, sofaName); ll_setStringValue(llsofa, TypeSystemImpl.sofaMimeFeatCode, mimeType); this.getBaseIndexRepository().addFS(sofa); this.svd.sofaNameSet.add(sofaName); }
@Override public AnnotationFS createAnnotation(Type type, int begin, int end) { if (this == this.svd.baseCAS) { // Can't create annotation on base CAS CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INVALID_BASE_CAS_METHOD, new String[] { "createAnnotation(Type, int, int)" }); throw e; } FeatureStructure fs = createFS(type); final int addr = ll_getFSRef(fs); // setSofaFeat(addr, this.mySofaRef); // already done by createFS setFeatureValueNotJournaled(addr, TypeSystemImpl.startFeatCode, begin); // because it's a create - not in index // setStartFeat(addr, begin); setFeatureValueNotJournaled(addr, TypeSystemImpl.endFeatCode, end); // because it's a create - not in index // setEndFeat(addr, end); return (AnnotationFS) fs; }
private void storeReferencesAndTargetsInMap(Map<Integer, CoreferenceLink> aReferencesMap, eu.clarin.weblicht.wlfxb.tc.api.ReferencedEntity entity, TextCorpus aCorpusData, Map<String, Token> aTokens, JCas aJcas) { for (Reference reference : entity.getReferences()) { StringBuilder sbTokens = new StringBuilder(); for (eu.clarin.weblicht.wlfxb.tc.api.Token token : aCorpusData.getReferencesLayer() .getTokens(reference)) { sbTokens.append(token.getID()).append(" "); } String[] referenceTokens = sbTokens.toString().split(" "); int begin = getOffsets(referenceTokens, aTokens)[0]; int end = getOffsets(referenceTokens, aTokens)[1]; CoreferenceLink link = new CoreferenceLink(aJcas); link.setBegin(begin); link.setEnd(end); String referencesType = reference.getType() == null ? "nam" : reference.getType(); link.setReferenceType(referencesType); if (reference.getRelation() != null) { link.setReferenceRelation(reference.getRelation()); } link.addToIndexes(); aReferencesMap.put(aJcas.getCasImpl().ll_getFSRef(link), link); } }
private void storeReferencesAndTargetsInMap(Map<Integer, CoreferenceLink> aReferencesMap, eu.clarin.weblicht.wlfxb.tc.api.ReferencedEntity entity, TextCorpus aCorpusData, Map<String, Token> aTokens, JCas aJcas) { for (Reference reference : entity.getReferences()) { StringBuilder sbTokens = new StringBuilder(); for (eu.clarin.weblicht.wlfxb.tc.api.Token token : aCorpusData.getReferencesLayer() .getTokens(reference)) { sbTokens.append(token.getID()).append(" "); } String[] referenceTokens = sbTokens.toString().split(" "); int begin = getOffsets(referenceTokens, aTokens)[0]; int end = getOffsets(referenceTokens, aTokens)[1]; CoreferenceLink link = new CoreferenceLink(aJcas); link.setBegin(begin); link.setEnd(end); String referencesType = reference.getType() == null ? "nam" : reference.getType(); link.setReferenceType(referencesType); if (reference.getRelation() != null) { link.setReferenceRelation(reference.getRelation()); } link.addToIndexes(); aReferencesMap.put(aJcas.getCasImpl().ll_getFSRef(link), link); } }
private static void forceSetFeatureValue(FeatureStructure aFS, String aFeatureName, String aValue) { CASImpl casImpl = (CASImpl) aFS.getCAS().getLowLevelCAS(); TypeSystemImpl ts = (TypeSystemImpl) aFS.getCAS().getTypeSystem(); Feature feat = aFS.getType().getFeatureByBaseName(aFeatureName); int featCode = ((FeatureImpl) feat).getCode(); int thisType = ((TypeImpl) aFS.getType()).getCode(); if (!ts.isApprop(thisType, featCode)) { throw new IllegalArgumentException("Feature structure does not have that feature"); } if (!ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), feat.getRange())) { throw new IllegalArgumentException("Not a string feature!"); } casImpl.ll_setStringValue(casImpl.ll_getFSRef(aFS), featCode, aValue); }
private static void forceSetFeatureValue(FeatureStructure aFS, String aFeatureName, String aValue) { CASImpl casImpl = (CASImpl) aFS.getCAS().getLowLevelCAS(); TypeSystemImpl ts = (TypeSystemImpl) aFS.getCAS().getTypeSystem(); Feature feat = aFS.getType().getFeatureByBaseName(aFeatureName); int featCode = ((FeatureImpl) feat).getCode(); int thisType = ((TypeImpl) aFS.getType()).getCode(); if (!ts.isApprop(thisType, featCode)) { throw new IllegalArgumentException("Feature structure does not have that feature"); } if (!ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), feat.getRange())) { throw new IllegalArgumentException("Not a string feature!"); } casImpl.ll_setStringValue(casImpl.ll_getFSRef(aFS), featCode, aValue); }
public void setFeatureValue(Feature feat, FeatureStructure fs) { final int valueAddr = this.getCASImpl().ll_getFSRef(fs); final int featCode = ((FeatureImpl) feat).getCode(); final int rangeType = this.getCASImpl().getTypeSystemImpl().range(featCode); if (valueAddr == CASImpl.NULL) { setNullValue(featCode, rangeType); return; } final int thisType = this.getCASImpl().getHeapValue(this.getAddress()); final int valueType = this.getCASImpl().getHeapValue(valueAddr); if (!this.getCASImpl().getTypeSystemImpl().isApprop(thisType, featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE, new String[] { feat.getName(), this.getType().getName() }); throw e; } if (!this.getCASImpl().getTypeSystemImpl().subsumes(rangeType, valueType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_RANGE, new String[] { feat.getName(), feat.getRange().getName(), fs.getType().getName() }); throw e; } // keys are not fsRefs this.getCASImpl().setFeatureValueNoIndexCorruptionCheck(this.getAddress(), featCode, valueAddr); }