public abstract class Exporter extends Object
A subclass should only need to implement the abstract methods of this class to produce a fully functional exporter.
Modifier and Type | Field and Description |
---|---|
protected NamespaceHelper |
helper
Namespace helper.
|
Modifier | Constructor and Description |
---|---|
protected |
Exporter(Session session,
ContentHandler handler,
boolean recurse,
boolean binary)
Creates an exporter instance.
|
Modifier and Type | Method and Description |
---|---|
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
exportProperties(Node) to process a multivalued
property. |
protected abstract void |
exportProperty(String uri,
String local,
Value value)
Called by
exportProperties(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.
|
protected final NamespaceHelper helper
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 valuespublic 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 exportedSAXException
- if a SAX error occursRepositoryException
- 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
- nodeRepositoryException
- if a repository error occursSAXException
- if a SAX error occursprotected abstract void exportProperty(String uri, String local, Value value) throws RepositoryException, SAXException
exportProperties(Node)
to process a single-valued
property.uri
- property namespacelocal
- property namevalue
- property valueRepositoryException
- if a repository error occursSAXException
- if a SAX error occursprotected abstract void exportProperty(String uri, String local, int type, Value[] values) throws RepositoryException, SAXException
exportProperties(Node)
to process a multivalued
property.uri
- property namespacelocal
- property nametype
- property typevalues
- property valuesRepositoryException
- if a repository error occursSAXException
- 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 nodeRepositoryException
- if a repository error occursSAXException
- 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
- nodeRepositoryException
- if a repository error occursSAXException
- if a SAX error occursprotected void characters(char[] ch, int start, int length) throws SAXException
ch
- character arraystart
- start offset within the arraylength
- number of characters to emitSAXException
- 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 valueRepositoryException
- 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 elementRepositoryException
- if a repository error occursSAXException
- if a SAX error occursprotected void endElement(String uri, String local) throws SAXException, RepositoryException
uri
- namespace URI or the elementlocal
- local name of the elementRepositoryException
- if a repository error occursSAXException
- if a SAX error occursprotected String getXMLName(String uri, String local) throws RepositoryException
uri
- namespace URIlocal
- local nameRepositoryException
- if a JCR namespace mapping is not availableprotected String addNamespace(String hint, String uri)
hint
- prefix hinturi
- namespace URICopyright © 2004–2022 The Apache Software Foundation. All rights reserved.