|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exist.storage.serializers.Serializer
Serializer base class, used to serialize a document or document fragment
back to XML. A serializer may be obtained by calling DBBroker.getSerializer().
The class basically offers two overloaded methods: serialize()
and toSAX(). serialize() returns the XML as a string, while
toSAX() generates a stream of SAX events. The stream of SAX
events is passed to the ContentHandler set by setContentHandler().
Internally, both types of methods pass events to a Receiver.
Subclasses thus have to implement the various serializeToReceiver() methods.
Output can be configured through properties. Property keys are defined in classes
OutputKeys and EXistOutputKeys
| Field Summary | |
protected static QName |
ATTR_COUNT_QNAME
|
protected static QName |
ATTR_HITS_QNAME
|
protected static QName |
ATTR_START_QNAME
|
protected static QName |
ATTR_TYPE_QNAME
|
protected DBBroker |
broker
|
protected boolean |
createContainerElements
|
protected java.util.Properties |
defaultProperties
|
protected static QName |
ELEM_RESULT_QNAME
|
protected static QName |
ELEM_VALUE_QNAME
|
protected java.lang.String |
encoding
|
static java.lang.String |
ENCODING
|
static java.lang.String |
EXIST_NS
|
protected javax.xml.transform.sax.SAXTransformerFactory |
factory
|
static java.lang.String |
GENERATE_DOC_EVENTS
|
protected org.xml.sax.ext.LexicalHandler |
lexicalHandler
|
protected static Logger |
LOG
|
protected java.util.Properties |
outputProperties
|
protected Receiver |
receiver
|
static int |
TAG_ATTRIBUTE_MATCHES
|
static int |
TAG_BOTH
|
static int |
TAG_ELEMENT_MATCHES
|
static int |
TAG_NONE
|
protected javax.xml.transform.Templates |
templates
|
protected User |
user
|
protected XIncludeFilter |
xinclude
|
protected SAXSerializer |
xmlout
|
protected javax.xml.transform.sax.TransformerHandler |
xslHandler
|
| Constructor Summary | |
Serializer(DBBroker broker,
Configuration config)
|
|
| Method Summary | |
protected void |
applyXSLHandler(java.io.Writer writer)
If an XSL stylesheet is present, plug it into the chain. |
protected void |
checkStylesheetParams()
|
org.xml.sax.ContentHandler |
getContentHandler()
Required by interface XMLReader. |
org.xml.sax.DTDHandler |
getDTDHandler()
Inherited from XMLReader. |
org.xml.sax.EntityResolver |
getEntityResolver()
Return my internal EntityResolver |
org.xml.sax.ErrorHandler |
getErrorHandler()
|
boolean |
getFeature(java.lang.String name)
|
protected int |
getHighlightingMode()
|
java.lang.Object |
getProperty(java.lang.String name)
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
|
User |
getUser()
Get the current User. |
boolean |
isStylesheetApplied()
|
void |
parse(org.xml.sax.InputSource input)
|
void |
parse(java.lang.String systemId)
|
protected void |
releasePrettyPrinter()
|
void |
reset()
Reset the class to its initial state. |
java.lang.String |
serialize(DocumentImpl doc)
|
void |
serialize(DocumentImpl doc,
java.io.Writer writer)
Serialize a document to the supplied writer. |
java.lang.String |
serialize(NodeProxy p)
Serialize a single NodeProxy. |
java.lang.String |
serialize(NodeValue n)
|
protected abstract void |
serializeToReceiver(DocumentImpl doc,
boolean generateDocEvent)
|
protected void |
serializeToReceiver(NodeImpl n,
boolean generateDocEvents)
|
protected abstract void |
serializeToReceiver(NodeProxy p,
boolean generateDocEvent)
|
protected void |
serializeToReceiver(NodeValue v,
boolean generateDocEvents)
|
void |
setContentHandler(org.xml.sax.ContentHandler handler)
|
protected void |
setDocument(DocumentImpl doc)
|
void |
setDTDHandler(org.xml.sax.DTDHandler handler)
Inherited from XMLReader. |
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the entityResolver attribute of the Serializer object |
void |
setErrorHandler(org.xml.sax.ErrorHandler handler)
Sets the errorHandler attribute of the Serializer object |
void |
setFeature(java.lang.String name,
boolean value)
Sets the feature attribute of the Serializer object |
protected void |
setPrettyPrinter(java.io.Writer writer,
boolean xmlDecl)
|
void |
setProperties(java.util.Hashtable table)
|
void |
setProperties(java.util.Properties properties)
|
void |
setProperty(java.lang.String prop,
java.lang.Object value)
|
void |
setReceiver(Receiver receiver)
|
void |
setSAXHandlers(org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler)
Set the ContentHandler to be used during serialization. |
void |
setStylesheet(DocumentImpl doc,
java.lang.String stylesheet)
Plug an XSL stylesheet into the processing pipeline. |
void |
setStylesheet(java.lang.String stylesheet)
|
protected void |
setStylesheetFromProperties(org.w3c.dom.Document doc)
|
void |
setStylesheetParam(java.lang.String param,
java.lang.String value)
Set stylesheet parameter |
void |
setUser(User user)
Set the current User. |
protected void |
setXSLHandler()
|
void |
toReceiver(NodeProxy p)
|
void |
toSAX(DocumentImpl doc)
|
void |
toSAX(NodeProxy p)
|
void |
toSAX(NodeValue n)
|
void |
toSAX(Sequence seq,
int start,
int count,
boolean wrap)
Serialize the items in the given sequence to SAX, starting with item start. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final Logger LOG
public static final java.lang.String EXIST_NS
public static final int TAG_NONE
public static final int TAG_ELEMENT_MATCHES
public static final int TAG_ATTRIBUTE_MATCHES
public static final int TAG_BOTH
public static final java.lang.String GENERATE_DOC_EVENTS
public static final java.lang.String ENCODING
protected static final QName ATTR_HITS_QNAME
protected static final QName ATTR_START_QNAME
protected static final QName ATTR_COUNT_QNAME
protected static final QName ELEM_RESULT_QNAME
protected static final QName ATTR_TYPE_QNAME
protected static final QName ELEM_VALUE_QNAME
protected DBBroker broker
protected java.lang.String encoding
protected javax.xml.transform.sax.SAXTransformerFactory factory
protected boolean createContainerElements
protected java.util.Properties defaultProperties
protected java.util.Properties outputProperties
protected javax.xml.transform.Templates templates
protected javax.xml.transform.sax.TransformerHandler xslHandler
protected XIncludeFilter xinclude
protected Receiver receiver
protected SAXSerializer xmlout
protected org.xml.sax.ext.LexicalHandler lexicalHandler
protected User user
| Constructor Detail |
public Serializer(DBBroker broker,
Configuration config)
| Method Detail |
public void setProperties(java.util.Properties properties)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setProperties(java.util.Hashtable table)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void setProperty(java.lang.String prop,
java.lang.Object value)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
setProperty in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
public boolean isStylesheetApplied()
protected int getHighlightingMode()
protected void applyXSLHandler(java.io.Writer writer)
public org.xml.sax.EntityResolver getEntityResolver()
getEntityResolver in interface org.xml.sax.XMLReaderpublic org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler in interface org.xml.sax.XMLReaderpublic void setUser(User user)
public User getUser()
public boolean getFeature(java.lang.String name)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
getFeature in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public java.lang.Object getProperty(java.lang.String name)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
getProperty in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
public void parse(org.xml.sax.InputSource input)
throws java.io.IOException,
org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReaderjava.io.IOException
org.xml.sax.SAXExceptionprotected void setDocument(DocumentImpl doc)
public void parse(java.lang.String systemId)
throws java.io.IOException,
org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReaderjava.io.IOException
org.xml.sax.SAXExceptionpublic void reset()
public java.lang.String serialize(DocumentImpl doc)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void serialize(DocumentImpl doc,
java.io.Writer writer)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public java.lang.String serialize(NodeValue n)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public java.lang.String serialize(NodeProxy p)
throws org.xml.sax.SAXException
p - Description of the Parameter
org.xml.sax.SAXException - Description of the Exception
public void setSAXHandlers(org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler)
contentHandler - The new contentHandler valuepublic void setReceiver(Receiver receiver)
public void setContentHandler(org.xml.sax.ContentHandler handler)
setContentHandler in interface org.xml.sax.XMLReaderpublic org.xml.sax.ContentHandler getContentHandler()
getContentHandler in interface org.xml.sax.XMLReaderXMLReader.getContentHandler()public void setEntityResolver(org.xml.sax.EntityResolver resolver)
setEntityResolver in interface org.xml.sax.XMLReaderresolver - The new entityResolver valuepublic void setErrorHandler(org.xml.sax.ErrorHandler handler)
setErrorHandler in interface org.xml.sax.XMLReaderhandler - The new errorHandler value
public void setFeature(java.lang.String name,
boolean value)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
setFeature in interface org.xml.sax.XMLReadername - The new feature valuevalue - The new feature value
org.xml.sax.SAXNotRecognizedException - Description of the Exception
org.xml.sax.SAXNotSupportedException - Description of the Exception
protected void setPrettyPrinter(java.io.Writer writer,
boolean xmlDecl)
protected void releasePrettyPrinter()
protected void setStylesheetFromProperties(org.w3c.dom.Document doc)
protected void checkStylesheetParams()
public void setStylesheet(java.lang.String stylesheet)
public void setStylesheet(DocumentImpl doc,
java.lang.String stylesheet)
public void setStylesheetParam(java.lang.String param,
java.lang.String value)
protected void setXSLHandler()
public void toSAX(DocumentImpl doc)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void toSAX(NodeValue n)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void toSAX(NodeProxy p)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void toSAX(Sequence seq,
int start,
int count,
boolean wrap)
throws org.xml.sax.SAXException
EXIST_NS and has the following form:
<exist:result hits="sequence length" start="value of start" count="value of count">
seq - start - count - wrap -
org.xml.sax.SAXException
public void toReceiver(NodeProxy p)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected abstract void serializeToReceiver(NodeProxy p,
boolean generateDocEvent)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected abstract void serializeToReceiver(DocumentImpl doc,
boolean generateDocEvent)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void serializeToReceiver(NodeValue v,
boolean generateDocEvents)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void serializeToReceiver(NodeImpl n,
boolean generateDocEvents)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void setDTDHandler(org.xml.sax.DTDHandler handler)
setDTDHandler in interface org.xml.sax.XMLReaderXMLReader.setDTDHandler(org.xml.sax.DTDHandler)public org.xml.sax.DTDHandler getDTDHandler()
getDTDHandler in interface org.xml.sax.XMLReaderXMLReader.getDTDHandler()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||