Package org.ametys.cms.content
Class RichTextHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.ametys.cms.content.RichTextHandler
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class RichTextHandler extends DefaultHandler
This handle parse a rich text to get only text nodes. HTML expert is ignored. CallgetValue()
to get parse string.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String[]
__IGNORED_ELEMENTS
List of elements to be ignored during the body text retrieval processingprivate static String
__SEPARATOR
private StringBuilder
_bodyText
private int
_excerptLength
private boolean
_ignoreElmt
private boolean
_newElmt
-
Constructor Summary
Constructors Constructor Description RichTextHandler()
Creates a rich text handlerRichTextHandler(int excerptLength)
Creates a rich text handler to parse a rich text with a limit a characters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
void
endElement(String uri, String localName, String qName)
String
getValue()
Gets the value of the parsed datavoid
startElement(String uri, String localName, String qName, Attributes attributes)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
__IGNORED_ELEMENTS
protected static final String[] __IGNORED_ELEMENTS
List of elements to be ignored during the body text retrieval processing
-
__SEPARATOR
private static final String __SEPARATOR
- See Also:
- Constant Field Values
-
_bodyText
private StringBuilder _bodyText
-
_ignoreElmt
private boolean _ignoreElmt
-
_newElmt
private boolean _newElmt
-
_excerptLength
private int _excerptLength
-
-
Constructor Detail
-
RichTextHandler
public RichTextHandler()
Creates a rich text handler
-
RichTextHandler
public RichTextHandler(int excerptLength)
Creates a rich text handler to parse a rich text with a limit a characters- Parameters:
excerptLength
- The length for content excerpt
-
-
Method Detail
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
-