Package railo.commons.lang

Examples of railo.commons.lang.StringList$Entry


   * @param var
   * @return matching Object
   * @throws PageException
   */
  public static Object getVariable(PageContext pc, Collection collection,String var) throws PageException {     
      StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable declaration ["+var+"]");
       
        while(list.hasNextNext()) {
            collection=Caster.toCollection(collection.get(KeyImpl.init(list.next())));
        }
        return collection.get(KeyImpl.init(list.next()));
  }
View Full Code Here


    return null;
  }
 

  public static Object getVariableEL(PageContext pc, Collection collection,String var) {     
      StringList list = parse(pc,new ParserString(var),false);
        if(list==null) return null;
      
        while(list.hasNextNext()) {
          collection=Caster.toCollection(collection.get(list.next(),null),null);
          if(collection==null) return null;
        }
        return collection.get(list.next(),null);
  }
View Full Code Here

   * @param var variable string to get value to
   * @return the value
     * @throws PageException
   */
  public static Object getVariable(PageContext pc,String var) throws PageException {
        StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable declaration ["+var+"]");
       
    int scope=scopeString2Int(list.next());
    Object coll =null;
    if(scope==Scope.SCOPE_UNDEFINED) {
        coll=pc.undefinedScope().get(list.current());
    }
    else {
      coll=VariableInterpreter.scope(pc, scope, list.hasNext());
    }
   
    while(list.hasNext()) {
      coll=pc.getVariableUtil().get(pc,coll,list.next());
    }
    return coll;
    }
View Full Code Here

    }
 


  public static Object getVariableAsCollection(PageContext pc,String var) throws PageException {
        StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable declaration ["+var+"]");
       
    int scope=scopeString2Int(list.next());
    Object coll =null;
    if(scope==Scope.SCOPE_UNDEFINED) {
        coll=pc.undefinedScope().getCollection(list.current());
    }
    else {
        coll=VariableInterpreter.scope(pc, scope, list.hasNext());
    }
   
    while(list.hasNext()) {
      coll=pc.getVariableUtil().getCollection(pc,coll,list.next());
    }
    return coll;
    }
View Full Code Here

   * @param var variable string to get value to
   * @param defaultValue value returnded if variable was not found
   * @return the value or default value if not found
   */
  public static Object getVariableEL(PageContext pc,String var, Object defaultValue) {
        StringList list = parse(pc,new ParserString(var),false);
        if(list==null) return defaultValue;
       
    int scope=scopeString2Int(list.next());
    Object coll =null;
    if(scope==Scope.SCOPE_UNDEFINED) {
        coll=pc.undefinedScope().get(KeyImpl.init(list.current()),NullSupportHelper.NULL());
        if(coll==NullSupportHelper.NULL()) return defaultValue;
    }
    else {
        try {
                coll=VariableInterpreter.scope(pc, scope, list.hasNext());
          //coll=pc.scope(scope);
            }
        catch (PageException e) {
                return defaultValue;
            }
    }
   
    while(list.hasNext()) {
      coll=pc.getVariableUtil().get(pc,coll,KeyImpl.init(list.next()),NullSupportHelper.NULL());
      if(coll==NullSupportHelper.NULL()) return defaultValue;
    }
    return coll;
    }
View Full Code Here

    }
    return coll;
    }
 
  public static Object getVariableELAsCollection(PageContext pc,String var, Object defaultValue) {
        StringList list = parse(pc,new ParserString(var),false);
        if(list==null) return defaultValue;
       
    int scope=scopeString2Int(list.next());
    Object coll =null;
    if(scope==Scope.SCOPE_UNDEFINED) {
        try {
        coll=pc.undefinedScope().getCollection(list.current());
      }
        catch (PageException e) {
        coll=null;
      }
        if(coll==null) return defaultValue;
    }
    else {
        try {
                coll=VariableInterpreter.scope(pc, scope, list.hasNext());
          //coll=pc.scope(scope);
            }
        catch (PageException e) {
                return defaultValue;
            }
    }
   
    while(list.hasNext()) {
      coll=pc.getVariableUtil().getCollection(pc,coll,list.next(),null);
      if(coll==null) return defaultValue;
    }
    return coll;
    }
View Full Code Here

   * @param var variable name to get
   * @return variable as Reference
   * @throws PageException
   */
  public static VariableReference getVariableReference(PageContext pc,String var) throws PageException {
      StringList list = parse(pc,new ParserString(var),false);
        if(list==null) throw new InterpreterException("invalid variable declaration ["+var+"]");
       
    if(list.size()==1) {
      return new VariableReference(pc.undefinedScope(),list.next());
    }
    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, list.hasNext());
      //coll=pc.scope(scope);
    }
   
   
    while(list.hasNextNext()) {
      coll=pc.touch(coll,list.next());
    }

    if(!(coll instanceof Collection))
      throw new InterpreterException("invalid variable ["+var+"]");
    return new VariableReference((Collection)coll,list.next());
  }
View Full Code Here

   * @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

TOP

Related Classes of railo.commons.lang.StringList$Entry

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.