Package railo.commons.lang

Examples of railo.commons.lang.StringList


   * @param value value to set to variable
   * @return value setted
   * @throws PageException
   */
  public static Object setVariable(PageContext pc,String var, Object value) throws PageException {     
      StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable name declaration ["+var+"]");

    if(list.size()==1) {
      return pc.undefinedScope().set(list.next(),value);
    }
   
    // min 2 elements
    int scope=scopeString2Int(list.next());
    Object coll;
    if(scope==Scope.SCOPE_UNDEFINED){
      coll=pc.touch(pc.undefinedScope(),list.current());
    }
    else {
      coll=VariableInterpreter.scope(pc, scope, true);
      //coll=pc.scope(scope);
    }
   
   
    while(list.hasNextNext()) {
        coll=pc.touch(coll,list.next());
    }
    return pc.set(coll,list.next(),value);
  }
View Full Code Here


   * @return has removed or not
   * @throws PageException
   */
  public static Object removeVariable(PageContext pc,String var) throws PageException
      //print.ln("var:"+var);
      StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable declaration ["+var+"]");
       
    if(list.size()==1) {
      return pc.undefinedScope().remove(KeyImpl.init(list.next()));
    }
       
    int scope=scopeString2Int(list.next());
   
    Object coll;
    if(scope==Scope.SCOPE_UNDEFINED){
      coll=pc.undefinedScope().get(list.current());
    }
    else {
      coll=VariableInterpreter.scope(pc, scope, true);
      //coll=pc.scope(scope);
    }
   
    while(list.hasNextNext()) {
        coll=pc.get(coll,list.next());
    }
    return Caster.toCollection(coll).remove(KeyImpl.init(list.next()));
  }
View Full Code Here

   * @param pc PageContext to check
   * @param var variable String
   * @return exists or not
   */
  public static boolean isDefined(PageContext pc,String var) {
    StringList list = parse(pc,new ParserString(var),false);
    if(list==null) return false;
        try {
      int scope=scopeString2Int(list.next());
      Object coll =NULL;
      if(scope==Scope.SCOPE_UNDEFINED) {
        coll=pc.undefinedScope().get(list.current(),null);
        if(coll==null)return false;
      }
      else {
        coll=VariableInterpreter.scope(pc, scope, list.hasNext());
        //coll=pc.scope(scope);
      }
     
      while(list.hasNext()) {
        coll=pc.getVariableUtil().getCollection(pc,coll,list.next(),null);
        if(coll==null)return false;
      }
    } catch (PageException e) {
          return false;
      }
View Full Code Here

     * @return Variable Definition in a String List
     */
    private static StringList parse(PageContext pc,ParserString ps, boolean doLowerCase) {
        String id=readIdentifier(ps,doLowerCase);
        if(id==null)return null;
        StringList list=new StringList(id);
        CFMLExpressionInterpreter interpreter=null;
       
        while(true) {
            if(ps.forwardIfCurrent('.')) {
              id=readIdentifier(ps,doLowerCase);
              if(id==null)return null;
              list.add(id);
            }
            else if(ps.forwardIfCurrent('[')) {
                if(interpreter==null)interpreter=new CFMLExpressionInterpreter();
                try {
                    list.add(Caster.toString(interpreter.interpretPart(pc,ps)));
                } catch (PageException e) {
                    return null;
                }
                if(!ps.forwardIfCurrent(']')) return null;
                ps.removeSpace();
            }
            else break;
        }
        if(ps.isValidIndex()) return null;
        list.reset();
        return list;
    }
View Full Code Here

   
    public static StringList parse(String var, boolean doLowerCase) {
      ParserString ps = new ParserString(var);
        String id=readIdentifier(ps,doLowerCase);
        if(id==null)return null;
        StringList list=new StringList(id);
       
        while(true) {
            if(ps.forwardIfCurrent('.')) {
              id=readIdentifier(ps,doLowerCase);
              if(id==null)return null;
              list.add(id);
            }
            else break;
        }
        if(ps.isValidIndex()) return null;
        list.reset();
        return list;
    }
View Full Code Here

TOP

Related Classes of railo.commons.lang.StringList

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.