com.sapportals.wcm.util.html

Class HtmlTokenizer

java.lang.Object
  extended bycom.sapportals.wcm.WcmObject
      extended bycom.sapportals.wcm.util.html.HtmlTokenizer

public class HtmlTokenizer
extends WcmObject

HtmlTokenizer

Copyright (c) SAP AG 2001-2003


Field Summary
static int TOKEN_COMMENT
          comment token
static int TOKEN_EOF
          end of file
static int TOKEN_TAG
          tag token
static int TOKEN_TEXT
          text token
 
Fields inherited from class com.sapportals.wcm.WcmObject
ORDER_TYPE_MANUAL, ORDER_TYPE_NONE
 
Constructor Summary
HtmlTokenizer(InputStream in)
          Create a new HtmlTokenizer InputStream is = ; HtmlTokenizer htmlTokenizer = new HtmlTokenizer(is); while (htmlTokenizer.next() !
 
Method Summary
 String getEncoding()
           
 String getToken()
          this method returns the current token as a String.
 String getTokenContent()
          this method returns raw content of last token, e.g. a tag without "<" and ">".
 int getTokenType()
           
 int next()
          Parse the input stream and returns the type of the next token. type is one of the TOKEN_ defines:
 void writeToStream(Writer pw)
          This method writes the inputstream from the current position to the PrintWriter without any further parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOKEN_EOF

public static final int TOKEN_EOF
end of file

See Also:
Constant Field Values

TOKEN_TEXT

public static final int TOKEN_TEXT
text token

See Also:
Constant Field Values

TOKEN_TAG

public static final int TOKEN_TAG
tag token

See Also:
Constant Field Values

TOKEN_COMMENT

public static final int TOKEN_COMMENT
comment token

See Also:
Constant Field Values
Constructor Detail

HtmlTokenizer

public HtmlTokenizer(InputStream in)
Create a new HtmlTokenizer
 InputStream is = ;
 HtmlTokenizer htmlTokenizer = new HtmlTokenizer(is);
 while (htmlTokenizer.next() != HtmlTokenizer.TOKEN_EOF) {
   int type = htmlTokenizer.getTokenType();
   if (type == HtmlTokenizer.TOKEN_TAG) {
     System.out.println("tag: " + htmlTokenizer.getToken());
   }
   else if (type == HtmlTokenizer.TOKEN_TEXT) {
     System.out.println("text: " + htmlTokenizer.getToken());
   }
   else if (type == HtmlTokenizer.TOKEN_COMMENT) {
     System.out.println("comment: " + htmlTokenizer.getToken());
   }
 

Parameters:
in - input stream
Method Detail

getEncoding

public String getEncoding()
Returns:
the encoding of the HTML page

getTokenType

public int getTokenType()
Returns:
the last token type. See TOKEN_ defines

getToken

public String getToken()
this method returns the current token as a String.

Returns:
token

getTokenContent

public String getTokenContent()
this method returns raw content of last token, e.g. a tag without "<" and ">".

Returns:
tokenContent

next

public int next()
         throws IOException
Parse the input stream and returns the type of the next token. type is one of the TOKEN_ defines:

Returns:
TBD: Description of the outgoing return value
Throws:
IOException - Exception raised in failure situation

writeToStream

public void writeToStream(Writer pw)
                   throws IOException
This method writes the inputstream from the current position to the PrintWriter without any further parsing.

Parameters:
pw - TBD: Description of the incoming method parameter
Throws:
IOException - Exception raised in failure situation


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.