/** * Serializes a CAS in the given format. * * @param jcas * CAS (Common Analysis System) to be serialized. * @param type * type of cTAKES (UIMA) serializer used to write CAS. * @param prettyPrint * {@code true} to do pretty printing of output. * @param stream * {@link OutputStream} object used to print out information * extracted by using cTAKES. * @throws SAXException * if there was a SAX exception. * @throws IOException * if any I/O error occurs. */ public static void serialize(JCas jcas, CTAKESSerializer type, boolean prettyPrint, OutputStream stream) throws SAXException, IOException { if (type == CTAKESSerializer.XCAS) { XCASSerializer.serialize(jcas.getCas(), stream, prettyPrint); } else if (type == CTAKESSerializer.XMI) { XmiCasSerializer.serialize(jcas.getCas(), jcas.getTypeSystem(), stream, prettyPrint, new XmiSerializationSharedData()); } else { XmlCasSerializer.serialize(jcas.getCas(), jcas.getTypeSystem(), stream); } }
@Override public AnnotationTree<T> tree(T annot) { AnnotationTreeImpl<T> tree = new AnnotationTreeImpl<T>(); AnnotationTreeNodeImpl<T> root = new AnnotationTreeNodeImpl<T>(); tree.setRoot(root); root.set(annot); addChildren(root, subiterator(annot, false, true)); return tree; }
public int ll_createDocumentAnnotationNoIndex(int begin, int end) { final TypeSystemImpl ts = this.svd.casMetadata.ts; int fsRef = ll_createAnnotation(ts.docType.getCode(), begin, end); ll_setStringValue(fsRef, ts.langFeat.getCode(), CAS.DEFAULT_LANGUAGE_NAME); return fsRef; }
/** updates the Cas, setting the indexed value with the corresponding Cas FeatureStructure. */ public void set(int i, FeatureStructure v) { jcasType.casImpl.checkArrayBounds(addr, i); jcasType.ll_cas.ll_setRefArrayValue(addr, i, jcasType.ll_cas.ll_getFSRef(v)); }
public void reinit(CASSerializer ser) { if (this != this.svd.baseCAS) { this.svd.baseCAS.reinit(ser); return; } this.resetNoQuestions(); reinit(ser.getHeapMetadata(), ser.getHeapArray(), ser.getStringTable(), ser.getFSIndex(), ser .getByteArray(), ser.getShortArray(), ser.getLongArray()); }
/** * Constructor * * @param iicp the sorted index for a type being cached */ public FSIndexFlat(IndexIteratorCachePair<T> iicp) { this.iicp = iicp; indexUpdateCountsResetValues = iicp.createIndexUpdateCountsAtReset(); debugTypeCode = iicp.getFsLeafIndex().getTypeCode(); casResetCount = iicp.getCASImpl().getCasResets(); casId = iicp.getCASImpl().getCasId(); }
@Override public void ll_setBooleanArrayValue(int fsRef, int position, boolean b) { byte value = (byte) (b ? CASImpl.TRUE : CASImpl.FALSE); final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getByteHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.BYTEHEAP, 1); } }
@Override public void ll_setShortArrayValue(int fsRef, int position, short value) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getShortHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.SHORTHEAP, 1); } }
@Override public void ll_setLongArrayValue(int fsRef, int position, long value) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getLongHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.LONGHEAP, 1); } }
@Override public int ll_createBooleanArray(int arrayLength) { final int addr = ll_createAuxArray(TypeSystemImpl.booleanArrayTypeCode, arrayLength); this.getHeap().heap[addr + arrayContentOffset] = this.getByteHeap().reserve(arrayLength); return addr; }
@Override public int ll_createShortArray(int arrayLength) { final int addr = ll_createAuxArray(TypeSystemImpl.shortArrayTypeCode, arrayLength); this.getHeap().heap[addr + arrayContentOffset] = this.getShortHeap().reserve(arrayLength); return addr; }
@Override public int ll_createDoubleArray(int arrayLength) { final int addr = ll_createAuxArray(TypeSystemImpl.doubleArrayTypeCode, arrayLength); this.getHeap().heap[addr + arrayContentOffset] = this.getLongHeap().reserve(arrayLength); return addr; }
@Override public boolean ll_getBooleanArrayValue(int fsRef, int position) { final int pos = this.getHeap().heap[getArrayStartAddress(fsRef)]; return CASImpl.TRUE == this.getByteHeap().getHeapValue(pos + position); }
void createStringTableFromArray(String[] stringTable) { // why a new heap instead of reseting the old one??? // this.stringHeap = new StringHeap(); this.getStringHeap().reset(); for (int i = 1; i < stringTable.length; i++) { this.getStringHeap().addString(stringTable[i]); } }
@Override public int ll_getCharBufferValueSize(int fsRef, int featureCode) { final int stringCode = ll_getIntValue(fsRef, featureCode); if (stringCode == NULL) { return -1; } return this.getStringHeap().getCharArrayLength(stringCode); }
@Override public void ll_setLongValue(int fsRef, int featureCode, long value) { final int offset = this.getLongHeap().addLong(value); setFeatureValue(fsRef, featureCode, offset); }
/** * @see org.apache.uima.cas.ArrayFS#size() */ public int size() { return this.getCASImpl().ll_getArraySize(this.getAddress()); }
/** * see org.apache.uima.cas.AnnotationBase#getView() */ public CAS getView() { return getCASImpl().ll_getSofaCasView(this.addr); } }
private int compareFeat(int o1, int o2, int featCode) { final int f1 = cas.ll_getIntValue(o1, featCode); final int f2 = cas.ll_getIntValue(o2, featCode); return compareInts(f1, f2); }
private XCASParsingException createException(int code, String arg) { XCASParsingException e = createException(code); e.addArgument(arg); return e; }