lux.index
Class XmlPathMapper

java.lang.Object
  extended by lux.index.XmlPathMapper
All Implemented Interfaces:
StAXHandler
Direct Known Subclasses:
QNameTextMapper, XPathValueMapper

public class XmlPathMapper
extends Object
implements StAXHandler

Accumulate counts of QNames and QName paths. Each path is a string of path components, separated by single space characters. The first path component is always {}. The others are element QNames of the form local-name{namespace}, where {namespace} is omitted when the namespace is empty. The sequence of element QNames may be followed by a single attribute QName of the form: @local-name{namespace}. Namespaces are encoded using URL-encoding so they will not contain unexpected characters (such as space and {}). TODO: a bunch of optimizations are possible here; there is a duplication of work in the subclasses, unneeded String creation, etc. Come back and fix that once we've settled on a definite implementation!


Field Summary
protected  StringBuilder currentPath
           
protected  QName currentQName
           
 
Constructor Summary
XmlPathMapper()
           
 
Method Summary
protected  String encodeQName(QName qname)
          encode a QName in a suitable form for indexing.
 Map<QName,Integer> getAttQNameCounts()
           
 Map<QName,Integer> getEltQNameCounts()
           
protected  QName getEventAttQName(XMLStreamReader reader, int i)
           
 Map<String,Integer> getPathCounts()
           
 void handleEvent(XMLStreamReader reader, int eventType)
          This method receives StAX events.
 boolean isNamespaceAware()
           
 void reset()
          reinitialize any internal state and prepare the handler for re-use
 void setNamespaceAware(boolean namespaceAware)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentPath

protected StringBuilder currentPath

currentQName

protected QName currentQName
Constructor Detail

XmlPathMapper

public XmlPathMapper()
Method Detail

getEltQNameCounts

public Map<QName,Integer> getEltQNameCounts()

getAttQNameCounts

public Map<QName,Integer> getAttQNameCounts()

getPathCounts

public Map<String,Integer> getPathCounts()

isNamespaceAware

public boolean isNamespaceAware()

setNamespaceAware

public void setNamespaceAware(boolean namespaceAware)

handleEvent

public void handleEvent(XMLStreamReader reader,
                        int eventType)
Description copied from interface: StAXHandler
This method receives StAX events. It should never call XMLStreamReader.next() since if it does, its caller will miss the event.

Specified by:
handleEvent in interface StAXHandler
Parameters:
reader - the reader from which events are being read
eventType - the XML stream event type

getEventAttQName

protected QName getEventAttQName(XMLStreamReader reader,
                                 int i)

encodeQName

protected String encodeQName(QName qname)
encode a QName in a suitable form for indexing. If namespace-aware, the encoding is: local-name{encoded-namespace}. Otherwise, if prefix is non-empty, it's local-name{prefix}, otherwise just local-name.

Parameters:
qname -
Returns:
the encoded qname

reset

public void reset()
Description copied from interface: StAXHandler
reinitialize any internal state and prepare the handler for re-use

Specified by:
reset in interface StAXHandler


Copyright © 2013. All Rights Reserved.