Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.StringValue


   */
  public static StringValue mcrypt_create_iv(Env env,
               int size,
               @Optional int randomMode)
  {
    StringValue bb = env.createBinaryBuilder(size);

    for (int i = 0; i < size; i++)
      bb.appendByte((byte) RandomUtil.nextInt(256));

    return bb;
  }
View Full Code Here


        = new InternetHeaders(encodedHeaders.toInputStream()).getAllHeaders();

      while (enumeration.hasMoreElements()) {
        Header header = enumeration.nextElement();

        StringValue name
        = QuercusMimeUtility.decodeMime(env, header.getName(), charset);
        StringValue val
        = QuercusMimeUtility.decodeMime(env, header.getValue(), charset);

        Value headerName;
        if ((headerName = headers.containsKey(name)) == null) {
          headers.put(name, val);
View Full Code Here

                              String charset)
    throws UnsupportedEncodingException
  {
    String decodedStr = MimeUtility.decodeText(word.toString());
   
    StringValue str
      = env.createString(MimeUtility.unfold(decodedStr));

    return str.toBinaryValue(charset);
  }
View Full Code Here

    CharSequence nameUnicode = decoder.decode(env, name);

    decoder.reset();
    String valueUnicode = decoder.decode(env, value).toString();

    StringValue sb = env.createUnicodeBuilder();
    sb.append(UnicodeUtility.encode(env, nameUnicode, outCharset));
    sb.append(':');
    sb.append(' ');

    String word = encodeMimeWord(valueUnicode.toString(),
                                 outCharset,
                                 scheme,
                                 lineBreakChars,
                                 lineLength);

    sb.append(MimeUtility.fold(sb.length(), word));

    return sb;
  }
View Full Code Here

    if (value instanceof BinaryBuilderValue)
      return (BinaryBuilderValue) value;
    else if (value instanceof Value)
      return ((Value) value).toBinaryValue(env);
    else {
      StringValue ret =  env.createBinaryBuilder();
      ret.append(value);
      return ret;
    }
  }
View Full Code Here

    }
  }

  private static ConnectionFactory getConnectionFactory(Env env)
  {
    StringValue factoryName = env.getIni("jms.connection_factory");

    if (factoryName == null)
      log.fine("jms.connection_factory not set");

    try {
      Context context = (Context) new InitialContext().lookup("java:comp/env");

      ConnectionFactory connectionFactory =
        (ConnectionFactory) context.lookup(factoryName.toString());

      if (connectionFactory == null)
        log.warning("Couldn't find factory " + factoryName.toString());

      return connectionFactory;
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
View Full Code Here

   * Reads a Binary string.
   */
  public StringValue read(int length)
    throws IOException
  {
    StringValue bb = _env.createBinaryBuilder();
    TempBuffer temp = TempBuffer.allocate();
   
    try {
      byte []buffer = temp.getBuffer();

      while (length > 0) {
        int sublen = buffer.length;

        if (length < sublen)
          sublen = length;

        sublen = read(buffer, 0, sublen);

        if (sublen > 0) {
          bb.append(buffer, 0, sublen);
          length -= sublen;
        }
        else
          break;
      }
View Full Code Here

  /**
   * Converts from iso-8859-1 to utf8
   */
  public static Value utf8_encode(Env env, StringValue str)
  {
    StringValue sb = str.createStringBuilder();
   
    int len = str.length();
    for (int i = 0; i < len; i++) {
      int ch = str.charAt(i);

      if (ch < 0x80)
  sb.append((char) ch);
      else if (ch < 0x800) {
  sb.append((char) (0xc0 + (ch >> 6)));
  sb.append((char) (0x80 + (ch & 0x3f)));
      }
      else {
  sb.append((char) (0xe0 + (ch >> 12)));
  sb.append((char) (0x80 + ((ch >> 6) & 0x3f)));
  sb.append((char) (0x80 + ((ch) & 0x3f)));
      }
    }

    return sb;
  }
View Full Code Here

  /**
   * Converts from utf8 to iso-8859-1
   */
  public static Value utf8_decode(Env env, StringValue str)
  {
    StringValue sb = env.createUnicodeBuilder();

    int len = str.length();
    for (int i = 0; i < len; i++) {
      int ch = str.charAt(i) & 0xff;

      if (ch < 0x80)
  sb.append((char) ch);
      else if ((ch & 0xe0) == 0xc0) {
  int d1 = (ch & 0x1f) << 6;
  int d2 = str.charAt(++i) & 0x3f;

  sb.append((char) (d1 + d2));
      }
      else {
  int d1 = (ch & 0xf) << 12;
  int d2 = (str.charAt(++i) & 0x3f) << 6;
  int d3 = (str.charAt(++i) & 0x3f);

  sb.append((char) (d1 + d2 + d3));
      }
    }

    return sb;
  }
View Full Code Here

    return true;
  }

  static public 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;
View Full Code Here

TOP

Related Classes of com.caucho.quercus.env.StringValue

Copyright © 2018 www.massapicom. 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.