xbn.string.escape
Class EscapeUnescapeString

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.string.escape.EscapeUnescapeString
Direct Known Subclasses:
EscapeString, UnescapeString

public abstract class EscapeUnescapeString
extends XBNObject

Base class for escaping or unescaping characters in a string.

Source code:  EscapeUnescapeString.java


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
EscapeUnescapeString(EscapeUnescapeString escape_unescapeString)
          Create a full copy of the provided EscapeUnescapeString.
EscapeUnescapeString(ESConfig es_config)
          Create an EscapeUnescapeString.
 
Method Summary
 ESConfig getESConfig()
          Get the ESConfig for direct manipulation.
 int getIdx1stUnesc2BEsc(String s_tr)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringBuffer str_buffer)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringBuffer str_buffer, int i_idxStart)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringBuffer str_buffer, int i_idxStart, int i_idxEnd)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(String s_tr, int i_idxStart)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(String s_tr, int i_idxStart, int i_idxEnd)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr, int i_idxStart)
          Get the array index of the first character that should be escaped, but is not.
 int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr, int i_idxStart, int i_idxEnd)
          Get the array index of the first character that should be escaped, but is not.
 boolean isEscaped(StringBuffer str_buffer, int i_dx)
          Is the character at the requested array index preceded by the escape character?
 boolean isEscaped(String s_tr, int i_dx)
          Is the character at the requested array index preceded by the escape character?
 boolean isEscaped(StringOrBuffer str_orBfr, int i_dx)
          Is the character at the requested array index preceded by the escape character?
 
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

EscapeUnescapeString

public EscapeUnescapeString(ESConfig es_config)

Create an EscapeUnescapeString.

Parameters:
es_config - The configuration. May not be null.

EscapeUnescapeString

public EscapeUnescapeString(EscapeUnescapeString escape_unescapeString)

Create a full copy of the provided EscapeUnescapeString.

Parameters:
escape_unescapeString - The object to copy. May not be null.
Method Detail

getESConfig

public final ESConfig getESConfig()

Get the ESConfig for direct manipulation.

Returns:
es_config Exactly as provided to the constructor.

isEscaped

public final boolean isEscaped(String s_tr,
                               int i_dx)

Is the character at the requested array index preceded by the escape character?

Returns:
isEscaped([UtilString].getSOBSB(s_tr, "isEscaped"), i_dx)

isEscaped

public final boolean isEscaped(StringBuffer str_buffer,
                               int i_dx)

Is the character at the requested array index preceded by the escape character?

Returns:
isEscaped([UtilStringBuffer].getSOBSB(str_buffer, "isEscaped"), i_dx)

isEscaped

public final boolean isEscaped(StringOrBuffer str_orBfr,
                               int i_dx)

Is the character at the requested array index preceded by the escape character?

Note that this function does not care if the character is one that should be escaped, just that it is preceded by the escape character.

Also, take special care when analyzing a character in a string that is being unescaped on the fly. It is easily possible to confuse things. For example:

Parameters:
str_orBfr - The string to analyze. May not be null or zero characters in length.
i_dx - The array index of the character to analyze for escaped-ness. Must be between zero and (str_orBfr.length() - 1), inclusive.
Returns:
true If an odd number of escape characters immediately precede str_orBfr.charAt(i_dx).
false If an even number (including zero) of escape characters immediately precede str_orBfr.charAt(i_dx).

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(String s_tr)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilString].getSOBSB(s_tr, "getIdx1stUnesc2BEsc"))

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(String s_tr,
                                     int i_idxStart)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilString].getSOBSB(s_tr, "getIdx1stUnesc2BEsc"), i_idxStart)

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(String s_tr,
                                     int i_idxStart,
                                     int i_idxEnd)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilString].getSOBSB(s_tr, "getIdx1stUnesc2BEsc"), i_idxStart, i_idxEnd)

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringBuffer str_buffer)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilStringBuffer].getSOBSB(s_tr, "getIdx1stUnesc2BEsc"))

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringBuffer str_buffer,
                                     int i_idxStart)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilStringBuffer].getSOBSB(str_buffer, "getIdx1stUnesc2BEsc"), i_idxStart)

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringBuffer str_buffer,
                                     int i_idxStart,
                                     int i_idxEnd)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc([UtilStringBuffer].getSOBSB(str_buffer, "getIdx1stUnesc2BEsc"), i_idxStart, i_idxEnd)

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr)

Get the array index of the first character that should be escaped, but is not.

Returns:
getIdx1stUnesc2BEsc(str_orBfr, 0)

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr,
                                     int i_idxStart)

Get the array index of the first character that should be escaped, but is not.

Parameters:
str_orBfr - The StringOrBuffer to analyze. May not be null.
Returns:
getIdx1stUnesc2BEsc(str_orBfr, i_idxStart, (str_orBfr.length() - 1))

getIdx1stUnesc2BEsc

public final int getIdx1stUnesc2BEsc(StringOrBuffer str_orBfr,
                                     int i_idxStart,
                                     int i_idxEnd)

Get the array index of the first character that should be escaped, but is not.

Note: Be careful that the value of i_idxStart/i_idxEnd (whichever is lower/smaller/more-to-the-left) is the index of a character that is not escaped. Otherwise, this function will give you inaccurate results.

Parameters:
str_orBfr - The StringBuffer to analyze. May not be null or zero characters in length.
i_idxStart - The first array index to analyze. Must be between zero and (str_orBfr.length() - 1), inclusive. Note that this may be greater than i_idxEnd, should you want to analyze right to left.
i_idxEnd - The last array index to analyze. Must be between zero and (str_orBfr.length() - 1), inclusive.
Returns:
The index of the first char found, starting with i_idxStart, that should be escaped, but is not. If every character that should be escaped, is escaped (or no to-be-escaped characters exist in the line), then -1 is returned.



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

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo