/** * 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 protected void initializeNamespaces() { if (cds.sharedData != null && (null != cds.sharedData.getOutOfTypeSystemElements() || cds.sharedData.hasOutOfTypeSystemArrayElements())) { throw new UnsupportedOperationException("Can't do JSON serialization " + "if there are out-of-type-system elements," + " because there's no type information available (needed for _context)"); } }
int getXmiIdAsInt(int fsAddr) { // see if we already have a mapping int xmiId = fsAddrToXmiIdMap.get(fsAddr); if (xmiId == 0) { // to be sure we get a unique Id, increment maxXmiId and use that xmiId = ++maxXmiId; addIdMapping(fsAddr, xmiId); } return xmiId; }
this.lenient = lenient; this.sharedData = sharedData != null ? sharedData : new XmiSerializationSharedData(); this.mergePoint = mergePoint; this.allowPreexistingFS = allowPreexistingFS; this.sharedData.clearIdMap();
int getElementCountForSharedData() { return (sharedData == null) ? 0 : sharedData.getOutOfTypeSystemElements().size(); }
@Override protected void writeView(Sofa sofa, Collection<TOP> members) throws IOException { jch.writeNlJustBeforeNext(); String sofaXmiId = (null == sofa) ? "0" : cds.getXmiId(sofa); jg.writeArrayFieldStart(sofaXmiId); writeViewMembers(members); //check for out-of-typesystem members if (cds.sharedData != null) { List<String> ootsMembers = cds.sharedData.getOutOfTypeSystemViewMembers(sofaXmiId); jch.writeNlJustBeforeNext(); writeViewMembers(ootsMembers); } jg.writeEndArray(); }
: cds.sharedData.getOutOfTypeSystemArrayElements(fsArray); int ootsIndex = 0; TOP[] fsItems = fsArray._getTheArray();
private void addNonsharedFSToEncompassingFSMapping(int nonsharedFS, int encompassingFS ) { //System.out.println("addNonsharedFSToEncompassingFSMapping" + nonsharedFS + " " + encompassingFS); this.sharedData.addNonsharedRefToFSMapping(nonsharedFS, encompassingFS); } }
Iterator<OotsElementData> ootsIter = cds.sharedData.getOutOfTypeSystemElements().iterator(); while (ootsIter.hasNext()) { OotsElementData oed = ootsIter.next();
List<String> ootsMembers = cds.sharedData.getOutOfTypeSystemViewMembers(sofaXmiId); writeViewMembers(membersString, ootsMembers, isPastFirstElement);
int pos = cds.cas.getArrayStartAddress(addr); List<XmiArrayElement> ootsArrayElementsList = cds.sharedData == null ? null : cds.sharedData.getOutOfTypeSystemArrayElements(addr); int ootsIndex = 0; for (int j = 0; j < size; j++) {
protected CAS deserialize(String aSerializedCAS, CAS aCAS) throws Exception { XmiSerializationSharedData deserSharedData = new XmiSerializationSharedData(); uimaSerializer.deserializeCasFromXmi(aSerializedCAS, aCAS, deserSharedData, true, -1); return aCAS; }
if (cds.sharedData == null) return; Iterator<OotsElementData> it = cds.sharedData.getOutOfTypeSystemElements().iterator(); while (it.hasNext()) { OotsElementData oed = it.next();
private void addFsAddrXmiIdMapping(int fsAddr, int xmiId) { if (xmiId > 0) { if (mergePoint < 0) { //if we are not doing a merge, update the map in the XmiSerializationSharedData sharedData.addIdMapping(fsAddr, xmiId); } else { //if we're doing a merge, we can't update the shared map because we could //have duplicate xmi:id values in the different parts of the merge. //instead we keep a local mapping used only within this deserialization. localXmiIdToFsAddrMap.put(xmiId, fsAddr); } } }
protected String serializeCAS(CAS aCAS) throws Exception { XmiSerializationSharedData serSharedData = new XmiSerializationSharedData(); return uimaSerializer.serializeCasToXmi(aCAS, serSharedData); }
private void deserialize(String xmi, CAS cas, String casReferenceId) throws Exception { CacheEntry entry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId); // Processing the reply from a standard, non-parallel delegate XmiSerializationSharedData deserSharedData; deserSharedData = entry.getDeserSharedData(); if (deserSharedData == null) { deserSharedData = new XmiSerializationSharedData(); entry.setXmiSerializationData(deserSharedData); } UimaSerializer uimaSerializer = SerializerCache.lookupSerializerByThreadId(); uimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, -1); }
/** * 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); } }
/** * 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 * {@see 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); } }
switch (serialFormat) { case XMI: XmiSerializationSharedData serSharedData = new XmiSerializationSharedData(); String serializedCAS = serializeCAS(aCAS, serSharedData); msg.put(AsynchAEMessage.CAS, serializedCAS);
deserSharedData = new XmiSerializationSharedData(); uimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, -1); break;