Package railo.runtime.type

Examples of railo.runtime.type.Struct


    if(object instanceof Throwable) {
      Throwable t=(Throwable)object;
      return new CustomTypeException(t.getMessage(),"","",t.getClass().getName(),"");
    }
    if(object instanceof Struct){
      Struct sct=(Struct) object;
      String type=Caster.toString(sct.get(KeyConstants._type,""),"").trim();
      String msg=Caster.toString(sct.get(KeyConstants._message,null),null);
      if(!StringUtil.isEmpty(msg, true)) {
        String detail=Caster.toString(sct.get(KeyConstants._detail,null),null);
        String errCode=Caster.toString(sct.get("ErrorCode",null),null);
        String extInfo=Caster.toString(sct.get("ExtendedInfo",null),null);
       
        PageException pe=null;
        if("application".equalsIgnoreCase(type))
          pe = new ApplicationException(msg, detail);
        else if("expression".equalsIgnoreCase(type))
          pe = new ExpressionException(msg, detail);
        else
          pe=new CustomTypeException(msg, detail, errCode, type, extInfo);
       
        // Extended Info
        if(!StringUtil.isEmpty(extInfo,true))pe.setExtendedInfo(extInfo);
 
        // Error Code
        if(!StringUtil.isEmpty(errCode,true))pe.setErrorCode(errCode);
       
        // Additional
        if(pe instanceof PageExceptionImpl) {
          PageExceptionImpl pei=(PageExceptionImpl) pe;
          sct=Caster.toStruct(sct.get("additional",null),null);
          Iterator<Entry<Key, Object>> it = sct.entryIterator();
          Entry<Key, Object> e;
          while(it.hasNext()){
            e = it.next();
            pei.setAdditional(e.getKey(), e.getValue());
          }
View Full Code Here



  private ExecutionPlan toExecutionPlan(Object obj,int plus) throws PageException {

    if(obj instanceof Struct){
      Struct sct=(Struct)obj;
      // GERT
     
      // tries
      Object oTries=sct.get("tries",null);
      if(oTries==null)throw new ExpressionException("missing key tries inside struct");
      int tries=Caster.toIntValue(oTries);
      if(tries<0)throw new ExpressionException("tries must contain a none negative value");
     
      // interval
      Object oInterval=sct.get("interval",null);
      if(oInterval==null)oInterval=sct.get("intervall",null);
     
      if(oInterval==null)throw new ExpressionException("missing key interval inside struct");
      int interval=toSeconds(oInterval);
      if(interval<0)throw new ExpressionException("interval should contain a positive value or 0");
     
View Full Code Here

            "you can define a default datasource as attribute [defaultdatasource] of the tag "+Constants.CFAPP_NAME+" or as data member of the "+Constants.APP_CFC+" (this.defaultdatasource=\"mydatasource\";)");
    }
   
   
   
      Struct res=new StructImpl();
    DataSourceManager manager = pageContext.getDataSourceManager();
    DatasourceConnection dc = ds instanceof DataSource?
        manager.getConnection(pageContext,(DataSource)ds,username,password):
        manager.getConnection(pageContext,Caster.toString(ds),username,password);
   
    // create returnValue
    returnValue(dc);
   
    // create SQL
    StringBuilder sql=createSQL();
   

    // add returnValue to params
    if(returnValue!=null){
      params.add(0,returnValue);
    }
   
    SQLImpl _sql=new SQLImpl(sql.toString());
    CallableStatement callStat=null;
    try {
        callStat = dc.getConnection().prepareCall(sql.toString());
            //ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
            //ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
       
        if(blockfactor>0)callStat.setFetchSize(blockfactor);
        if(timeout>0)callStat.setQueryTimeout(timeout);
       
  // set IN register OUT
        Iterator<ProcParamBean> it = params.iterator();
      ProcParamBean param;
      int index=1;
        while(it.hasNext()) {
          param= it.next();
          param.setIndex(index);
          _sql.addItems(new SQLItemImpl(param.getValue()));
          if(param.getDirection()!=ProcParamBean.DIRECTION_OUT) {
            SQLCaster.setValue(pageContext.getTimeZone(),callStat, index, param);
          }
          if(param.getDirection()!=ProcParamBean.DIRECTION_IN) {
            registerOutParameter(callStat,param);
          }
          index++;
      }
       
  // cache
        boolean isFromCache=false;
        boolean hasCached=cachedbefore!=null || cachedafter!=null;
        Object cacheValue=null;
        String dsn = ds instanceof DataSource?((DataSource)ds).getName():Caster.toString(ds);
      if(clearCache) {
        hasCached=false;
        pageContext.getQueryCache().remove(pageContext,_sql,dsn,username,password);
      }
      else if(hasCached) {
        cacheValue = pageContext.getQueryCache().get(pageContext,_sql,dsn,username,password,cachedafter);
      }
      int count=0;
      if(cacheValue==null){
        // execute
        boolean isResult=callStat.execute();
       
          Struct cache=hasCached?new StructImpl():null;
 
          // resultsets
          ProcResultBean result;
         
          index=1;
        do {
            if(isResult){
              ResultSet rs=callStat.getResultSet();
              if(rs!=null) {
              try{
                result=(ProcResultBean) results.get(index++,null);
                if(result!=null) {
                  railo.runtime.type.Query q = new QueryImpl(rs,result.getMaxrows(),result.getName(),pageContext.getTimeZone())
                  count+=q.getRecordcount();
                  setVariable(result.getName(), q);
                  if(hasCached)cache.set(KeyImpl.getInstance(result.getName()), q);
                }
              }
              finally{
                IOUtil.closeEL(rs);
              }
            }
            }
          }
          while((isResult=callStat.getMoreResults()) || (callStat.getUpdateCount() != -1));

          // params
          it = params.iterator();
          while(it.hasNext()) {
            param= it.next();
            if(param.getDirection()!=ProcParamBean.DIRECTION_IN){
              Object value=null;
              if(!StringUtil.isEmpty(param.getVariable())){
                try{
                  value=SQLCaster.toCFType(callStat.getObject(param.getIndex()));
                }
                catch(Throwable t){}
                value=emptyIfNull(value);
               
                if(param==STATUS_CODE) res.set(STATUSCODE, value);
                else setVariable(param.getVariable(), value);
                if(hasCached)cache.set(KeyImpl.getInstance(param.getVariable()), value);
              }
            }
        }
          if(hasCached){
            cache.set(COUNT, Caster.toDouble(count));
            pageContext.getQueryCache().set(pageContext,_sql,dsn,username,password,cache,cachedbefore);
          }
         
      }
      else if(cacheValue instanceof Struct) {
        Struct sctCache = (Struct) cacheValue;
        count=Caster.toIntValue(sctCache.removeEL(COUNT),0);
       
        Iterator<Entry<Key, Object>> cit = sctCache.entryIterator();
        Entry<Key, Object> ce;
        while(cit.hasNext()){
          ce = cit.next();
          if(STATUS_CODE.getVariable().equals(ce.getKey().getString()))
            res.set(KEY_SC, ce.getValue());
View Full Code Here

  public static Struct toProperties(Struct data) {
    data=(Struct) Duplicator.duplicate(data,true);
   
   

    Struct rdf = Caster.toStruct(data.removeEL(RDF),null,false);
    if(rdf==null)rdf = Caster.toStruct(data.removeEL(RSS),null,false);
    if(rdf!=null){
      rdf.removeEL(ITEM);
      Struct channel = Caster.toStruct(rdf.get(CHANNEL,null),null,false);
      if(channel!=null){
        channel.removeEL(ITEMS);
        StructUtil.copy(channel, data, true);
       
      }
    }
   
View Full Code Here

     */
    private void setCFLogin(Object username, Object password) {
        if(username==null) return;
        if(password==null) password="";
       
        Struct sct=new StructImpl();
        sct.setEL(KeyConstants._name,username);
        sct.setEL(KeyConstants._password,password);
        pageContext.undefinedScope().setEL(CFLOGIN,sct);
    }
View Full Code Here

        sct.set(KeyConstants._synchronized,comp.properties._synchronized);
        if(comp.properties.output!=null)
        sct.set(KeyConstants._output,comp.properties.output);
           
        // extends
        Struct ex=null;
        if(comp.base!=null) ex=getMetaData(access,pc,comp.base,true);
        if(ex!=null)sct.set(KeyConstants._extends,ex);
       
        // implements
        InterfaceCollection ic = comp.interfaceCollection;
        if(ic!=null){
          Set<String> set = ListUtil.listToSet(comp.properties.implement, ",",true);
            InterfaceImpl[] interfaces = comp.interfaceCollection.getInterfaces();
            if(!ArrayUtil.isEmpty(interfaces)){
              Struct imp=new StructImpl();
              for(int i=0;i<interfaces.length;i++){
                if(!set.contains(interfaces[i].getCallPath())) continue;
                //print.e("-"+interfaces[i].getCallPath());
                imp.setEL(KeyImpl.init(interfaces[i].getCallPath()), interfaces[i].getMetaData(pc,true));
              }
              sct.set(KeyConstants._implements,imp);
            }
        }
        
View Full Code Here

      readExternalOldStyle(pc, name);
      return;
    }
   
    String md5 = in.readUTF();
    Struct _this = Caster.toStruct(in.readObject(),null);
    Struct _var = Caster.toStruct(in.readObject(),null);
     
    try {
      ComponentImpl other=(ComponentImpl)EvaluateComponent.invoke(pc, name, md5, _this,_var);
      _readExternal(other);
    }
View Full Code Here

    }
  }

  public void writeExternal(ObjectOutput out) throws IOException {
    ComponentWrap cw = new ComponentWrap(Component.ACCESS_PRIVATE,this)
        Struct _this=new StructImpl();
    Struct _var=new StructImpl();
   
   
    // this scope (removing all UDFs)
    Object member;
      {
        Iterator<Entry<Key, Object>> it = cw.entryIterator();
          Entry<Key, Object> e;
          while(it.hasNext()) {
              e = it.next();
              member = e.getValue();
              if(member instanceof UDF)continue;
              _this.setEL(e.getKey(), member);
          }
    }
   
     
      // variables scope (removing all UDFs and key "this")
      {
          ComponentScope scope = getComponentScope();
          Iterator<Entry<Key, Object>> it = scope.entryIterator();
            Entry<Key, Object> e;
          Key k;
          while(it.hasNext()) {
            e = it.next();
            k = e.getKey();
                if(KeyConstants._THIS.equalsIgnoreCase(k))continue;
                member = e.getValue();
                if(member instanceof UDF)continue;
              _var.setEL(e.getKey(), member);
            }
        }
     
      out.writeUTF(getAbsName());
    out.writeUTF(ComponentUtil.md5(cw));
View Full Code Here

   */
  public static boolean isCastableToArray(Object o) {
        if(isArray(o)) return true;
        //else if(o instanceof XMLStruct) return true;
        else if(o instanceof Struct) {
            Struct sct=(Struct) o;
            Iterator<Key> it = sct.keyIterator();
            try {
                while(it.hasNext()) {
                  Caster.toIntValue(it.next().getString());
                }
                return true;
View Full Code Here

   * @param methodName Name of the Method to get
   * @param count wished count of arguments
   * @return matching Methods as Array
   */
  public synchronized Method[] getMethods(Class clazz,Collection.Key methodName, int count) {
    Struct methodsMap = map.get(clazz);
    if(methodsMap==null)
      methodsMap=store(clazz);
   
    Object o = methodsMap.get(methodName,null);
    if(o==null) return null;
    Array methods=(Array) o;
    o=methods.get(count+1,null);
    if(o==null) return null;
    return (Method[]) o;
View Full Code Here

TOP

Related Classes of railo.runtime.type.Struct

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.