Package uk.ac.starlink.ttools.copy
Class SquashAttributeHandler
java.lang.Object
uk.ac.starlink.ttools.copy.SquashAttributeHandler
- All Implemented Interfaces:
ContentHandler,LexicalHandler
SAX content handler which mostly copies events to text,
but eliminates a given attribute from the root element.
- Since:
- 19 Nov 2012
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionSquashAttributeHandler(Writer out, String attName, boolean removeEmptyElement) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidcomment(char[] ch, int start, int length) voidendCDATA()voidvoidendDTD()voidendElement(String namespaceURI, String localName, String qName) voidvoidendPrefixMapping(String prefix) voidflush()Ensures that any pending output has been written.voidignorableWhitespace(char[] ch, int start, int length) voidWrites a string raw.voidprocessingInstruction(String target, String data) voidsetDocumentLocator(Locator locator) voidSets the destination stream.voidskippedEntity(String name) voidvoidvoidvoidstartElement(String namespaceURI, String localName, String qName, Attributes atts) voidstartEntity(String name) voidstartPrefixMapping(String prefix, String uri) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
SquashAttributeHandler
Constructor.- Parameters:
out- output stream; SAX events are copied as XML text to hereattName- name of attribute on level-0 element to removeremoveEmptyElement- if true, then if removing the named attribute from the level-0 element results in an element with no interesting content and no other attributes, the element itself is removed from the output
-
-
Method Details
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElementin interfaceContentHandler- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Throws:
SAXException
-
comment
- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
setOutput
Sets the destination stream. This method must be called before the handler is used.- Parameters:
out- output stream
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler
-
startDTD
- Specified by:
startDTDin interfaceLexicalHandler
-
endDTD
public void endDTD()- Specified by:
endDTDin interfaceLexicalHandler
-
startEntity
- Specified by:
startEntityin interfaceLexicalHandler
-
endEntity
- Specified by:
endEntityin interfaceLexicalHandler
-
flush
Ensures that any pending output has been written. If other classes wish to write directly to this writer's destination stream, they must call this method first.- Throws:
SAXException
-
out
Writes a string raw.- Parameters:
text- string to write- Throws:
SAXException
-