Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.ArrayValue


 
  protected static Value findTimeZone(StringValue abbr,
                                      int offset,
                                      boolean isDST)
  {
    ArrayValue array = listAbbreviations();
   
    Value zones = array.get(abbr.toLowerCase());
   
    if (zones.isset() && zones.isArray()) {
      Value offsetStr = StringValue.create("offset");
     
      for (Value zone : ((ArrayValue)zones).values()) {
View Full Code Here


  public static Value decodeMimeHeaders(Env env,
                                        StringValue encodedHeaders,
                                        String charset)
    throws UnsupportedEncodingException
  {
    ArrayValue headers = new ArrayValueImpl();

    try {
      Enumeration<Header> enumeration
        = (Enumeration<Header>)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);
          continue;
        }

        ArrayValue inner;
        if (headerName.isArray()) {
          inner = headerName.toArrayValue(env);
        }
        else {
          inner = new ArrayValueImpl();
          inner.put(headerName);
        }

        inner.put(val);
        headers.put(name, inner);
      }

      return headers;
   
View Full Code Here

   *
   * @return the expression value.
   */
  public Value eval(Env env)
  {
    ArrayValue array = new ArrayValueImpl();

    for (int i = 0; i < _values.length; i++) {
      Expr keyExpr = _keys[i];
     
      Value value = _values[i].evalArg(env, true);
      value = value.toArgValue();

      if (keyExpr != null) {
        Value key = keyExpr.evalArg(env, true).toArgValue();

        array.put(key, value);
      }
      else
        array.put(value);
    }

    return array;
  }
View Full Code Here

   */
  public Value evalArray(Env env)
  {
    Value obj = _expr.evalArray(env);

    ArrayValue array = new ArrayValueImpl();
   
    obj.put(array);
   
    return array;
  }
View Full Code Here

  /**
   * Returns the supported key sizes
   */
  public Value get_supported_key_sizes()
  {
    ArrayValue value = new ArrayValueImpl();

    if (McryptModule.MCRYPT_RIJNDAEL_128.equals(_algorithm)) {
      value.put(128 / 8);
    }
    else if (McryptModule.MCRYPT_RIJNDAEL_192.equals(_algorithm)) {
      value.put(128 / 8);
      value.put(192 / 8);
    }
    else if (McryptModule.MCRYPT_RIJNDAEL_256.equals(_algorithm)) {
      value.put(128 / 8);
      value.put(192 / 8);
      value.put(256 / 8);
    }
    else if (McryptModule.MCRYPT_3DES.equals(_algorithm)) {
      value.put(24);
    }
    else if (McryptModule.MCRYPT_DES.equals(_algorithm)) {
      value.put(8);
    }

    return value;
  }
View Full Code Here

  /**
   * Lists the available algorithms
   */
  public static Value mcrypt_list_algorithms(Env env)
  {
    ArrayValue array = new ArrayValueImpl();

    for (int i = 0; i < ALGORITHMS.length; i++) {
      try {
        Mcrypt mcrypt = new Mcrypt(env, ALGORITHMS[i], "cbc");

        array.put(mcrypt.get_algorithms_name());
      } catch (Throwable e) {
      }
    }

    return array;
View Full Code Here

  /**
   * Lists the available modes.
   */
  public static Value mcrypt_list_modes(Env env)
  {
    ArrayValue array = new ArrayValueImpl();

    array.put(MCRYPT_MODE_ECB);
    array.put(MCRYPT_MODE_CBC);
    array.put(MCRYPT_MODE_CFB);
    array.put(MCRYPT_MODE_OFB);
    array.put(MCRYPT_MODE_NOFB);

    return array;
  }
View Full Code Here

  /**
   * Returns the supported key sizes
   */
  public Value get_supported_key_sizes()
  {
    ArrayValue value = new ArrayValueImpl();

    // php/1q0c - can mix any key size with any block size
    if (McryptModule.MCRYPT_RIJNDAEL_128.equals(_algorithm)) {
      value.put(128 / 8);
      value.put(192 / 8);
      value.put(256 / 8);
    }
    else if (McryptModule.MCRYPT_RIJNDAEL_192.equals(_algorithm)) {
      value.put(128 / 8);
      value.put(192 / 8);
      value.put(256 / 8);
    }
    else if (McryptModule.MCRYPT_RIJNDAEL_256.equals(_algorithm)) {
      value.put(128 / 8);
      value.put(192 / 8);
      value.put(256 / 8);
    }
    else if (McryptModule.MCRYPT_3DES.equals(_algorithm)) {
      value.put(24);
    }
    else if (McryptModule.MCRYPT_DES.equals(_algorithm)) {
      value.put(8);
    }

    return value;
  }
View Full Code Here

  public static Value decodeMimeHeaders(Env env,
                                        StringValue encodedHeaders,
                                        String charset)
    throws UnsupportedEncodingException
  {
    ArrayValue headers = new ArrayValueImpl();

    try {
      Enumeration<Header> enumeration
        = 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);
          continue;
        }

        ArrayValue inner;
        if (headerName.isArray()) {
          inner = headerName.toArrayValue(env);
        }
        else {
          inner = new ArrayValueImpl();
          inner.put(headerName);
        }

        inner.put(val);
        headers.put(name, inner);
      }

      return headers;
   
View Full Code Here

                 @Optional String charset)
  {
    if (string.length() == 0)
      return env.getEmptyString();

    ArrayValue htmlEntities = null;
   
    boolean isUnicode = env.isUnicodeSemantics();

    if (isUnicode) {
      if (HTML_ENTITIES_ARRAY_UNICODE_ENTITY_KEY == null)
        HTML_ENTITIES_ARRAY_UNICODE_ENTITY_KEY = toUnicodeArray(env, HTML_ENTITIES_ARRAY_ENTITY_KEY);
     
      htmlEntities = HTML_ENTITIES_ARRAY_UNICODE_ENTITY_KEY;
    }
    else
      htmlEntities = HTML_ENTITIES_ARRAY_ENTITY_KEY;

    EncodingWriter out = null;

    if (! isUnicode) {
      if (charset == null || charset.length() == 0)
        charset = env.getRuntimeEncoding();

      out = Encoding.getWriteEncoding(charset);
    }

    int len = string.length();
    int htmlEntityStart = -1;
    StringValue result = env.createStringBuilder();
   
    try {
      // Loop through each character
      for (int i = 0; i < len; i++) {     
        char ch = string.charAt(i);
       
        // Check whether it's a html entity i.e. starts with '&' and ends with ';'
        if (ch == '&' && htmlEntityStart < 0) {                   
          htmlEntityStart = i;
        }
        else if (htmlEntityStart < 0) {
          // else add it to result.
          result.append(ch);
        }
        else if (ch == ';') {
          // If so substitute the entity and add it to result.
          StringValue entity = string.substring(htmlEntityStart, i + 1);
          Value value = htmlEntities.get(entity);
         
          if (value.isNull()) {
            result.append(entity);
          }
          else if (isUnicode) {
View Full Code Here

TOP

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

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.