Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.ArrayValueImpl


    boolean isRef = ref instanceof Var;

    ArrayValue result = null;

    if (isRef) {
      result = new ArrayValueImpl();
      ref.set(result);
    }
    else if (ref instanceof ArrayValue) {
      result = (ArrayValue) ref;
      isRef = true;
    }
    else
      result = new ArrayValueImpl();

    return StringUtility.parseStr(env,
                                  str,
                                  result,
                                  isRef,
View Full Code Here


    if (strlen == 0) {
      return isReturnArray ? NullValue.NULL : LongValue.MINUS_ONE;
    }

    ArrayValue array = new ArrayValueImpl();

    for (int i = 0; i < formatArray.length; i++) {
      ScanfSegment segment = formatArray[i];

      Value var;
View Full Code Here

    if (strlen == 0) {
      return isAssign ? LongValue.MINUS_ONE : NullValue.NULL;
    }

    ArrayValue array = new ArrayValueImpl();

    while (fIndex < fmtLen) {
      char ch = format.charAt(fIndex++);

      if (isWhitespace(ch)) {
        for (;
             (fIndex < fmtLen &&
              isWhitespace(ch = format.charAt(fIndex)));
             fIndex++) {
        }

        /*ch = string.charAt(sIndex);
        if (! isWhitespace(ch)) {
          // XXX: return false?
          return sscanfReturn(env, array, args, argIndex, isAssign, true);
        }*/

        for (;
          sIndex < strlen && isWhitespace(string.charAt(sIndex));
          sIndex++) {
        }
      }
      else if (ch == '%') {
        int maxLen = -1;

        loop:
        while (fIndex < fmtLen) {
          ch = format.charAt(fIndex++);

          if (sIndex >= strlen && ch != 'n') {
            array.append(NullValue.NULL);
            break loop;
          }

          Value obj;

View Full Code Here

    if (search.isNull())
      return subject;

    if (subject instanceof ArrayValue) {
      ArrayValue subjectArray = (ArrayValue) subject;
      ArrayValue resultArray = new ArrayValueImpl();

      for (Map.Entry<Value, Value> entry : subjectArray.entrySet()) {

        if (entry.getValue() instanceof ArrayValue) {
          resultArray.append(entry.getKey(), entry.getValue());
        } else {
          Value result = strReplaceImpl(env,
                                      search,
                                      replace,
                                      entry.getValue().toStringValue(),
                                      count,
                                      isInsensitive);

          resultArray.append(entry.getKey(), result);
        }
      }

      return resultArray;
    }
View Full Code Here

   * @param chunk chunk size
   */
  public static Value str_split(StringValue string,
                                @Optional("1") int chunk)
  {
    ArrayValue array = new ArrayValueImpl();

    if (string.length() == 0) {
      array.put(string);
      return array;
    }

    int strLen = string.length();

    for (int i = 0; i < strLen; i += chunk) {
      Value value;

      if (i + chunk <= strLen) {
        value = string.substring(i, i + chunk);
      } else {
        value = string.substring(i);
      }

      array.put(LongValue.create(i), value);
    }

    return array;
  }
View Full Code Here

    boolean isAdditionalWordCharacters = false;

    if (additionalWordCharacters != null)
      isAdditionalWordCharacters = additionalWordCharacters.length() > 0;

    ArrayValueImpl resultArray = null;

    if (format > 0)
      resultArray = new ArrayValueImpl();

    boolean isBetweenWords = true;
    int wordCount = 0;
    int lastWordStart = 0;

    for (int i = 0; i <= strlen; i++) {
      boolean isWordCharacter;

      if (i < strlen) {
        int ch = string.charAt(i);

        isWordCharacter = Character.isLetter(ch)
                          || ch == '-'
                          || ch == '\''
                          || (isAdditionalWordCharacters
                              && additionalWordCharacters.indexOf(ch) > -1);
      }
      else
        isWordCharacter = false;

      if (isWordCharacter) {
        if (isBetweenWords) {
          // starting a word
          isBetweenWords = false;

          lastWordStart = i;
          wordCount++;
        }
      }
      else {
        if (!isBetweenWords) {
          // finished a word
          isBetweenWords = true;

          if (format > 0) {
            StringValue word = string.substring(lastWordStart, i);

            if (format == 1)
              resultArray.append(word);
            else if (format == 2)
              resultArray.put(LongValue.create(lastWordStart), word);
          }
        }
      }
    }
View Full Code Here

      lengthV.isArray()
      ? ((ArrayValue) lengthV).values().iterator()
      : null;

    if (subjectV.isArray()) {
      ArrayValue resultArray = new ArrayValueImpl();

      ArrayValue subjectArray = (ArrayValue) subjectV;

      for (Value value : subjectArray.values()) {

        if (lengthIterator != null && lengthIterator.hasNext())
          length = lengthIterator.next().toInt();

        if (startIterator != null && startIterator.hasNext())
          start = startIterator.next().toInt();

        Value result = substrReplaceImpl(value.toStringValue(), replacement, start, length);

        resultArray.append(result);
      }

      return resultArray;
    }
    else {
View Full Code Here

  }
 
  @Override
  public ArrayValue getParameters(Env env)
  {
    ArrayValue array = new ArrayValueImpl();
   
    AbstractFunction fun = getFunction();
    Arg []args = fun.getArgs();
   
    for (int i = 0; i < args.length; i++) {
      array.put(env.wrapJava(new ReflectionParameter(_clsName, fun, args[i])));
    }
   
    return array;
  }
View Full Code Here

    return null;
  }

  public ArrayValue getFunctions(Env env)
  {
    ArrayValue array = new ArrayValueImpl();

    for (ModuleInfo moduleInfo : env.getQuercus().getModules()) {
      Set<String> extensionSet = moduleInfo.getLoadedExtensions();

      if (extensionSet.contains(_name)) {
        for (String functionName : moduleInfo.getFunctions().keySet()) {
          AbstractFunction fun = env.findFunction(functionName);

          array.put(env.wrapJava(new ReflectionFunction(fun)));
        }
      }
    }

    return array;
View Full Code Here

    return array;
  }

  public ArrayValue getConstants(Env env)
  {
    ArrayValue array = new ArrayValueImpl();

    for (ModuleInfo moduleInfo : env.getQuercus().getModules()) {
      Set<String> extensionSet = moduleInfo.getLoadedExtensions();

      if (extensionSet.contains(_name)) {
        for (Map.Entry<StringValue, Value> entry : moduleInfo.getConstMap().entrySet()) {
          array.put(entry.getKey(), entry.getValue());
        }
      }
    }

    return array;
View Full Code Here

TOP

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

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.