Examples of StringOrBuffer


Examples of com.uic.ase.proj.xbn.string.StringOrBuffer

  public final int unescape(StringOrBuffer str_orBfr, int i_idxErrOffset) throws UnescapeStringException  {
    throwAXIfNull(str_orBfr, "str_orBfr", "unescape");

    int iCharsDeleted = 0;

    StringOrBuffer sob = str_orBfr;

    //Note this is initialized to false.  The first character
    //in the string is definitely not escaped.
    boolean bPrecededByEscChar = false;
    for(int i = 0; i < sob.length(); i++)  {
      char c = sob.charAt(i);
      if(c != getUSConfig().getEscapeChar())  {
        //The current character is not the escape character.
        if(getUSConfig().isToBeEscaped(c))  {
          //This character is not the escape character, but
          //is one that must be escaped...

          if(!bPrecededByEscChar)  {
            //...but it is not escaped (it is preceded by a
            //character other than the escape character, or
            //this character is the first one).
            throwEUSUX("unescape (1):  An unescaped '" + c + "' was found at index " + (i + iCharsDeleted + i_idxErrOffset) + ".  [" + getUSConfig().toString() + sCLS_BRK);

          }
          //... and it is escaped.

          //Delete the escape character.
          sob.deleteCharAt(i - 1);
          iCharsDeleted++;
          bPrecededByEscChar = false;

          //i is now pointing to the character *after* the one
          //being escaped.  Decrement i to point to the character
          //being escaped, so when it is incremented at the top of the
          //for loop, it *then* points to that same next character.
          i--;

          continue;

        else if(bPrecededByEscChar)  {
          //This character is not the escape character, and not one
          //that must be escaped...but it *is* escaped.
          bPrecededByEscChar = false;

          if(!getUSConfig().getUSCIgnore().doIgnoreAll()  &&
              !getUSConfig().getUSCIgnore().isSpcfcIgnored(c))  {
            throwEUSUX("unescape (3):  An escaped '" + c + "' was found at index " + (i + iCharsDeleted + i_idxErrOffset) + ".  '" + c + "' is not among the characters that should be escaped.  [" + getUSConfig().toString() + sCLS_BRK);
          }

        }

      }  else  {
        //The current character is an escape character...
        if(bPrecededByEscChar  &&  i > 0)  {
          //...and it itself is escaped.
          sob.deleteCharAt(i - 1);
          iCharsDeleted++;
          bPrecededByEscChar = false;

          //i is now pointing to the character *after* the one
          //being escaped.  Decrement i to point to the character
          //being escaped, so when it is incremented at the top of the
          //for loop, it *then* points to the next character.
          i--;

          continue;
        }

        //...but it is not escaped.  Perhaps it is escaping
        //   something else?
        if(i == (sob.length() - 1))  {
          //This escape character is the last character in the
          //string, is not escaping anything, and is not
          //escaped itself.
          throwEUSUX("unescape (2):  An unescaped '" + getUSConfig().getEscapeChar() + "' was found at index " + (i + iCharsDeleted + i_idxErrOffset) + ".  [" + getUSConfig().toString() + sCLS_BRK);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.