Package org.apache.uima.adapter.vinci
Class CASTransportable
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.uima.adapter.vinci.CASTransportable
-
- All Implemented Interfaces:
Transportable
,org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
public class CASTransportable extends org.xml.sax.helpers.DefaultHandler implements Transportable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
CASTransportable.XTalkSerializer
This nested class handles serializing the CAS to XTalk through events provided by an XCASSerializer.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
command
private java.lang.String
error
private VinciFrame
extraDataFrame
private org.xml.sax.ContentHandler
handler
boolean
ignoreResponse
boolean
includeDocText
private boolean
incomingCommand
private boolean
incomingError
private boolean
incomingExtraData
private java.lang.String
lastqName
private byte[]
mybuf
private CAS
myCas
private CasPool
myCasPool
private OutOfTypeSystemData
outOfTypeSystemData
private int
ready
UimaContext
uimaContext
-
Constructor Summary
Constructors Constructor Description CASTransportable(CAS cas, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, boolean includeDocText)
This constructor is used on the client side, where we have a dedicated CAS instance for the request.CASTransportable(CasPool casPool, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, boolean includeDocText)
This constructor is used on the service side - a CAS Pool reference is provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
void
cleanup()
private java.io.IOException
convertToIOException(java.lang.Throwable t)
Converts a Throwable to an IOException.void
endDocument()
void
endElement(java.lang.String uri, java.lang.String name, java.lang.String qName)
protected void
finalize()
KeyValuePair
fromStream(java.io.InputStream is)
Read the object from the input stream.CAS
getCas()
Gets the cas.java.lang.String
getCommand()
Gets the command.VinciFrame
getExtraDataFrame()
Gets the extra data frame.OutOfTypeSystemData
getOutOfTypeSystemData()
Gets the out of type system data.void
setCommand(java.lang.String command)
Sets the command.void
startDocument()
void
startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atts)
void
toStream(java.io.OutputStream os)
Serialize the CAS to the stream in XTalk format.org.xml.sax.SAXException
wrapAsSAXException(java.io.IOException e)
Create a SAXException that wraps the given IOException.
-
-
-
Field Detail
-
myCasPool
private CasPool myCasPool
-
myCas
private CAS myCas
-
mybuf
private byte[] mybuf
-
outOfTypeSystemData
private OutOfTypeSystemData outOfTypeSystemData
-
incomingCommand
private boolean incomingCommand
-
incomingError
private boolean incomingError
-
incomingExtraData
private boolean incomingExtraData
-
lastqName
private java.lang.String lastqName
-
command
private java.lang.String command
-
error
private java.lang.String error
-
ready
private int ready
-
handler
private org.xml.sax.ContentHandler handler
-
extraDataFrame
private VinciFrame extraDataFrame
-
uimaContext
public UimaContext uimaContext
-
includeDocText
public boolean includeDocText
-
ignoreResponse
public boolean ignoreResponse
-
-
Constructor Detail
-
CASTransportable
public CASTransportable(CasPool casPool, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, boolean includeDocText)
This constructor is used on the service side - a CAS Pool reference is provided. We don't check a CAS out of the pool until we get a request.- Parameters:
casPool
- the cas pooloutOfTypeSystemData
- the out of type system datauimaContext
- the uima contextincludeDocText
- the include doc text
-
CASTransportable
public CASTransportable(CAS cas, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, boolean includeDocText)
This constructor is used on the client side, where we have a dedicated CAS instance for the request.- Parameters:
cas
- the casoutOfTypeSystemData
- the out of type system datauimaContext
- the uima contextincludeDocText
- the include doc text
-
-
Method Detail
-
getExtraDataFrame
public VinciFrame getExtraDataFrame()
Gets the extra data frame.- Returns:
- the extra data frame
-
getOutOfTypeSystemData
public OutOfTypeSystemData getOutOfTypeSystemData()
Gets the out of type system data.- Returns:
- the out of type system data
-
getCommand
public java.lang.String getCommand()
Gets the command.- Returns:
- the command
-
setCommand
public void setCommand(java.lang.String command)
Sets the command.- Parameters:
command
- the new command
-
getCas
public CAS getCas()
Gets the cas.- Returns:
- the cas
-
fromStream
public KeyValuePair fromStream(java.io.InputStream is) throws java.io.IOException
Description copied from interface:Transportable
Read the object from the input stream.- Specified by:
fromStream
in interfaceTransportable
- Parameters:
is
- The stream to read from.- Returns:
- -
- Throws:
java.io.IOException
- -
-
toStream
public void toStream(java.io.OutputStream os) throws java.io.IOException
Serialize the CAS to the stream in XTalk format. After serialization is complete the cas is returned to the pool (if it was allocated from a pool.)- Specified by:
toStream
in interfaceTransportable
- Parameters:
os
- the os- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
cleanup
public void cleanup()
-
finalize
protected void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
startElement
public void startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String name, java.lang.String qName) throws org.xml.sax.SAXException
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
wrapAsSAXException
public org.xml.sax.SAXException wrapAsSAXException(java.io.IOException e)
Create a SAXException that wraps the given IOException. The wrapping is done using the standard Java 1.4 mechanism, so that getCause() will work. Note that new SAXException(Exception) does NOT work.- Parameters:
e
- an IOException to wrap- Returns:
- a SAX exception for which
getCause()
will returne
.
-
convertToIOException
private java.io.IOException convertToIOException(java.lang.Throwable t)
Converts a Throwable to an IOException. Ift
is an IOException, thent
is returned. If not, then ift
was caused by an IOException (directly or indirectly), then that IOException is returned. Otherwise, a new IOException is created which wraps (is caused by)t
.- Parameters:
t
- the throwable to convert- Returns:
- an IOException which is either t, one of the causes of t, or a new IOException that wraps t.
-
-