com.g11ntoolkit.tokenizer
Class JSPTokenizer

java.lang.Object
  |
  +--com.g11ntoolkit.tokenizer.JSPTokenizer

public class JSPTokenizer
extends java.lang.Object

Looks for the JSP language elements in a JSP or HTML file and protects them so that SDLX will process them correctly.

Version:
2005/06/27
Author:
Bill Rich, Wilandra Consulting LLC
Copyright © 2004-2005, Wilandra Consulting LLC, all rights reserved.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See License Agreement.


Field Summary
static int COMMENT
          Indicator of a comment tag.
private  int currentPosition
          The current position in the string.
static int HTMLTAG
          Indicator of an HTML tag.
protected static java.util.ResourceBundle jspVars
          JSP variables Resource Bundle.
private static java.util.logging.Logger log
          The log used for all messages from this class.
private  int maxPosition
          The maximum position to begin the search for a tag.
private static java.util.ResourceBundle mrb
          Message Resource Bundle.
static int OTHER
          Indicator of some other tag.
static int SCRIPT
          Indicator of a script tag.
static int SCRIPTTAG
          Indicator of a script tag in the txt file.
private  java.lang.String str
          The string.
private  int type
          The type of tag found.
private static java.util.ResourceBundle vrb
          Variables Resource Bundle.
 
Constructor Summary
JSPTokenizer()
          Establishes an instance of the class.
JSPTokenizer(java.lang.String astr)
          Establishes an instance of the class and processes the string passed to it.
 
Method Summary
 java.lang.String getString()
          Returns the string save in this object.
 int getType()
          Returns the type of the tag found.
 boolean hasMoreTokens()
          Returns true if there could be more tags in the string.
 int[] nextCommentToken(java.lang.String cbeg, java.lang.String cend)
          Return the start and end positions of the next comment in the string.
 int[] nextImbededTag()
          Gets the begin and end positions of the first tag in the string that is inside another tag.
 int[] nextJSPTag()
          Gets the begin and end positions of the first JSP tag in the string.
 int[] nextScriptToken()
          Gets the beginning and ending positions of a script tag block in the string.
 java.lang.String nextToken()
          Gets the next tag in the string.
 int[] nextXlAttrTag(java.lang.String elName, java.lang.String attrName, int startPos)
          Gets the begin and end positions of the first translatable attribute in the string.
private  int scanScriptToken(int startPos)
          Scans the class string looking for the starting of script tags.
private  int scanToken(int startPos)
          Scans the class string looking for the starting of comment or script tags.
 void setString(java.lang.String astr)
          Sets the string and prepares it for detokenizing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log
The log used for all messages from this class.


mrb

private static java.util.ResourceBundle mrb
Message Resource Bundle.


vrb

private static java.util.ResourceBundle vrb
Variables Resource Bundle.


jspVars

protected static java.util.ResourceBundle jspVars
JSP variables Resource Bundle.


currentPosition

private int currentPosition
The current position in the string.


maxPosition

private int maxPosition
The maximum position to begin the search for a tag. This allows enough room in the string to contain the tag.


str

private java.lang.String str
The string.


type

private int type
The type of tag found.


COMMENT

public static final int COMMENT
Indicator of a comment tag.

See Also:
Constant Field Values

SCRIPT

public static final int SCRIPT
Indicator of a script tag.

See Also:
Constant Field Values

HTMLTAG

public static final int HTMLTAG
Indicator of an HTML tag.

See Also:
Constant Field Values

OTHER

public static final int OTHER
Indicator of some other tag.

See Also:
Constant Field Values

SCRIPTTAG

public static final int SCRIPTTAG
Indicator of a script tag in the txt file.

See Also:
Constant Field Values
Constructor Detail

JSPTokenizer

public JSPTokenizer()
Establishes an instance of the class.


JSPTokenizer

public JSPTokenizer(java.lang.String astr)
Establishes an instance of the class and processes the string passed to it.

Method Detail

setString

public void setString(java.lang.String astr)
Sets the string and prepares it for detokenizing.

See Also:
getString()

getString

public java.lang.String getString()
Returns the string save in this object.

Returns:
a String representing the string stored in this object
See Also:
setString(java.lang.String)

scanToken

private int scanToken(int startPos)
Scans the class string looking for the starting of comment or script tags.

Parameters:
startPos - an int specifying where to start the scan in the class string
Returns:
an int representing the position in string following the last character in the ending characters of the element

scanScriptToken

private int scanScriptToken(int startPos)
Scans the class string looking for the starting of script tags.

Parameters:
startPos - an int specifying where to start the scan in the class string
Returns:
an int representing the position in string following the last character in the ending characters of the element

getType

public int getType()
Returns the type of the tag found.

The types are represented by integers for each type.

Returns:
an int representing the type of tag found.

hasMoreTokens

public boolean hasMoreTokens()
Returns true if there could be more tags in the string.

Returns:
a boolean representing the state of whether there can be more tags in the string (true) or not (false)

nextToken

public java.lang.String nextToken()
Gets the next tag in the string.

Returns:
a String representing the next tag in the string

nextJSPTag

public int[] nextJSPTag()
Gets the begin and end positions of the first JSP tag in the string.

Returns:
an Array of int representing the beginning and ending position of the JSP tag in the string

nextImbededTag

public int[] nextImbededTag()
Gets the begin and end positions of the first tag in the string that is inside another tag.

Returns:
an Array of int representing the beginning and ending position of the imbeded tag in the string

nextXlAttrTag

public int[] nextXlAttrTag(java.lang.String elName,
                           java.lang.String attrName,
                           int startPos)
Gets the begin and end positions of the first translatable attribute in the string.

Parameters:
elName - a String specifying the name of the element that contains the translatable attribute
attrName - a String specifying the name of the translatable attribute
startPos - an int specifying the position to begin searching
Returns:
an Array of int representing the beginning and ending position of the translatable attribute in the string

nextScriptToken

public int[] nextScriptToken()
Gets the beginning and ending positions of a script tag block in the string.

Returns:
an Array of int representing the begining and ending positions of the script tag block in the string

nextCommentToken

public int[] nextCommentToken(java.lang.String cbeg,
                              java.lang.String cend)
Return the start and end positions of the next comment in the string.

Parameters:
cbeg - a String specifying the comment begin string
cend - a String specifying the comment end string
Returns:
an Array of int representing the begining and ending positions of the comment block in the string