/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.string.escape; import xbn.string.SOBString; import xbn.string.StringOrBuffer; import xbn.string.UtilString; import xbn.string.UtilStringBuffer; /**
Unescape characters in a string.
Source code: UnescapeString.java
"UnescapeString", meaning: Delete the escape character existing immediately before another character.
@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class UnescapeString extends EscapeUnescapeString { private UtilString uStr = new UtilString(); private UtilStringBuffer uSB = new UtilStringBuffer(); /**Create an EscapeUnescapeString.
Equal to EscapeUnescapeString(us_config)
Create a full copy of the provided UnescapeString.
Equal to EscapeUnescapeString(unescape_string)
Get the USConfig for direct manipulation.
@return(USConfig)getESConfig()
**/
public final USConfig getUSConfig() {
return (USConfig)getESConfig();
}
/**
Get a copy of the string where all characters that need to be escaped, are.
@return The contents of getSOBS:unescape([UtilString].getSOBSB(s_tr, "get"))
**/
public final String get(String s_tr) throws UnescapeStringException {
SOBString ss = uStr.getSOBS(s_tr, "get");
//We don't care what it returns, this is just to indicate that it *does* return something.
int iUNRTRND = unescape(ss);
return ss.toString();
}
/**
Get a copy of the string where all characters that need to be escaped, are.
@return The contents of getSOBS:unescape([UtilString].getSOBSB(s_tr, "get"), i_idxErrOffset)
**/
public final String get(String s_tr, int i_idxErrOffset) throws UnescapeStringException {
SOBString ss = uStr.getSOBS(s_tr, "get");
//We don't care what it returns, this is just to indicate that it *does* return something.
int iUNRTRND = unescape(ss, i_idxErrOffset);
return ss.toString();
}
/**
UnescapeString all characters that need to be.
@returnunescape([UtilStringBuffer].getSOBSB(str_buffer, "unescape"))
**/
public final int unescape(StringBuffer str_buffer) throws UnescapeStringException {
return unescape(uSB.getSOBSB(str_buffer, "unescape"));
}
/**
UnescapeString all characters that need to be.
@returnunescape([UtilStringBuffer].getSOBSB(str_buffer, "unescape"), i_idxErrOffset)
**/
public final int unescape(StringBuffer str_buffer, int i_idxErrOffset) throws UnescapeStringException {
return unescape(uSB.getSOBSB(str_buffer, "unescape"), i_idxErrOffset);
}
/**
UnescapeString all characters that need to be.
@returnunescape(str_orBfr, 0)
**/
public final int unescape(StringOrBuffer str_orBfr) throws UnescapeStringException {
return unescape(str_orBfr, 0);
}
/**
UnescapeString all characters that need to be. This removes the escape character from before the characters it is escaping. See USConfig for more information.
@param str_orBfr Contains the string that needs to have its characters un-escaped. May not be null. @param i_idxErrOffset For use only in error messages. This number is the offset to make the error messages display the proper--overall--character array index. When str_orBfr is actually a part of a larger string, use this to make error messages display the original character array index, as if str_orBfr were still part of the larger string. @return The number of (escape) characters deleted. @exception UnescapeStringException If either condition is true: