Esempio n. 1
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 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. 3
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. 4
0
  protected void toXMLImpl(StringValue sb) {
    sb.append("<");

    boolean hasPrefix = false;

    if (_prefix != null && !"".equals(_prefix) && getNamespace(_prefix) != null) hasPrefix = true;

    if (hasPrefix) {
      sb.append(_prefix);
      sb.append(":");
    }

    sb.append(_name);

    /*
    if (_namespaceMap != null) {
      for (Map.Entry<String,String> entry : _namespaceMap.entrySet()) {
        if (! "".equals(entry.getKey())) {
          sb.append(" xmlns:");
          sb.append(entry.getKey());
        }
        else
          sb.append(" xmlns");
        sb.append("=\"");
        sb.append(entry.getValue());
        sb.append("\"");
      }
    }
    */

    // add attributes, if any
    if (_attributes != null) {
      int size = _attributes.size();

      for (int i = 0; i < size; i++) {
        SimpleXMLElement attr = _attributes.get(i);

        attr.toXMLImpl(sb);
      }
    }

    // add children, if any
    if (_children != null) {
      sb.append(">");

      int size = _children.size();

      for (int i = 0; i < size; i++) {
        SimpleXMLElement child = _children.get(i);

        child.toXMLImpl(sb);
      }
    } else if (_text == null || _text.length() == 0) {
      sb.append("/>");
      return;
    } else {
      sb.append(">");

      sb.append(_text);
    }

    // add closing tag
    sb.append("</");

    if (hasPrefix) {
      sb.append(_prefix);
      sb.append(":");
    }

    sb.append(_name);

    sb.append(">");
  }
 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) != '*';
 }