jsutil
Class UtilHtml

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--jsutil.UtilHtml

public class UtilHtml
extends XBNObject

Random functions to manipulate HTML source code.

Source code:  HtmlDispToActual.java


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
UtilHtml()
          Create a new UtilHtml.
 
Method Summary
 int eliminateLinks(StringOrBuffer sob_html)
          Eliminate all links in the provided html.
 int elimTagMarkers(StringOrBuffer sob_html)
          Eliminate every tag marker from the provided html.
 int elimTagMarkers(StringOrBuffer sob_html, String s_tagStart)
          Eliminate every tag marker from the provided html.
 void shrink(StringOrBuffer sob_html, int i_shrinkBy)
          Shrink the provided html.
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilHtml

public UtilHtml()

Create a new UtilHtml. This does nothing.

Method Detail

shrink

public final void shrink(StringOrBuffer sob_html,
                         int i_shrinkBy)

Shrink the provided html.

Specifically, this function makes the following changes (assumes i_shrinkBy is 1):

Parameters:
sob_html - The html to shrink May not be null.
i_shrinkBy - How many font sizes should it be shrunk by? Can be negative to increase the size. If zero, this function does nothing..

eliminateLinks

public final int eliminateLinks(StringOrBuffer sob_html)

Eliminate all links in the provided html.

This function calls:
   elimTagMarkers(sob_html, "A")
   elimTagMarkers(sob_html, "/A")

Returns:
The total number of tag markers deleted (A single link, with '<A HREF...">' and '</A>') is two replacements.

elimTagMarkers

public final int elimTagMarkers(StringOrBuffer sob_html)

Eliminate every tag marker from the provided html.

Returns:
elimTagMarkers(sob_html, null)


elimTagMarkers

public final int elimTagMarkers(StringOrBuffer sob_html,
                                String s_tagStart)

Eliminate every tag marker from the provided html.

Examples of tag markers:

Limitation: Html tag markers may not span multiple lines

This is fine:

<B>Some &lt;I&gt;html&lt;/I&gt; to bold</B>

This is legal html, but not legal for this class:

<B
>Some &lt;I&gt;html&lt;/I&gt; to bold</B>

Parameters:
sob_html - The html to eliminate links from. May not be null.
s_tagStart - If null, then all tags markers are eliminated. If non-null, then this text must be found immediately after the '<', or it is left untouched. For example:
  • 'A' causes all of the following tags to be deleted:
    • '<A HREF="...">'
    • '<A NAME="...">'
    • '<A onClick="...">'
    • '<A>'
  • 'A HREF' causes
    causes this to be deleted:  '<A HREF="...">'
    but not these:
    • '<a href="...">'
    • '<A href="...">'
  • '/A' causes all of the following tags to be deleted:
    • '</A>'
    • '</ANOTHERTAG>'
Returns:
The total number of tag markers deleted.



Copyright 2003-2005, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/jsutiljava

 

SourceForge.net Logo