com.cometway.httpd
Class HTMLStringTools

java.lang.Object
  extended by com.cometway.httpd.HTMLStringTools

public class HTMLStringTools
extends java.lang.Object

This class has a collection of static methods for HTML/HTTP related string manipulation.


Field Summary
protected static java.lang.String EOL
           
 
Constructor Summary
HTMLStringTools()
           
 
Method Summary
static java.lang.String completeURLs(java.lang.String data, java.lang.String refURL)
          This method completes all the relative URLs found in the data based off reference URL passed in.
protected static void convertHTMLListToPlainText(XMLToken t, XMLParser parser, java.lang.StringBuffer b, int depth)
           
protected static void convertHTMLObjectToPlainText(XMLToken t, XMLParser parser, java.lang.StringBuffer b)
           
static java.lang.String convertHTMLToPlainText(java.lang.String html)
           
protected static java.lang.String convertPlainTextLineToHTML(java.lang.String s)
           
static java.lang.String convertPlainTextToHTML(java.lang.String s)
           
static java.lang.String decode(java.lang.String in)
          This method decodes an encoded URL.
static java.lang.String encode(java.lang.String in)
          This method encodes a URL and the data embedded in the URL so that it can be requested.
static java.lang.String encode(java.lang.String in, boolean fullEncode, boolean encodeForwardSlash)
          This method encodes a URL and the data embedded in the URL so that it can be requested.
static java.lang.String extractIMGTag(java.lang.String data)
          This method extracts the first img tag that is in the data
static java.lang.String extractIMGTag(java.lang.String data, org.apache.oro.text.perl.Perl5Util perl)
          This method extracts the first img tag that is in the data
static java.lang.String extractURL(java.lang.String data)
          * This method returns the first url that it finds in data.
protected static int hexToInt(java.lang.String hex)
           
protected static java.lang.String intToHex(int i)
           
static void main(java.lang.String[] args)
           
static java.lang.String removeFormTags(java.lang.String text)
          This utility method removes form tags.
static java.lang.String removeFormTags(java.lang.String text, org.apache.oro.text.perl.Perl5Util perl)
          This utility method removes form tags.
static java.lang.String removeHRTags(java.lang.String text)
          This utility method removes horizontal rule tags.
static java.lang.String removeHRTags(java.lang.String text, org.apache.oro.text.perl.Perl5Util perl)
          This utility method removes horizontal rule tags.
static java.lang.String removeHTMLTags(java.lang.String text)
          This method removes all the HTML tags in the data
static java.lang.String removeHTMLTags(java.lang.String text, org.apache.oro.text.perl.Perl5Util perl)
          This method removes all the HTML tags in the data
static java.lang.String removeListTags(java.lang.String text)
          This utility method removes list tags.
static java.lang.String removeListTags(java.lang.String text, org.apache.oro.text.perl.Perl5Util perl)
          This utility method removes list tags.
static java.lang.String removeTableTags(java.lang.String text)
          This utility method removes table tags.
static java.lang.String removeTableTags(java.lang.String text, org.apache.oro.text.perl.Perl5Util perl)
          This utility method removes table tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

protected static final java.lang.String EOL
Constructor Detail

HTMLStringTools

public HTMLStringTools()
Method Detail

extractIMGTag

public static java.lang.String extractIMGTag(java.lang.String data,
                                             org.apache.oro.text.perl.Perl5Util perl)
This method extracts the first img tag that is in the data


extractIMGTag

public static java.lang.String extractIMGTag(java.lang.String data)
This method extracts the first img tag that is in the data


removeHTMLTags

public static java.lang.String removeHTMLTags(java.lang.String text)
This method removes all the HTML tags in the data


removeHTMLTags

public static java.lang.String removeHTMLTags(java.lang.String text,
                                              org.apache.oro.text.perl.Perl5Util perl)
This method removes all the HTML tags in the data


removeFormTags

public static java.lang.String removeFormTags(java.lang.String text)
This utility method removes form tags.


removeFormTags

public static java.lang.String removeFormTags(java.lang.String text,
                                              org.apache.oro.text.perl.Perl5Util perl)
This utility method removes form tags.


removeTableTags

public static java.lang.String removeTableTags(java.lang.String text)
This utility method removes table tags.


removeTableTags

public static java.lang.String removeTableTags(java.lang.String text,
                                               org.apache.oro.text.perl.Perl5Util perl)
This utility method removes table tags.


removeHRTags

public static java.lang.String removeHRTags(java.lang.String text)
This utility method removes horizontal rule tags.


removeHRTags

public static java.lang.String removeHRTags(java.lang.String text,
                                            org.apache.oro.text.perl.Perl5Util perl)
This utility method removes horizontal rule tags.


removeListTags

public static java.lang.String removeListTags(java.lang.String text)
This utility method removes list tags.


removeListTags

public static java.lang.String removeListTags(java.lang.String text,
                                              org.apache.oro.text.perl.Perl5Util perl)
This utility method removes list tags.


extractURL

public static java.lang.String extractURL(java.lang.String data)
* This method returns the first url that it finds in data.


completeURLs

public static java.lang.String completeURLs(java.lang.String data,
                                            java.lang.String refURL)
This method completes all the relative URLs found in the data based off reference URL passed in.


encode

public static java.lang.String encode(java.lang.String in)
This method encodes a URL and the data embedded in the URL so that it can be requested.


encode

public static java.lang.String encode(java.lang.String in,
                                      boolean fullEncode,
                                      boolean encodeForwardSlash)
This method encodes a URL and the data embedded in the URL so that it can be requested. If the boolean parameter, fullEncode, is set to true, every character in the String will be encoded regardless of whether it needs to be. If the boolean parameter, encodeForwardSlash is set to true, forward slashes will also be encoded.

Currently, the encoding scheme works like this:
spaces are encoded as '+'
all letters, numbers, and the '*', '-', '.', '@', and '_' characters are not encoded
everything else will be encoded as '%XY' where X and Y are the hex value of the character


decode

public static java.lang.String decode(java.lang.String in)
This method decodes an encoded URL.


hexToInt

protected static int hexToInt(java.lang.String hex)

intToHex

protected static java.lang.String intToHex(int i)

convertHTMLToPlainText

public static java.lang.String convertHTMLToPlainText(java.lang.String html)

convertHTMLListToPlainText

protected static void convertHTMLListToPlainText(XMLToken t,
                                                 XMLParser parser,
                                                 java.lang.StringBuffer b,
                                                 int depth)
                                          throws XMLParserException
Throws:
XMLParserException

convertHTMLObjectToPlainText

protected static void convertHTMLObjectToPlainText(XMLToken t,
                                                   XMLParser parser,
                                                   java.lang.StringBuffer b)
                                            throws XMLParserException
Throws:
XMLParserException

convertPlainTextLineToHTML

protected static java.lang.String convertPlainTextLineToHTML(java.lang.String s)

convertPlainTextToHTML

public static java.lang.String convertPlainTextToHTML(java.lang.String s)

main

public static void main(java.lang.String[] args)