public class CommentHandler extends Object implements LexicalHandler
Modifier and Type | Field and Description |
---|---|
static String |
CLOSE_TAG_COMMENT
A constant marking a comment on the closing tag.
|
static String |
OPEN_TAG_COMMENT
A constant marking a comment on the opening tag.
|
Constructor and Description |
---|
CommentHandler()
DefaultConstructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearComments()
Clears all comments.
|
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document.
|
void |
endCDATA()
Report the end of a CDATA section.
|
void |
endDTD()
Report the end of DTD declarations.
|
void |
endEntity(String name)
Report the end of an entity.
|
String[] |
getComments()
Returns all collected comments as string array.
|
void |
startCDATA()
Report the start of a CDATA section.
|
void |
startDTD(String name,
String publicId,
String systemId)
Report the start of DTD declarations, if any.
|
void |
startEntity(String name)
Report the beginning of some internal and external XML entities.
|
public static final String OPEN_TAG_COMMENT
public static final String CLOSE_TAG_COMMENT
public void startDTD(String name, String publicId, String systemId) throws SAXException
This method is empty.
startDTD
in interface LexicalHandler
name
- The document type name.publicId
- The declared public identifier for the external DTD subset, or null if none was declared.systemId
- The declared system identifier for the external DTD subset, or null if none was declared.SAXException
- The application may raise an exception.endDTD()
,
startEntity(String)
public void endDTD() throws SAXException
This method is empty.
endDTD
in interface LexicalHandler
SAXException
- The application may raise an exception.public void startEntity(String name) throws SAXException
This method is empty.
startEntity
in interface LexicalHandler
name
- The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the
external DTD subset, it will be "[dtd]".SAXException
- The application may raise an exception.endEntity(String)
,
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)
,
DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
public void endEntity(String name) throws SAXException
This method is empty.
endEntity
in interface LexicalHandler
name
- The name of the entity that is ending.SAXException
- The application may raise an exception.startEntity(String)
public void startCDATA() throws SAXException
This method is empty.
startCDATA
in interface LexicalHandler
SAXException
- The application may raise an exception.endCDATA()
public void endCDATA() throws SAXException
This method is empty.
endCDATA
in interface LexicalHandler
SAXException
- The application may raise an exception.startCDATA()
public void comment(char[] ch, int start, int length) throws SAXException
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).
comment
in interface LexicalHandler
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.SAXException
- The application may raise an exception.public String[] getComments()
public void clearComments()