xbn.string.escape
Class USCIgnore

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.string.escape.USCIgnore
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
USCISpecific

public class USCIgnore
extends XBNObject
implements Cloneable

Defines which characters, when escaped, should be ignored (that is, left escaped without causing an error). This affects every character not defined as "to-be-escaped" (see ESConfig.getAPCToEscape()).

Source code:  USCIgnore.java

Why ignore?

When the same string is escaped in multiple phases, then it's most likely that something needs to be ignored. Otherwise, characters that should be unescaped in phase two (but not phase one) will cause an UnescapeStringException during phase one.

On the other hand, when there will only be one phase of escaping (or the current phase is definitely the final one), then you may want to generate an error when an incorrectly escaped character exists.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
  USCIgnore()
          Create a USCIgnore with default settings.
  USCIgnore(boolean b_ignoreAll)
          Create a USCIgnore.
protected USCIgnore(boolean b_ignoreAll, char[] ac_ignore)
          Create a USCIgnore.
  USCIgnore(char[] ac_ignore)
          Create a USCIgnore.
 
Method Summary
protected  Object clone()
          Get a full (deep) copy of this USCIgnore as an Object.
 boolean doIgnoreAll()
          Should all non-should-be-escaped characters be ignored?
 APChar getAPCIgnore()
          What specific non-to-be-escaped characters should be ignored?
 USCIgnore getEUSCUIClone()
          Get a full (deep) copy of this USCIgnore.
 boolean hasCharToIgnore()
          Is at least on character ignored?
 boolean isSpcfcIgnored(char c_har)
          Is the provided character one that should be specifically ignored?
 String toString()
          Get some information about this USCIgnore.
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

USCIgnore

public USCIgnore()

Create a USCIgnore with default settings.

Equal to USCIgnore(true)


USCIgnore

public USCIgnore(boolean b_ignoreAll)

Create a USCIgnore.

Equal to USCIgnore(b_ignoreAll, (new char[] {}))


USCIgnore

public USCIgnore(char[] ac_ignore)

Create a USCIgnore.

Equal to USCIgnore(false, ac_ignore)


USCIgnore

protected USCIgnore(boolean b_ignoreAll,
                    char[] ac_ignore)

Create a USCIgnore.

Parameters:
b_ignoreAll - Should all non-to-be-escaped chars be ignored (left escaped without causing an error)? If true, yes. If false, no. When true, ac_ignore must be zero elements in length. See doIgnoreAll.
ac_ignore - The specific array of chars to be ignored. May not be null. If zero elements in length, no specific characters are ignored. If more zero elements, then each character element should be unique, must not equal the escape character, nor any character defined as to-be-escaped (verifying that the characters are are not illegal is checked in the USConfig constructor, not here). When more than zero elements in length, b_ignoreAll must equal false. See getAPCIgnore.
Method Detail

doIgnoreAll

public final boolean doIgnoreAll()

Should all non-should-be-escaped characters be ignored?

If this function returns true, then all escaped characters (not including the escape character and those defined as to-be-escaped) are ignored. If false, then specific characters may be ignored, but "every" one is not.

Returns:
b_ignoreAll Exactly as provided to the constructor.

getAPCIgnore

public final APChar getAPCIgnore()

What specific non-to-be-escaped characters should be ignored?

When the length of the returned APChar is zero, then doIgnoreAll may return true or false. When the returned contains at least one element, doIgnoreAll always returns false.

Returns:
An APChar of length one or more Containing individual characters to be ignored, when escaped. None of these characters are the escape character, nor are any a duplicate of those defined as getAPCToEscape.
An APChar of length zero When no specific characters should be ignored.

isSpcfcIgnored

public final boolean isSpcfcIgnored(char c_har)

Is the provided character one that should be specifically ignored?

Use this in tandem with doIgnoreAll to truly determite whether a character should be ignored.

Parameters:
c_har - The character to analyze for ignore-ness.
Returns:
(Arrays.binarySearch(ac_ignore, c_har) > -1), where ac_ignore is exactly as provided to the constructor.

hasCharToIgnore

public final boolean hasCharToIgnore()

Is at least on character ignored?

Returns:
(doIgnoreAll() || getAPCIgnore().getLength() > 0)

toString

public String toString()

Get some information about this USCIgnore.

Overrides:
toString in class Object

getEUSCUIClone

public final USCIgnore getEUSCUIClone()

Get a full (deep) copy of this USCIgnore.

Returns:
(USCIgnore)clone()

clone

protected Object clone()
                throws CloneNotSupportedException

Get a full (deep) copy of this USCIgnore as an Object.

Overrides:
clone in class Object



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