JavaTM Platform
Standard Ed. 6

javax.swing.text.html.parser
클래스 Parser

java.lang.Object 
  상위를 확장 javax.swing.text.html.parser.Parser
모든 구현된 인터페이스:
DTDConstants
직계의 기존의 서브 클래스:
DocumentParser


public class Parser
extends Object
implements DTDConstants

DTD 구동형의 단순한 HTML 퍼서입니다. 퍼서는 InputStream 로부터 HTML 파일을 읽어내, 태그나 데이터를 검출하면(자), 각종의 메소드 (서브 클래스에서 오버라이드(override) 된다)를 호출합니다.

유감스럽게, 올바르게 구현되어 있지 않은 HTML 퍼서가 많이 나돌고 있습니다. 그 결과, 서식의 올바르지 않은 HTML 파일도 다수 존재합니다. 이 퍼서는, 대부분의 HTML 파일의 해석을 시도합니다. 즉, 이 구현은 HTML 를 우선해, SGML 의 스펙과는 다른 경우도 있습니다.

이 퍼서는, \r 및 \r\n 를 \n 로서 취급합니다. 개시 태그의 뒤, 및 종료 태그의 전의 개행은, SGML 나 HTML 의 스펙에 따라 무시됩니다.

HTML 스펙에서는, 공백 문자가 어떻게 연속할까에 임해서 명확하게 지정되고 있지 않습니다. 특히, 다음과 같은 시나리오에 대해서는 논의되고 있지 않습니다 (여기에서는 공백 문자를 사용해야 하지만, 공백 문자의 표시에 &nbsp 를 사용하고 있다).

' 「<b>blah <i> <strike> foo」는 「<b>blah <i><strike>foo」와 같은 것으로서 다루어집니다.

같이 「<p><a href="xx"> <em>Using</em></a></p>」는 「<p><a href="xx"><em>Using</em></a></p>」와 같은 것으로서 다루어집니다.

strict 가 false 의 경우, 플로우를 브레이크하는 태그 (TagElement.breaksFlows)나 말미에 공백이 발견되면(자), 공백 이외의 문자가 발견될 때까지, 공백은 모두 무시됩니다. 이것에 의해, 일반적인 브라우저에 동작이 가까운 시일내에 됩니다.

관련 항목:
DTD , TagElement , SimpleAttributeSet

필드의 개요
protected  DTD dtd
           
protected  boolean strict
          이 플래그는, Parser 가 SGML 와의 호환성을 엄밀하게 조사할지 어떨지를 결정합니다.
 
인터페이스 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
 
생성자 의 개요
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)
          빈 상태(empty)의 태그를 검출했을 때에 불려 갑니다.
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 Declaration)의 마크 업 선언을 해석합니다.
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 
빈 상태(empty)의 태그를 검출했을 때에 불려 갑니다.

예외:
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 
개시 태그를 처리합니다. 새로운 태그가, 태그의 스택에 푸쉬 됩니다. 속성 리스트를 조사해, 필요한 속성을 찾습니다.

예외:
ChangedCharSetException

endTag

protected void endTag(boolean omitted)
종료 태그를 처리합니다. 종료 태그는, 태그의 스택으로부터 팝 됩니다.


markFirstTime

protected void markFirstTime(Element  elem)
문서내에서 최초로 발견된 태그에 마크를 붙입니다.


parseDTDMarkup

public String  parseDTDMarkup()
                      throws IOException 
문서형 정의 (DTD - Document Type Declaration)의 마크 업 선언을 해석합니다. 현재는, 이것을 무시합니다.

예외:
IOException

parseMarkupDeclarations

protected boolean parseMarkupDeclarations(StringBuffer  strBuff)
                                   throws IOException 
마크 업 선언을 해석합니다. 현재는, 문서형 정의 (DTD - Document Type Declaration)에 의한 마크 업만을 처리합니다. 마크 업 선언의 경우는 true 를 돌려주어, 그렇지 않은 경우는 false 를 돌려줍니다.

예외:
IOException

parse

public void parse(Reader  in)
           throws IOException 
DTD 가 지정되고 있는 경우에, HTML 스트림을 해석합니다.

예외:
IOException

getCurrentPos

protected int getCurrentPos()

JavaTM Platform
Standard Ed. 6

버그의 보고와 기능의 요청
한층 더 자세한 API 레퍼런스 및 개발자 문서에 대해서는,Java SE 개발자용 문서를 참조해 주세요. 개발자전용의 상세한 해설, 개념의 개요, 용어의 정의, 버그의 회피책, 및 코드 실례가 포함되어 있습니다.

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.