|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.thirdparty.streamhtmlparser.util.EntityResolver
public class EntityResolver
Decodes (unescapes) HTML entities with the complication that these are received one character at a time hence must be stored temporarily. Also, we may receive some "junk" characters before the actual entity which we will discard.
This class is designed to be 100% compatible with the corresponding
logic in the C-version of the
com.google.security.streamhtmlparser.HtmlParser, found
in htmlparser.c. There are however a few intentional
differences outlines below:
processChar
returns the output String whereas in Java, we return
a status code and then provide the String in a separate
method getEntity. It is cleaner as it avoids the
need to return empty Strings during incomplete processing.
Valid HTML entities have one of the following three forms:
ⅆ where dd is a number in decimal (base 10) form.
&x|Xyy; where yy is a hex-number (base 16).
&<html-entity>; where
<html-entity> is one of lt,
gt, amp, quot or
apos.
A reset method is provided to facilitate object re-use.
| Nested Class Summary | |
|---|---|
static class |
EntityResolver.Status
Returned in processChar method. |
| Constructor Summary | |
|---|---|
EntityResolver()
Constructs an entity resolver that is initially empty and with status NOT_STARTED, see EntityResolver.Status. |
|
EntityResolver(EntityResolver aEntityResolver)
Constructs an entity resolver that is an exact copy of the one provided. |
|
| Method Summary | |
|---|---|
java.lang.String |
getEntity()
Returns the decoded HTML Entity. |
EntityResolver.Status |
processChar(char input)
Processes a character from the input stream and decodes any html entities from that processed input stream. |
void |
reset()
Returns the object to its original state for re-use, deleting any stored characters that may be present. |
java.lang.String |
toString()
Returns the full state of the StreamEntityResolver
in a human readable form. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public EntityResolver()
NOT_STARTED, see EntityResolver.Status.
public EntityResolver(EntityResolver aEntityResolver)
aEntityResolver - the entity resolver to copy| Method Detail |
|---|
public void reset()
public java.lang.String toString()
StreamEntityResolver
in a human readable form. The format of the returned String
is not specified and is subject to change.
toString in class java.lang.Objectpublic java.lang.String getEntity()
processChar returned status COMPLETED.
String if
we were called with any status other than COMPLETEDpublic EntityResolver.Status processChar(char input)
input - the char to process
String. Typically returns an empty
String while awaiting for more characters to complete
processing of the entity.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||