Java Doc for XMLFilter.java in  » Scripting » Kawa » gnu » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » Kawa » gnu.xml 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   gnu.xml.XMLFilter

XMLFilter
public class XMLFilter implements DocumentHandler,ContentHandler,gnu.text.SourceLocator,XConsumer,PositionConsumer(Code)
Fixup XML input events. Handles namespace resolution, and adds "namespace nodes" if needed. Does various error checking. This wrapper should be used when creating a NodeTree, as is done for XQuery node constructor expressions. Can also be called directly from XMLParser, in which case we use a slightly lower-level interface where we array char array segments rather than Strings. This is to avoid duplicate String allocation and interning. The combination XMLParser+XMLFilter+NodeTree makes for a fast and compact way to read an XML file into a DOM.


Field Summary
final public static  intCOPY_NAMESPACES_INHERIT
    
final public static  intCOPY_NAMESPACES_PRESERVE
    
 intattrCount
     The number of attributes. Zero means we've seen an element start tag. Gets reset to -1 when we no longer in the element header.
 StringattrLocalName
     The local name if currently processing an attribute value.
 StringattrPrefix
    
 Consumerbase
    
public transient  intcopyNamespacesMode
    
 StringcurrentNamespacePrefix
     Non-null if we're processing a namespace declaration attribute. In that case it is the prefix we're defining, or "" in the case of a default namespace.
protected  intignoringLevel
     Postive if all output should be ignored. This happens if we're inside an attribute value inside an element which is stringized because it is in turm inside an outer attribute.
 LineBufferedReaderin
    
 booleaninStartTag
    
 SourceLocatorlocator
    
 MappingInfo[]mappingTable
     Map either lexical-QName or expanded-QName to a MappingInfo.
 intmappingTableMask
    
 booleanmismatchReported
    
 NamespaceBindingnamespaceBindings
    
public  booleannamespacePrefixes
     True if namespace declarations should be passed through as attributes. Like SAX2's http://xml.org/features/namespace-prefixes.
protected  intnesting
     Twice the number of active startElement and startDocument calls.
public  Consumerout
     The specified target Consumer that accepts the output. In contrast, base may be either ==out or ==tlist .
 intprevious
    
 int[]startIndexes
    
protected  intstringizingElementNesting
     Value of nesting just before outermost startElement while stringizingLevel > 0 . I.e.
protected  intstringizingLevel
     If stringizingLevel > 0 then stringize rather than copy nodes.
 TreeListtlist
     This is where we save attributes while processing a begin element. It may be the final output if out instanceof NodeTree .
 Object[]workStack
     A helper stack. This is logically multiple separate stacks, but we combine them into a single array.

Constructor Summary
public  XMLFilter(Consumer out)
    

Method Summary
public  voidbeginEntity(Object baseUri)
    
public  voidcharacters(char ch, int start, int length)
    
protected  voidcheckValidComment(char[] chars, int offset, int length)
    
protected  booleancheckWriteAtomic()
    
 voidcloseStartTag()
    
