java.lang.Objectjavax.swing.text.html.parser.Parser
public class Parser
A simple DTD-driven HTML parser. The parser reads an HTML file from an InputStream and calls various methods (which should be overridden in a subclass) when tags and data are encountered.
Unfortunately there are many badly implemented HTML parsers out there, and as a result there are many badly formatted HTML files. This parser attempts to parse most HTML files. This means that the implementation sometimes deviates from the SGML specification in favor of HTML.
The parser treats \r and \r\n as \n. Newlines after starttags and before end tags are ignored just as specified in the SGML/HTML specification.
The html spec does not specify how spaces are to be coalesced very well. Specifically, the following scenarios are not discussed (note that a space should be used here, but I am using   to force the space to be displayed):
'<b>blah <i> <strike> foo' which can be treated as: '<b>blah <i><strike>foo'
as well as: '<p><a href="http://www.gaudry.be/java-api-rf-xx"> <em>Using</em></a></p>' which appears to be treated as: '<p><a href="http://www.gaudry.be/java-api-rf-xx"><em>Using</em></a></p>'
If strict is false, when a tag that breaks flow,
(TagElement.breaksFlows) or trailing whitespace is
encountered, all whitespace will be ignored until a non whitespace
character is encountered. This appears to give behavior closer to
the popular browsers.
DTD,
TagElement,
SimpleAttributeSet| Field Summary | |
|---|---|
protected DTD |
dtd
|
protected boolean |
strict
This flag determines whether or not the Parser will be strict in enforcing SGML compatibility. |
| Fields inherited from interface javax.swing.text.html.parser.DTDConstants |
|---|
ANY, CDATA, CONREF, CURRENT, DEFAULT, EMPTY, ENDTAG, ENTITIES, ENTITY, FIXED, GENERAL, ID, IDREF, IDREFS, IMPLIED, MD, MODEL, MS, NAME, NAMES, NMTOKEN, NMTOKENS, NOTATION, NUMBER, NUMBERS, NUTOKEN, NUTOKENS, PARAMETER, PI, PUBLIC, RCDATA, REQUIRED, SDATA, STARTTAG, SYSTEM |
| Constructor Summary | |
|---|---|
Parser(DTD dtd)
|
|
| Method Summary | |
|---|---|
protected void |
endTag(boolean omitted)
Handle an end tag. |
protected void |
error(String err)
|
protected void |
error(String err,
String arg1)
|
protected void |
error(String err,
String arg1,
String arg2)
|
protected void |
error(String err,
String arg1,
String arg2,
String arg3)
Invoke the error handler. |
protected void |
flushAttributes()
|
protected SimpleAttributeSet |
getAttributes()
|
protected int |
getCurrentLine()
|
protected int |
getCurrentPos()
|
protected void |
handleComment(char[] text)
Called when an HTML comment is encountered. |
protected void |
handleEmptyTag(TagElement tag)
Called when an empty tag is encountered. |
protected void |
handleEndTag(TagElement tag)
Called when an end tag is encountered. |
protected void |
handleEOFInComment()
|
protected void |
handleError(int ln,
String msg)
An error has occurred. |
protected void |
handleStartTag(TagElement tag)
Called when a start tag is encountered. |
protected void |
handleText(char[] text)
Called when PCDATA is encountered. |
protected void |
handleTitle(char[] text)
Called when an HTML title tag is encountered. |
protected TagElement |
makeTag(Element elem)
|
protected TagElement |
makeTag(Element elem,
boolean fictional)
Makes a TagElement. |
protected void |
markFirstTime(Element elem)
Marks the first time a tag has been seen in a document |
void |
parse(Reader in)
Parse an HTML stream, given a DTD. |
String |
parseDTDMarkup()
Parses th Document Declaration Type markup declaration. |
protected boolean |
parseMarkupDeclarations(StringBuffer strBuff)
Parse markup declarations. |
protected void |
startTag(TagElement tag)
Handle a start tag. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DTD dtd
protected boolean strict
| Constructor Detail |
|---|
public Parser(DTD dtd)
| Method Detail |
|---|
protected int getCurrentLine()
protected TagElement makeTag(Element elem, boolean fictional)
protected TagElement makeTag(Element elem)
protected SimpleAttributeSet getAttributes()
protected void flushAttributes()
protected void handleText(char[] text)
protected void handleTitle(char[] text)
protected void handleComment(char[] text)
protected void handleEOFInComment()
protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException
ChangedCharSetExceptionprotected void handleStartTag(TagElement tag)
protected void handleEndTag(TagElement tag)
protected void handleError(int ln,
String msg)
protected void error(String err, String arg1, String arg2, String arg3)
protected void error(String err, String arg1, String arg2)
protected void error(String err, String arg1)
protected void error(String err)
protected void startTag(TagElement tag) throws ChangedCharSetException
ChangedCharSetExceptionprotected void endTag(boolean omitted)
protected void markFirstTime(Element elem)
public String parseDTDMarkup() throws IOException
IOExceptionprotected boolean parseMarkupDeclarations(StringBuffer strBuff) throws IOException
IOExceptionpublic void parse(Reader in) throws IOException
IOExceptionprotected int getCurrentPos()
Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)