|
|||||||||
| Home >> All >> com >> port80 >> eclipse >> xml >> [ editors overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.port80.eclipse.xml.editors
Class XMLFormatter.XMLContentHandler

java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.port80.eclipse.xml.editors.XMLFormatter.XMLContentHandler
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, XMLFormatter.CustomHandler
- Enclosing class:
- XMLFormatter
- static class XMLFormatter.XMLContentHandler
- extends org.xml.sax.helpers.DefaultHandler
- implements org.xml.sax.ext.LexicalHandler, org.xml.sax.ext.DeclHandler, XMLFormatter.CustomHandler
- extends org.xml.sax.helpers.DefaultHandler
An XMLContentHanlder that format XML source while parsing.
| Field Summary | |
(package private) int |
fColumn
|
(package private) XMLEditorConfiguration |
fConfig
|
(package private) int |
fLine
|
(package private) java.lang.String |
fLineSep
|
(package private) int |
fLineWidth
|
(package private) org.xml.sax.Locator |
fLocator
|
(package private) java.lang.StringBuffer |
fResult
|
(package private) java.lang.String |
fTab
|
(package private) int |
fTabWidth
|
(package private) java.util.Stack |
fTagStack
|
(package private) java.lang.StringBuffer |
fText
|
(package private) org.eclipse.jface.text.source.ISourceViewer |
fViewer
|
(package private) boolean |
hasInternalDTD
|
(package private) boolean |
isCData
Flag to ignore SAX ContentHandler calls when content is handled by LexicalHandler (eg. |
(package private) boolean |
isCompact
|
(package private) boolean |
isEmpty
|
(package private) boolean |
isIgnore
Flag to ignore SAX ContentHandler calls when content is handled by LexicalHandler (eg. |
(package private) boolean |
isNewLine
|
(package private) boolean |
isPreserveSpace
|
| Constructor Summary | |
XMLFormatter.XMLContentHandler(java.lang.StringBuffer ret,
java.lang.String linesep,
boolean compact,
XMLEditorConfiguration cf,
org.eclipse.jface.text.source.ISourceViewer viewer)
|
|
| Method Summary | |
void |
attributeDecl(java.lang.String eName,
java.lang.String aName,
java.lang.String type,
java.lang.String valueDefault,
java.lang.String value)
Report an attribute type declaration. |
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data inside an element. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
void |
elementDecl(java.lang.String name,
java.lang.String model)
Report an element type declaration. |
private void |
emitComment()
|
private void |
emitEndElement(java.lang.String namespaceURI,
java.lang.String localName,
XMLFormatter.Element element)
|
private void |
emitIndent()
|
private void |
emitIndent(int delta)
|
private void |
emitMultiLineElement(XMLFormatter.Element element,
int delta)
|
private void |
emitPI(java.lang.String target,
java.lang.String data)
|
private void |
emitSingleLineElement(XMLFormatter.Element element,
int delta)
|
private int |
emitStartTag(XMLFormatter.Element element,
int delta)
|
private void |
emitText()
|
private void |
emitText(boolean linebreak,
boolean preserve,
int delta)
Wrap given text to the given linewidth. |
private void |
emitText(java.lang.StringBuffer text,
int start,
int end,
int delta)
Emit the given range of text with line wrap. |
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
Receive notification of the end of the document. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
Receive notification of the end of an element. |
void |
endEntity(java.lang.String name)
Report the end of an entity. |
void |
externalEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report a parsed external entity declaration. |
private void |
flushDTD()
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
void |
internalEntityDecl(java.lang.String name,
java.lang.String value)
Report an internal entity declaration. |
private void |
peekPreserveSpace()
|
private void |
printBuffer(java.lang.String m,
java.lang.StringBuffer buf)
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
reportError(java.lang.String message,
int line,
int column)
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events. |
void |
skippedEntity(java.lang.String name)
Receive notification of a skipped entity. |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
Receive notification of the beginning of the document. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report the start of DTD declarations, if any. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
Receive notification of the start of an element. |
void |
startEntity(java.lang.String name)
Report the beginning of some internal and external XML entities. |
void |
startInternalDTD(boolean b)
|
private void |
startNewLine()
|
private int |
trimLeadingWhitespace(java.lang.StringBuffer buf)
|
private void |
trimText(java.lang.StringBuffer text)
Trim given StringBuffer such that all leading and trailing whitespaces are eliminated unless there are two or more continuous breaks. |
private boolean |
trimWhitespace(java.lang.StringBuffer buf)
|
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endPrefixMapping, error, fatalError, notationDecl, resolveEntity, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
fConfig
XMLEditorConfiguration fConfig
fViewer
org.eclipse.jface.text.source.ISourceViewer fViewer
fResult
java.lang.StringBuffer fResult
fLineSep
java.lang.String fLineSep
fLocator
org.xml.sax.Locator fLocator
fText
java.lang.StringBuffer fText
fTagStack
java.util.Stack fTagStack
fLineWidth
int fLineWidth
fTabWidth
int fTabWidth
fTab
java.lang.String fTab
isNewLine
boolean isNewLine
isCompact
boolean isCompact
fLine
int fLine
fColumn
int fColumn
isEmpty
boolean isEmpty
isPreserveSpace
boolean isPreserveSpace
hasInternalDTD
boolean hasInternalDTD
isIgnore
boolean isIgnore
- Flag to ignore SAX ContentHandler calls when content is handled by LexicalHandler
(eg. between StartEntity and EndEntity).
isCData
boolean isCData
- Flag to ignore SAX ContentHandler calls when content is handled by LexicalHandler
(eg. between StartEntity and EndEntity).
| Constructor Detail |
XMLFormatter.XMLContentHandler
public XMLFormatter.XMLContentHandler(java.lang.StringBuffer ret, java.lang.String linesep, boolean compact, XMLEditorConfiguration cf, org.eclipse.jface.text.source.ISourceViewer viewer)
| Method Detail |
reportError
public void reportError(java.lang.String message, int line, int column)
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive a Locator object for document events.
By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler
startDocument
public void startDocument()
throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the beginning of the document.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).
- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler
endDocument
public void endDocument()
throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the end of the document.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).
- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler
startElement
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the start of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of the end of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler
characters
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of character data inside an element.
By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler
ignorableWhitespace
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of ignorable whitespace in element content.
By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).
- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of a processing instruction.
By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
- Description copied from class:
org.xml.sax.helpers.DefaultHandler - Receive notification of a skipped entity.
By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler
comment
public void comment(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report an XML comment anywhere in the document.
This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read). Comments in the DTD must be properly nested inside start/endDTD and start/endEntity events (if used).
- Specified by:
commentin interfaceorg.xml.sax.ext.LexicalHandler
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the start of DTD declarations, if any.
This method is intended to report the beginning of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.
All declarations reported through DTDHandler or DeclHandler events must appear between the startDTD and endDTD 55 events. Declarations are assumed to belong to the internal DTD subset unless they appear between startEntity 55 and endEntity 55 events. Comments and processing instructions from the DTD should also be reported between the startDTD and endDTD events, in their original order of (logical) occurrence; they are not required to appear in their correct locations relative to DTDHandler or DeclHandler events, however.
Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement 55 event.
- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler
endDTD
public void endDTD()
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the end of DTD declarations.
This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.
- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the beginning of some internal and external XML entities.
The reporting of parameter entities (including the external DTD subset) is optional, and SAX2 drivers that report LexicalHandler events may not implement it; you can use the
http://xml.org/sax/features/lexical-handler/parameter-entitiesfeature to query or control the reporting of parameter entities.General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".
When a SAX2 driver is providing these events, all other events must be properly nested within start/end entity events. There is no additional requirement that events from DeclHandler or DTDHandler be properly ordered.
Note that skipped entities will be reported through the skippedEntity 55 event, which is part of the ContentHandler interface.
Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:
- general entities within attribute values
- parameter entities within declarations
These will be silently expanded, with no indication of where the original entity boundaries were.
Note also that the boundaries of character references (which are not really entities anyway) are not reported.
All start/endEntity events must be properly nested.
- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the end of an entity.
- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler
startCDATA
public void startCDATA()
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the start of a CDATA section.
The contents of the CDATA section will be reported through the regular characters 55 event; this event is intended only to report the boundary.
- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler
endCDATA
public void endCDATA()
throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.LexicalHandler - Report the end of a CDATA section.
- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler
attributeDecl
public void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.DeclHandler - Report an attribute type declaration.
Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group with the separator "|" and all whitespace removed, or the word "NOTATION" followed by a space followed by a parenthesized token group with all whitespace removed.
The value will be the value as reported to applications, appropriately normalized and with entity and character references expanded.
- Specified by:
attributeDeclin interfaceorg.xml.sax.ext.DeclHandler
elementDecl
public void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.DeclHandler - Report an element type declaration.
The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all parameter entities are fully resolved and all whitespace is removed,and will include the enclosing parentheses. Other normalization (such as removing redundant parentheses or simplifying occurrence indicators) is at the discretion of the parser.
- Specified by:
elementDeclin interfaceorg.xml.sax.ext.DeclHandler
externalEntityDecl
public void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.DeclHandler - Report a parsed external entity declaration.
Only the effective (first) declaration for each entity will be reported.
If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
- Specified by:
externalEntityDeclin interfaceorg.xml.sax.ext.DeclHandler
internalEntityDecl
public void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ext.DeclHandler - Report an internal entity declaration.
Only the effective (first) declaration for each entity will be reported. All parameter entities in the value will be expanded, but general entities will not.
- Specified by:
internalEntityDeclin interfaceorg.xml.sax.ext.DeclHandler
startInternalDTD
public void startInternalDTD(boolean b)
- Specified by:
startInternalDTDin interfaceXMLFormatter.CustomHandler
startNewLine
private void startNewLine()
emitIndent
private void emitIndent()
emitIndent
private void emitIndent(int delta)
flushDTD
private void flushDTD()
emitText
private void emitText()
emitText
private void emitText(boolean linebreak,
boolean preserve,
int delta)
- Wrap given text to the given linewidth. Embedded line break in the text are treated as paragraph
break and would becomes a blank line.
NOTE: XML parser always return 0x0a as line separator
emitText
private void emitText(java.lang.StringBuffer text, int start, int end, int delta)
- Emit the given range of text with line wrap.
emitComment
private void emitComment()
emitStartTag
private int emitStartTag(XMLFormatter.Element element, int delta)
emitSingleLineElement
private void emitSingleLineElement(XMLFormatter.Element element, int delta)
emitMultiLineElement
private void emitMultiLineElement(XMLFormatter.Element element, int delta)
emitEndElement
private void emitEndElement(java.lang.String namespaceURI, java.lang.String localName, XMLFormatter.Element element)
emitPI
private void emitPI(java.lang.String target, java.lang.String data)
trimLeadingWhitespace
private int trimLeadingWhitespace(java.lang.StringBuffer buf)
trimWhitespace
private boolean trimWhitespace(java.lang.StringBuffer buf)
trimText
private void trimText(java.lang.StringBuffer text)
- Trim given StringBuffer such that all leading and trailing whitespaces are eliminated unless there
are two or more continuous breaks. In that case, a break would stay. Similarly all whitespaces
inside the text are reduced to a single space unless there are multple line breaks. In that case,
one line break would stay. Lines without blank line between them is reduced to one continuous line
(represent a paragraph).
peekPreserveSpace
private void peekPreserveSpace()
printBuffer
private void printBuffer(java.lang.String m, java.lang.StringBuffer buf)
|
|||||||||
| Home >> All >> com >> port80 >> eclipse >> xml >> [ editors overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC