Java プラットフォーム 1.2

javax.swing.text.html.parser
クラス Parser

java.lang.Object
  |
  +--javax.swing.text.html.parser.Parser
直接の既知のサブクラス:
DocumentParser

public class Parser
extends Object
implements DTDConstants

DTD 駆動型の、単純な HTML パーサです。パーサは InputStream から HTML ファイルを読み取って、タグやデータを検出すると、各種のメソッド (サブクラスでオーバーライドされる) を呼び出します。

残念なことに、正しく実装されていない HTML パーサが数多く出回っています。その結果、書式の正しくない HTML ファイルも多数存在します。このパーサは、ほとんどの HTML ファイルの解析を試みます。すなわち、この実装は HTML を優先し、SGML の仕様とは異なっている場合もあります。

このパーサは、¥r および ¥r¥n を ¥n として扱います。開始タグの後、および終了タグの前の改行は、SGML や HTML の仕様に従って無視されます。

関連項目:
DTD, Tag, SimpleAttributeSet

フィールドの概要
protected  DTD dtd
           
protected  boolean strict
          このフラグは、Parser が SGML との互換性を厳密に調べるかどうかを決定します。
 
コンストラクタの概要
Parser(DTD dtd)
           
 
メソッドの概要
protected  void endTag(boolean omitted)
          終了タグを処理します。
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)
          エラーハンドラを呼び出します。
protected  void flushAttributes()
           
protected  SimpleAttributeSet getAttributes()
           
protected  int getCurrentLine()
           
protected  int getCurrentPos()
           
protected  void handleComment(char[] text)
          HTML のコメントを検出したときに呼び出されます。
protected  void handleEmptyTag(TagElement tag)
          空のタグを検出したときに呼び出されます。
protected  void handleEndTag(TagElement tag)
          終了タグを検出したときに呼び出されます。
protected  void handleEOFInComment()
           
protected  void handleError(int ln, String msg)
          エラーが発生したことを示します。
protected  void handleStartTag(TagElement tag)
          開始タグを検出したときに呼び出されます。
protected  void handleText(char[] text)
          PCDATA を検出したときに呼び出されます。
protected  void handleTitle(char[] text)
          HTML の title タグを検出したときに呼び出されます。
protected  TagElement makeTag(Element elem)
           
protected  TagElement makeTag(Element elem, boolean fictional)
          TagElement を作成します。
protected  void markFirstTime(Element elem)
          ドキュメント内に最初に見つかったタグにマークを付けます。
 void parse(Reader in)
          DTD が指定されている場合に、HTML ストリームを解析します。
 String parseDTDMarkup()
          文書型定義 (DTD - Document Type Definition) のマークアップ宣言を解析します。
protected  boolean parseMarkupDeclarations(StringBuffer strBuff)
          マークアップ宣言を解析します。
protected  void startTag(TagElement tag)
          開始タグを処理します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

dtd

protected DTD dtd

strict

protected boolean strict
このフラグは、Parser が SGML との互換性を厳密に調べるかどうかを決定します。false の場合、Parser は、不正な HTML 構成要素からなる特定の共通クラスについては寛容な解析を行います。厳密な場合もそうでない場合も、エラーは記録されます。
コンストラクタの詳細

Parser

public Parser(DTD dtd)
メソッドの詳細

getCurrentLine

protected int getCurrentLine()
戻り値:
現在解析中の行の行番号

makeTag

protected TagElement makeTag(Element elem,
                             boolean fictional)
TagElement を作成します。

makeTag

protected TagElement makeTag(Element elem)

getAttributes

protected SimpleAttributeSet getAttributes()

flushAttributes

protected void flushAttributes()

handleText

protected void handleText(char[] text)
PCDATA を検出したときに呼び出されます。

handleTitle

protected void handleTitle(char[] text)
HTML の title タグを検出したときに呼び出されます。

handleComment

protected void handleComment(char[] text)
HTML のコメントを検出したときに呼び出されます。

handleEOFInComment

protected void handleEOFInComment()

handleEmptyTag

protected void handleEmptyTag(TagElement tag)
                       throws ChangedCharSetException
空のタグを検出したときに呼び出されます。

handleStartTag

protected void handleStartTag(TagElement tag)
開始タグを検出したときに呼び出されます。

handleEndTag

protected void handleEndTag(TagElement tag)
終了タグを検出したときに呼び出されます。

handleError

protected void handleError(int ln,
                           String msg)
エラーが発生したことを示します。

error

protected void error(String err,
                     String arg1,
                     String arg2,
                     String arg3)
エラーハンドラを呼び出します。

error

protected void error(String err,
                     String arg1,
                     String arg2)

error

protected void error(String err,
                     String arg1)

error

protected void error(String err)

startTag

protected void startTag(TagElement tag)
                 throws ChangedCharSetException
開始タグを処理します。新しいタグが、タグのスタックにプッシュされます。属性リストを調べて、必要な属性を探します。

endTag

protected void endTag(boolean omitted)
終了タグを処理します。終了タグは、タグのスタックからポップされます。

markFirstTime

protected void markFirstTime(Element elem)
ドキュメント内に最初に見つかったタグにマークを付けます。

parseDTDMarkup

public String parseDTDMarkup()
                      throws IOException
文書型定義 (DTD - Document Type Definition) のマークアップ宣言を解析します。現在は、これを無視します。

parseMarkupDeclarations

protected boolean parseMarkupDeclarations(StringBuffer strBuff)
                                   throws IOException
マークアップ宣言を解析します。現在は、文書型定義 (DTD - Document Type Definition) によるマークアップだけを処理します。マークアップ宣言の場合は true を返し、そうでない場合は false を返します。

parse

public void parse(Reader in)
           throws IOException
DTD が指定されている場合に、HTML ストリームを解析します。

getCurrentPos

protected int getCurrentPos()

Java プラットフォーム 1.2

バグや機能要求の報告
新しい javadoc の表示についてのコメントやご提案
Java は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.