public  voidcommentFromParser(char[] chars, int start, int length)
     Process a comment, when called from an XML parser. The data (starting at start for length chars). Does not include the delimiters (i.e.
public  voidconsume(SeqPosition position)
    
public static  StringduplicateAttributeMessage(Symbol attrSymbol, Object elementName)
    
public  voidemitCharacterReference(int value, char[] name, int start, int length)
     Process a character entity reference. The string encoding of the character (e.g.
public  voidemitDoctypeDecl(char[] buffer, int target, int tlength, int data, int dlength)
     Process a DOCTYPE declaration.
public  voidemitEndAttributes()
     Process the end of a start tag. There are no more attributes.
public  voidemitEndElement(char[] data, int start, int length)
     Process an end tag.
public  voidemitEntityReference(char[] name, int start, int length)
     Process an entity reference.
public  voidemitStartAttribute(char[] data, int start, int count)
     Process an attribute, with the given attribute name.
public  voidemitStartElement(char[] data, int start, int count)
     Process a start tag, with the given element name.
public  voidendAttribute()
    
public  voidendDocument()
    
public  voidendElement()
    
public  voidendElement(String namespaceURI, String localName, String qName)
    
public  voidendElement(String name)
    
public  voidendEntity()
    
public  voidendPrefixMapping(String prefix)
    
public  voiderror(char severity, String message)
    
public  NamespaceBindingfindNamespaceBinding(String prefix, String uri, NamespaceBinding oldBindings)
     Functionally equivalent to new NamespaceBinding(prefix, uri, oldBindings , but uses "hash consing".
public  intgetColumnNumber()
    
public  StringgetFileName()
    
public  intgetLineNumber()
    
public  StringgetPublicId()
    
public  StringgetSystemId()
    
public  voidignorableWhitespace(char ch, int start, int length)
    
public  booleanignoring()
    
final  booleaninElement()
    
public  booleanisStableSourceLocation()
    
public  voidlinefeedFromParser()
    
public  MappingInfolookupNamespaceBinding(String prefix, char[] uriChars, int uriStart, int uriLength, int uriHash, NamespaceBinding oldBindings)
     Return a MappingInfo containing a match namespaces.
 MappingInfolookupTag(Symbol qname)
    
 MappingInfolookupTag(char[] data, int start, int length)
     Look up an attribute/element tag (a QName as a lexical string before namespace resolution), and return a MappingInfo with the tagHash, prefix, and local fields set. The trick is to avoid allocating a new String for each element or attribute node we see, but only allocate a new String when we see a tag we haven't seen.
public  voidprocessingInstruction(String target, String data)
    
 voidprocessingInstructionCommon(String target, char[] content, int offset, int length)
    
public  voidprocessingInstructionFromParser(char[] buffer, int tstart, int tlength, int dstart, int dlength)
     Process a processing instruction.
public  voidsetDocumentLocator(Locator locator)
    
public  voidsetMessages(SourceMessages messages)
    
public  voidsetSourceLocator(LineBufferedReader in)
    
public  voidsetSourceLocator(SourceLocator locator)
    
public  voidskippedEntity(String name)
    
public  voidstartAttribute(Object attrType)
    
public  voidstartDocument()
    
public  voidstartElement(Object type)
    
public  voidstartElement(String namespaceURI, String localName, String qName, Attributes atts)
    
public  voidstartElement(String name, AttributeList atts)
    
protected  voidstartElementCommon()
    
public  voidstartPrefixMapping(String prefix, String uri)
    
public  voidtextFromParser(char[] data, int start, int length)
    
public  voidwrite(int v)
    
public  voidwrite(char[] data, int start, int length)
     Process raw text.
public  voidwrite(String str)
    
public  voidwrite(CharSequence str, int start, int length)
    
public  voidwriteBoolean(boolean v)
    
public  voidwriteCDATA(char[] data, int start, int length)
     Process a CDATA section. The data (starting at start for length char). Does not include the delimiters (i.e.
public  voidwriteComment(char[] chars, int start, int length)
     Process a comment. The data (starting at start for length chars). Does not include the delimiters (i.e.
public  voidwriteDocumentUri(Object uri)
    
public  voidwriteDouble(double v)
    
public  voidwriteFloat(float v)
    
public  voidwriteInt(int v)
    
protected  voidwriteJoiner()
    
public  voidwriteLong(long v)
    
public  voidwriteObject(Object v)
     If v is a node, make a copy of it.
public  voidwritePosition(AbstractSequence seq, int ipos)
    
public  voidwriteProcessingInstruction(String target, char[] content, int offset, int length)
    

Field Detail
COPY_NAMESPACES_INHERIT
final public static int COPY_NAMESPACES_INHERIT(Code)



COPY_NAMESPACES_PRESERVE
final public static int COPY_NAMESPACES_PRESERVE(Code)



attrCount
int attrCount(Code)
The number of attributes. Zero means we've seen an element start tag. Gets reset to -1 when we no longer in the element header.



attrLocalName
String attrLocalName(Code)
The local name if currently processing an attribute value.



attrPrefix
String attrPrefix(Code)



base
Consumer base(Code)



copyNamespacesMode
public transient int copyNamespacesMode(Code)



currentNamespacePrefix
String currentNamespacePrefix(Code)
Non-null if we're processing a namespace declaration attribute. In that case it is the prefix we're defining, or "" in the case of a default namespace.



ignoringLevel
protected int ignoringLevel(Code)
Postive if all output should be ignored. This happens if we're inside an attribute value inside an element which is stringized because it is in turm inside an outer attribute. Phew. If gets increment by nested attributes so we can tell when to stop.



in
LineBufferedReader in(Code)



inStartTag
boolean inStartTag(Code)



locator
SourceLocator locator(Code)



mappingTable
MappingInfo[] mappingTable(Code)
Map either lexical-QName or expanded-QName to a MappingInfo. This is conceptually three hash tables merged into a single data structure. (1) when we first see a tag (a QName as a lexical form before namespace resolution), we map the tag String to an preliminary info entry that has a null qname field. (2) After see the namespace declaration, we use the same table and keys, but name the uri and qtype.namespaceNodes also have to match. (3) Used for hash-consing NamespaceBindings.



mappingTableMask
int mappingTableMask(Code)



mismatchReported
boolean mismatchReported(Code)



namespaceBindings
NamespaceBinding namespaceBindings(Code)



namespacePrefixes
public boolean namespacePrefixes(Code)
True if namespace declarations should be passed through as attributes. Like SAX2's http://xml.org/features/namespace-prefixes.



nesting
protected int nesting(Code)
Twice the number of active startElement and startDocument calls.



out
public Consumer out(Code)
The specified target Consumer that accepts the output. In contrast, base may be either ==out or ==tlist .



previous
int previous(Code)



startIndexes
int[] startIndexes(Code)



stringizingElementNesting
protected int stringizingElementNesting(Code)
Value of nesting just before outermost startElement while stringizingLevel > 0 . I.e. if we're nested inside a element nested inside an attribute then stringizingElementNesting >= 0 , otherwise stringizingElementNesting == -1 .



stringizingLevel
protected int stringizingLevel(Code)
If stringizingLevel > 0 then stringize rather than copy nodes. It counts the number of nested startAttributes that are active. (In the future it should also count begun comment and processing-instruction constructors, when those support nesting.)



tlist
TreeList tlist(Code)
This is where we save attributes while processing a begin element. It may be the final output if out instanceof NodeTree .



workStack
Object[] workStack(Code)
A helper stack. This is logically multiple separate stacks, but we combine them into a single array. While this makes the code a little harder to read, it reduces memory overhead and (more importantly) should improve locality. For each nested document or element there is the saved value of namespaceBindings followed by a either a MappingInfo or Symbol from the emitBeginElement/startElement. This is followed by a MappingInfo or Symbol for each attribute we seen for the current element.




Constructor Detail
XMLFilter
public XMLFilter(Consumer out)(Code)




Method Detail
beginEntity
public void beginEntity(Object baseUri)(Code)



characters
public void characters(char ch, int start, int length) throws SAXException(Code)



checkValidComment
protected void checkValidComment(char[] chars, int offset, int length)(Code)



checkWriteAtomic
protected boolean checkWriteAtomic()(Code)



closeStartTag
void closeStartTag()(Code)



commentFromParser
public void commentFromParser(char[] chars, int start, int length)(Code)
Process a comment, when called from an XML parser. The data (starting at start for length chars). Does not include the delimiters (i.e. "" are excluded).



consume
public void consume(SeqPosition position)(Code)



duplicateAttributeMessage
public static String duplicateAttributeMessage(Symbol attrSymbol, Object elementName)(Code)



emitCharacterReference
public void emitCharacterReference(int value, char[] name, int start, int length)(Code)
Process a character entity reference. The string encoding of the character (e.g. "xFF" or "255") is given, as well as the character value.



emitDoctypeDecl
public void emitDoctypeDecl(char[] buffer, int target, int tlength, int data, int dlength)(Code)
Process a DOCTYPE declaration.



emitEndAttributes
public void emitEndAttributes()(Code)
Process the end of a start tag. There are no more attributes.



emitEndElement
public void emitEndElement(char[] data, int start, int length)(Code)
Process an end tag. An abbreviated tag (such as '
' ) has a name==null.



emitEntityReference
public void emitEntityReference(char[] name, int start, int length)(Code)
Process an entity reference. The entity name is given. This handles the predefined entities, such as "<" and """.



emitStartAttribute
public void emitStartAttribute(char[] data, int start, int count)(Code)
Process an attribute, with the given attribute name. The attribute value is given using write . The value is terminated by either another emitStartAttribute or an emitEndAttributes.



emitStartElement
public void emitStartElement(char[] data, int start, int count)(Code)
Process a start tag, with the given element name.



endAttribute
public void endAttribute()(Code)



endDocument
public void endDocument()(Code)



endElement
public void endElement()(Code)



endElement
public void endElement(String namespaceURI, String localName, String qName)(Code)



endElement
public void endElement(String name) throws SAXException(Code)



endEntity
public void endEntity()(Code)



endPrefixMapping
public void endPrefixMapping(String prefix)(Code)



error
public void error(char severity, String message)(Code)



findNamespaceBinding
public NamespaceBinding findNamespaceBinding(String prefix, String uri, NamespaceBinding oldBindings)(Code)
Functionally equivalent to new NamespaceBinding(prefix, uri, oldBindings , but uses "hash consing".



getColumnNumber
public int getColumnNumber()(Code)



getFileName
public String getFileName()(Code)



getLineNumber
public int getLineNumber()(Code)



getPublicId
public String getPublicId()(Code)



getSystemId
public String getSystemId()(Code)



ignorableWhitespace
public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)



ignoring
public boolean ignoring()(Code)



inElement
final boolean inElement()(Code)



isStableSourceLocation
public boolean isStableSourceLocation()(Code)



linefeedFromParser
public void linefeedFromParser()(Code)



lookupNamespaceBinding
public MappingInfo lookupNamespaceBinding(String prefix, char[] uriChars, int uriStart, int uriLength, int uriHash, NamespaceBinding oldBindings)(Code)
Return a MappingInfo containing a match namespaces. Specifically, return a MappingInfo info is such that info.namespaces is equal to new NamespaceBinding(prefix, uri, oldBindings) , where uri is new String(uriChars, uriStart, uriLength).intern()) .



lookupTag
MappingInfo lookupTag(Symbol qname)(Code)



lookupTag
MappingInfo lookupTag(char[] data, int start, int length)(Code)
Look up an attribute/element tag (a QName as a lexical string before namespace resolution), and return a MappingInfo with the tagHash, prefix, and local fields set. The trick is to avoid allocating a new String for each element or attribute node we see, but only allocate a new String when we see a tag we haven't seen. So we calculate the hash code using the characters in the array, rather than using String's hashCode.



processingInstruction
public void processingInstruction(String target, String data)(Code)



processingInstructionCommon
void processingInstructionCommon(String target, char[] content, int offset, int length)(Code)



processingInstructionFromParser
public void processingInstructionFromParser(char[] buffer, int tstart, int tlength, int dstart, int dlength)(Code)
Process a processing instruction.



setDocumentLocator
public void setDocumentLocator(Locator locator)(Code)



setMessages
public void setMessages(SourceMessages messages)(Code)



setSourceLocator
public void setSourceLocator(LineBufferedReader in)(Code)



setSourceLocator
public void setSourceLocator(SourceLocator locator)(Code)



skippedEntity
public void skippedEntity(String name)(Code)



startAttribute
public void startAttribute(Object attrType)(Code)



startDocument
public void startDocument()(Code)



startElement
public void startElement(Object type)(Code)



startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)(Code)



startElement
public void startElement(String name, AttributeList atts)(Code)



startElementCommon
protected void startElementCommon()(Code)



startPrefixMapping
public void startPrefixMapping(String prefix, String uri)(Code)



textFromParser
public void textFromParser(char[] data, int start, int length)(Code)



write
public void write(int v)(Code)



write
public void write(char[] data, int start, int length)(Code)
Process raw text.



write
public void write(String str)(Code)



write
public void write(CharSequence str, int start, int length)(Code)



writeBoolean
public void writeBoolean(boolean v)(Code)



writeCDATA
public void writeCDATA(char[] data, int start, int length)(Code)
Process a CDATA section. The data (starting at start for length char). Does not include the delimiters (i.e. "" are excluded).



writeComment
public void writeComment(char[] chars, int start, int length)(Code)
Process a comment. The data (starting at start for length chars). Does not include the delimiters (i.e. "" are excluded).



writeDocumentUri
public void writeDocumentUri(Object uri)(Code)



writeDouble
public void writeDouble(double v)(Code)



writeFloat
public void writeFloat(float v)(Code)



writeInt
public void writeInt(int v)(Code)



writeJoiner
protected void writeJoiner()(Code)



writeLong
public void writeLong(long v)(Code)



writeObject
public void writeObject(Object v)(Code)
If v is a node, make a copy of it.



writePosition
public void writePosition(AbstractSequence seq, int ipos)(Code)



writeProcessingInstruction
public void writeProcessingInstruction(String target, char[] content, int offset, int length)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.