SAP NetWeaver '04

com.sapportals.wcm.util.string
Class RemoveHTMLTags

[contained in: com.sap.netweaver.bc.util.par - bc.util.public_api.jar]
java.lang.Object
  |
  +--java.io.Reader
        |
        +--java.io.FilterReader
              |
              +--com.sapportals.wcm.util.string.RemoveHTMLTags

public class RemoveHTMLTags
extends java.io.FilterReader

Title: Strip HTML tags from a Reader Description: It works only with proper tags, so character references needs to be converted before applying this Filter, see ReplaceHTMLTokens

Usage Example:

in = new BufferedReader(
 new ReplaceTokens(
 new RemoveHTMLTags(
 new CharArrayReader(content.toCharArray()))));
  
Copyright (c) SAP AG 2001-2002 Company: SAP AG


Field Summary
static java.lang.String newline
           
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
RemoveHTMLTags(java.io.Reader in)
          
 
Method Summary
 void addEntity(java.lang.String entity, java.lang.String substitute)
          Defines an entity substitution set.
 void addSubstitute(java.lang.String tag, java.lang.String substitute)
          Defines a tag substitution set.
 void clearEntities()
          Tells the filter to clear all current entity substitutions
 void clearSubstitutes()
          Tells the filter to clear all current tag substitutions.
 boolean getNoCR()
          You can tell the filter to remove carraige returns (\n and \r) when parsing.
static void main(java.lang.String[] args)
          The main program for test
 int read()
          Reads a char.
 int read(char[] b, int off, int len)
          read
 void setCompressSpace(boolean flag)
          Define whether multiple spaces should be compressed into a single space.
 void setNoCR(boolean flag)
          You can tell the filter to remove carraige returns (\n and \r) when parsing.
 void useStandardEntities()
          Tells the filter to set up a standard entity substitution set.
 void useStandardSubstitutes()
          Tells the filter to set up a standard tag substitution set.
 
Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

newline

public static java.lang.String newline
Constructor Detail

RemoveHTMLTags

public RemoveHTMLTags(java.io.Reader in)
Parameters:
in - parameter for
Method Detail

read

public int read(char[] b,
                int off,
                int len)
         throws java.io.IOException
read
Overrides:
read in class java.io.FilterReader
Parameters:
len - parameter for read
b - TBD: Description of the incoming method parameter
off - TBD: Description of the incoming method parameter
Returns:
the returned int
Throws:
java.io.IOException - -

read

public int read()
         throws java.io.IOException
Reads a char. Will block if no input is available.
Overrides:
read in class java.io.FilterReader
Returns:
the char read, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - If an I/O error has occurred.
See Also:
InputStream.read()

addEntity

public void addEntity(java.lang.String entity,
                      java.lang.String substitute)
               throws java.lang.NullPointerException
Defines an entity substitution set. The user should only use the base tag definition and not include the & and ; characters.
Parameters:
entity - - the entity to substitute. Example: quot, #90, copy.
substitute - - string to sub for the entity.
Throws:
java.lang.NullPointerException -  
See Also:
useStandardEntities()

addSubstitute

public void addSubstitute(java.lang.String tag,
                          java.lang.String substitute)
                   throws java.lang.NullPointerException
Defines a tag substitution set. The user should only use the base tag definition (when substituting, attributes are ignored anyway). For example, addSubstitute("hr", "-=-=-=") will substitute any HR tag found (even with attributes) with the -=-=-= characters. Note: beginning and ending need their own definitions
Parameters:
tag - - the tag to substitute. Use base tag without attributes.
substitute - - string to sub for tag.
Throws:
java.lang.NullPointerException -  
See Also:
useStandardSubstitutes()

useStandardSubstitutes

public void useStandardSubstitutes()
Tells the filter to set up a standard tag substitution set.

useStandardEntities

public void useStandardEntities()
Tells the filter to set up a standard entity substitution set. This is relatively limited and the default set is shown below: / Original Substitution / quot " / amp & / lt < / gt > / copy (C)

clearSubstitutes

public void clearSubstitutes()
Tells the filter to clear all current tag substitutions.

clearEntities

public void clearEntities()
Tells the filter to clear all current entity substitutions

setCompressSpace

public void setCompressSpace(boolean flag)
Define whether multiple spaces should be compressed into a single space. This does not affect other "white space" characters.
Parameters:
flag -  

setNoCR

public void setNoCR(boolean flag)
You can tell the filter to remove carraige returns (\n and \r) when parsing. This allows the caller to insert CR's where desired since CR's in HTML do not confer any special meaning
Parameters:
flag - - remove carraige returns during parse and substitue spaces

getNoCR

public boolean getNoCR()
You can tell the filter to remove carraige returns (\n and \r) when parsing. This allows the caller to insert CR's where desired since CR's in HTML do not confer any special meaning
Returns:
boolean

main

public static void main(java.lang.String[] args)
The main program for test
Parameters:
args - The command line arguments

SAP NetWeaver '04

Copyright © 2004 by SAP AG. All Rights Reserved.
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.