Package railo.runtime.type

Examples of railo.runtime.type.Struct


* @return return a struct with all section an dkey list as value
* @throws IOException
*/
public static Struct getProfileSections(Resource file) throws IOException {
     IniFile ini=new IniFile(file);
     Struct rtn=new StructImpl(Struct.TYPE_SYNC);
     Map sections = ini.getSections();
     Iterator it = sections.keySet().iterator();
     while(it.hasNext()) {
         String strSection=(String) it.next();
         Map section = ini.getSectionEL(strSection);
         Iterator iit = section.keySet().iterator();
         StringBuilder sb=new StringBuilder();
         while(iit.hasNext()) {
             if(sb.length()!=0)sb.append(',');
             sb.append(iit.next());
         }
         rtn.setEL(strSection,sb.toString());
     }
     return rtn;
}
View Full Code Here


        used+=usage.getUsed();
        max+=usage.getMax();
        init+=usage.getInit();
      }
    }
    Struct sct=new StructImpl();
    sct.setEL(KeyConstants._used, Caster.toDouble(used));
    sct.setEL(KeyConstants._max, Caster.toDouble(max));
    sct.setEL(KeyConstants._init, Caster.toDouble(init));
    sct.setEL(KeyImpl.init("available"), Caster.toDouble(max-used));
    return sct;
  }
View Full Code Here

    Iterator<MemoryPoolMXBean> it = manager.iterator();
   
    MemoryPoolMXBean bean;
    MemoryUsage usage;
    MemoryType _type;
    Struct sct=new StructImpl();
    while(it.hasNext()){
      bean = it.next();
      usage = bean.getUsage();
      _type = bean.getType();
      if(type==MEMORY_TYPE_HEAP && _type!=MemoryType.HEAP)continue;
      if(type==MEMORY_TYPE_NON_HEAP && _type!=MemoryType.NON_HEAP)continue;
       
      double d=((int)(100D/usage.getMax()*usage.getUsed()))/100D;
      sct.setEL(KeyImpl.init(bean.getName()), Caster.toDouble(d));
    }
    return sct;
  }
View Full Code Here

 
 
 

    private static Struct toStruct(String propertyNames[], Object state[])  {
        Struct sct = CommonUtil.createStruct();
        if(state!=null && propertyNames!=null){
          for(int i = 0; i < propertyNames.length; i++) {
            sct.setEL(CommonUtil.createKey(propertyNames[i]), state[i]);
          }
      }
        return sct;
    }
View Full Code Here

         this.allEvents=allEvents;
         this.eventType=eventType;
    }
 
  protected boolean preUpdate(PreUpdateEvent event) {
    Struct oldData=CommonUtil.createStruct();
    Property[] properties = HibernateUtil.getProperties(component,HibernateUtil.FIELDTYPE_COLUMN,null);
    Object[] data = event.getOldState();
   
    if(data!=null && properties!=null && data.length==properties.length) {
      for(int i=0;i<data.length;i++){
        oldData.setEL(CommonUtil.createKey(properties[i].getName()), data[i]);
      }
    }
    invoke(CommonUtil.PRE_UPDATE, event.getEntity(),oldData);
    return false;
  }
View Full Code Here

    return namingStrategy;
  }
 
  public Struct getTableInfo(DatasourceConnection dc, String tableName) throws PageException {
    Collection.Key keyTableName=CommonUtil.createKey(tableName);
    Struct columnsInfo = (Struct) tableInfo.get(keyTableName,null);
    if(columnsInfo!=null) return columnsInfo;
   
    columnsInfo = HibernateUtil.checkTable(dc,tableName,this);
      tableInfo.setEL(keyTableName,columnsInfo);
      return columnsInfo;
View Full Code Here


  //
 
  public static Property[] createPropertiesFromTable(DatasourceConnection dc, String tableName) {
    Struct properties = CommonUtil.createStruct();
    try {
      DatabaseMetaData md = dc.getConnection().getMetaData();
      String dbName=DataSourceUtil.getDatabaseName(dc);
      Collection.Key name;
     
     
      // get all columns
      ResultSet res = md.getColumns(dbName, null, tableName, null);
      while(res.next()) {
        name=CommonUtil.createKey(res.getString("COLUMN_NAME"));
        properties.setEL(
            name,
            CommonUtil.createProperty(name.getString(),res.getString("TYPE_NAME")));
      }
     
      // ids
      res = md.getPrimaryKeys(null, null, tableName);
      Property p;
      while(res.next()) {
        name=CommonUtil.createKey(res.getString("COLUMN_NAME"));
        p=(Property) properties.get(name,null);
        if(p!=null) p.getDynamicAttributes().setEL(CommonUtil.FIELDTYPE, "id");
      }
     
      // MUST foreign-key relation
   
    }
    catch(Throwable t){
      return new Property[0];
    }
   
    Iterator<Object> it = properties.valueIterator();
    Property[] rtn=new Property[properties.size()];
    for(int i=0;i<rtn.length;i++){
      rtn[i]=(Property) it.next();
    }
   
      return rtn;
View Full Code Here

  public static Struct checkTable(DatasourceConnection dc, String tableName, SessionFactoryData data) throws PageException {
   
    try {
      String dbName=DataSourceUtil.getDatabaseName(dc);
      DatabaseMetaData md = dc.getConnection().getMetaData();
      Struct rows=checkTableFill(md,dbName,tableName);
      if(rows.size()==0)  {
        String tableName2 = checkTableValidate(md,dbName,tableName);
        if(tableName2!=null)rows=checkTableFill(md,dbName,tableName2);
      }
     
      if(rows.size()==0)  {
        //ORMUtil.printError("there is no table with name  ["+tableName+"] defined", engine);
        return null;
      }
      return rows;
    } catch (SQLException e) {
View Full Code Here

  }
 


  private static Struct checkTableFill(DatabaseMetaData md, String dbName, String tableName) throws SQLException, PageException {
    Struct rows=new CastableStruct(tableName,Struct.TYPE_LINKED);
    ResultSet columns = md.getColumns(dbName, null, tableName, null);
    //print.o(new QueryImpl(columns,""));
    try{
      String name;
      Object nullable;
      while(columns.next()) {
        name=columns.getString("COLUMN_NAME");
       
        nullable=columns.getObject("IS_NULLABLE");
        rows.setEL(CommonUtil.createKey(name),new ColumnInfo(
            name,
            columns.getInt("DATA_TYPE"),
            columns.getString("TYPE_NAME"),
            columns.getInt("COLUMN_SIZE"),
            CommonUtil.toBooleanValue(nullable
View Full Code Here

    try {
      name=CommonUtil.toString(HibernateUtil.getMetaStructItem(cfc,CommonUtil.ENTITY_NAME),null);
    }
    catch (Throwable t) {
      try {
        Struct md = cfc.getMetaData(CommonUtil.pc());
        name = CommonUtil.toString(md.get(CommonUtil.ENTITY_NAME),null);
       
      }catch (PageException e) {}
    }
   
    if(!Util.isEmpty(name)) {
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.