|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.commons.xml.Exporter
public abstract class Exporter
Abstract base class for document and system view exporters. This class takes care of all the details related to namespace mappings, shareable nodes, recursive exports, binary values, and so on while leaving the decisions about what kind of SAX events to generate to subclasses.
A subclass should only need to implement the abstract methods of this class to produce a fully functional exporter.
Field Summary | |
---|---|
protected NamespaceHelper |
helper
Namespace helper. |
Constructor Summary | |
---|---|
protected |
Exporter(Session session,
ContentHandler handler,
boolean recurse,
boolean binary)
Creates an exporter instance. |
Method Summary | |
---|---|
protected void |
addAttribute(String uri,
String local,
String value)
Adds the given attribute to be included in the next element. |
protected String |
addNamespace(String hint,
String uri)
Adds the given namespace to the export. |
protected void |
characters(char[] ch,
int start,
int length)
Emits a characters event with the given character content. |
protected void |
endElement(String uri,
String local)
Emits the end element event for an element with the given name. |
void |
export(Node node)
Exports the given node by preparing the export and calling the abstract exportNode(String, String, Node) method to give
control of the export format to a subclass. |
protected abstract void |
exportNode(String uri,
String local,
Node node)
Called to export the given node. |
protected void |
exportNodes(Node node)
Called by exportNode(String, String, Node) to recursively
call exportNode(String, String, Node) for each child node. |
protected void |
exportProperties(Node node)
Processes all properties of the given node by calling the abstract exportProperty(String, String, Value) and
exportProperty(String, String, int, Value[]) methods for
each property depending on whether the property is single- or
multivalued. |
protected abstract void |
exportProperty(String uri,
String local,
int type,
Value[] values)
Called by #processProperties(Node) to process a multivalued
property. |
protected abstract void |
exportProperty(String uri,
String local,
Value value)
Called by #processProperties(Node) to process a single-valued
property. |
protected String |
getXMLName(String uri,
String local)
Returns a prefixed XML name for the given namespace URI and local name. |
protected void |
startElement(String uri,
String local)
Emits the start element event for an element with the given name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final NamespaceHelper helper
Constructor Detail |
---|
protected Exporter(Session session, ContentHandler handler, boolean recurse, boolean binary)
session
- current sessionhandler
- SAX event handlerrecurse
- whether the export should be recursivebinary
- whether the export should include binary valuesMethod Detail |
---|
public void export(Node node) throws RepositoryException, SAXException
exportNode(String, String, Node)
method to give
control of the export format to a subclass.
This method should be called only once for an exporter instance.
node
- node to be exported
SAXException
- if a SAX error occurs
RepositoryException
- if a repository error occursprotected abstract void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException
jcr:root
if the node is the root node) is given as an explicit pair of the
resolved namespace URI and local part of the name.
The implementation of this method should call the methods
exportProperties(Node)
and exportProperties(Node)
to respectively export the properties and child nodes of the given node.
Those methods will call back to the implementations of this method and
the abstract property export methods so the subclass can decide what
SAX events to emit for each exported item.
uri
- node namespacelocal
- node namenode
- node
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected abstract void exportProperty(String uri, String local, Value value) throws RepositoryException, SAXException
#processProperties(Node)
to process a single-valued
property.
uri
- property namespacelocal
- property namevalue
- property value
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected abstract void exportProperty(String uri, String local, int type, Value[] values) throws RepositoryException, SAXException
#processProperties(Node)
to process a multivalued
property.
uri
- property namespacelocal
- property nametype
- property typevalue
- property values
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected void exportNodes(Node node) throws RepositoryException, SAXException
exportNode(String, String, Node)
to recursively
call exportNode(String, String, Node)
for each child node.
Does nothing if this exporter is not recursive.
node
- parent node
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected void exportProperties(Node node) throws RepositoryException, SAXException
exportProperty(String, String, Value)
and
exportProperty(String, String, int, Value[])
methods for
each property depending on whether the property is single- or
multivalued.
The first properties to be processed are jcr:primaryType
,
jcr:mixinTypes
, and jcr:uuid
, and then the
remaining properties ordered by their names.
If the node is a shareable node that has already been encountered by
this event generator, then only a jcr:primaryType
property
with the fixed value "nt:share" and the jcr:uuid
property
of the shareable node are exported.
node
- node
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occurshttps://issues.apache.org/jira/browse/JCR-1084
protected void characters(char[] ch, int start, int length) throws SAXException
ch
- character arraystart
- start offset within the arraylength
- number of characters to emit
SAXException
- if a SAX error occursprotected void addAttribute(String uri, String local, String value) throws RepositoryException
uri
- namespace URI of the attributelocal
- local name of the attributevalue
- attribute value
RepositoryException
- if a repository error occursprotected void startElement(String uri, String local) throws SAXException, RepositoryException
addAttribute(String, String, String)
are included in the
element along with any new namespace mappings. The namespace stack
is extended for potential child elements.
uri
- namespace URI or the elementlocal
- local name of the element
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected void endElement(String uri, String local) throws SAXException, RepositoryException
uri
- namespace URI or the elementlocal
- local name of the element
RepositoryException
- if a repository error occurs
SAXException
- if a SAX error occursprotected String getXMLName(String uri, String local) throws RepositoryException
uri
- namespace URIlocal
- local name
RepositoryException
- if a JCR namespace mapping is not availableprotected String addNamespace(String hint, String uri)
hint
- prefix hinturi
- namespace URI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |