public static StringValue getDeclaringClass(StringValue sb, StringValue canonicalName) {
    if (canonicalName.charAt(0) != '\u0000') {
      return sb;
    }

    int len = canonicalName.length();
    for (int i = 1; i < len; i++) {
      char ch = canonicalName.charAt(i);

      if (ch == '\u0000') {
        break;
      } else {
        sb.append(ch);
      }
    }

    return sb;
  }
Esempio n. 2
0
  private static StringValue formatImpl(Env env,
                                        StringValue msg,
                                        Value []args,
                                        StringValue sb)
  {
    int i = 0;
    int length = msg.length();

    while (i < length) {
      char ch = msg.charAt(i);

      if (ch != '[' || i + 4 > length) {
        sb.append(ch);
        i++;
      }
      else if (msg.charAt(i + 1) != '_') {
        sb.append(ch);
        i++;
      }
      else if (msg.charAt(i + 3) != ']') {
        sb.append(ch);
        i++;
      }
      else {
        ch = msg.charAt(i + 2);
        int argIndex = ch - '0';

        if (0 <= argIndex && argIndex < args.length) {
          sb.append(args[argIndex]);
          i += 4;
        }
        else {
          sb.append('[');
          i++;
        }
      }
    }
    
    return sb;
  }
Esempio n. 3
0
  public static StringValue pgRealEscapeString(StringValue str) {
    StringValue buf = str.createStringBuilder(str.length());

    final int strLength = str.length();

    for (int i = 0; i < strLength; i++) {
      char c = str.charAt(i);

      switch (c) {
        case '\u0000':
          buf.append('\\');
          buf.append('\u0000');
          break;
        case '\n':
          buf.append('\\');
          buf.append('n');
          break;
        case '\r':
          buf.append('\\');
          buf.append('r');
          break;
        case '\\':
          buf.append('\\');
          buf.append('\\');
          break;
        case '\'':
          buf.append('\'');
          buf.append('\'');
          break;
        case '"':
          // pg_escape_string does nothing about it.
          // buf.append('\\');
          buf.append('\"');
          break;
        case '\032':
          buf.append('\\');
          buf.append('Z');
          break;
        default:
          buf.append(c);
          break;
      }
    }

    return buf;
  }
 public static boolean isProtected(StringValue canonicalName) {
   return canonicalName.length() > 3
       && canonicalName.charAt(0) == '\u0000'
       && canonicalName.charAt(1) == '*'
       && canonicalName.charAt(2) == '\u0000';
 }
 public static boolean isPrivate(StringValue canonicalName) {
   return canonicalName.length() > 3
       && canonicalName.charAt(0) == '\u0000'
       && canonicalName.charAt(1) != '*';
 }