Package org.fto.jthink.lang

Examples of org.fto.jthink.lang.ObjectBuffered


    }
    if(rowLen<0){
      throw new JThinkRuntimeException("rowLen不能小于0!");
    }

    ObjectBuffered values = null;   

    StringBuffered sqlStr = new StringBuffered(16)
      .append("SELECT ");

    /* 生成DISTINCT串 */
    if (distinct) {
      sqlStr.append(" DISTINCT ");
    }
   
    /* 生成TOP串 */
    if (rowLen != -1) {
      sqlStr.append(" TOP ").append((startIndex + rowLen)).append(" ");
    }
   
    /* 生成返回列的串 */
    if (columns != null && columns.length != 0) {
      SQL columnSQL = constructSelectedColumn(columns);
      sqlStr.append(columnSQL.getSQLStatement());
      values = columnSQL.getValueBuffered();
    }else{
      sqlStr.append("*");
    }

    /* 生成FROM子串, 如果tableName为空,将不构建FROM子句 */
    if (tableName != null && tableName.length() != 0) {
      sqlStr.append(" FROM ").append(tableName);
    }
   
    /* 生成查询条件串 */
    if (condition != null && condition.size() != 0) {
      sqlStr.append(" WHERE ").append(condition.getConditionStatement());
      if(values==null){
        values = condition.getValueBuffered();
      }else{
        values.append(condition.getValueBuffered());
      }
    }
   
    /* 生成GROUP BY串 */
    if (groupby != null && groupby.length() != 0) {
View Full Code Here


   * @return 描述此列的SQL语句
   *
   */
  public SQL getColumn(){
    StringBuffered column=null;
    ObjectBuffered values=null;
    if(columnValue instanceof java.lang.String){
      if(columnName==columnValue){
        return new SQL(SQL.UNDEFINED, columnName, null);
      }else{
        column = new StringBuffered(4).append("(").append(columnValue).append(") AS ").append(columnName);
View Full Code Here

          "The value of an columns cannot be empty.");
    }
    int size = columns.size();
    StringBuffered names = new StringBuffered(size*2);
    StringBuffered valueStatement = new StringBuffered(size);
    ObjectBuffered values  = new ObjectBuffered(size);
    Iterator columnsIT = columns.entrySet().iterator();
   
    for(int i=0;i<size;i++){
    //while(columnsIT.hasNext()){
      Map.Entry column = (Map.Entry)columnsIT.next();
      Object value = column.getValue();
      if(value!=null){
        if(values.size()==0){
          names.append(column.getKey());
          valueStatement.append("?");
        }else{
          names.append(",").append(column.getKey());
          valueStatement.append(",?");
        }
        values.append(value);
      };     
    }
    StringBuffered sql = new StringBuffered(5+names.size()+valueStatement.size())
      .append("INSERT INTO ")
      .append(tableName)
View Full Code Here

      throw new IllegalArgumentException(
          "The value of an columns cannot be empty.");
    }
    int columnsCapacity = columns.size();

    ObjectBuffered values  = new ObjectBuffered(columnsCapacity+1);
    StringBuffered sql = new StringBuffered(columnsCapacity+columnsCapacity+columnsCapacity+4)
    .append("UPDATE ")
    .append(tableName)
    .append(" SET ");

    /* 处理被更新的字段 */
    Iterator columnsIT = columns.entrySet().iterator();
    //while(columnsIT.hasNext()){
    for(int i=0;i<columnsCapacity;i++){
      Map.Entry column = (Map.Entry)columnsIT.next();
      Object value = column.getValue();
      int valuesSize = values.size();
      if(value==null){
        sql.append(valuesSize>0?",":"").append(column.getKey()).append("=NULL");
      }else{
        sql.append(valuesSize>0?",":"").append(column.getKey()).append("=?");
        values.append(value);
      }
    }
    /* 处理条件 */
    if(condition!=null && condition.size()!=0){
      sql.append(" WHERE ").append(condition.getConditionStatement());
      values.append(condition.getValueBuffered());
    }
    return new SQL(SQL.UPDATE, sql, values);
 
View Full Code Here

//      conditionStatementSize = conditionStatement.size();
//    }
   
    StringBuffered sqlStr = new StringBuffered(17)
      .append("SELECT ");
    ObjectBuffered values = null;//new ObjectBuffered();
   
    /* 生成DISTINCT串 */
    if (distinct) {
      sqlStr.append(" DISTINCT ");
    }
   
    /* 生成返回列的串 */
    if (columns != null && columns.length != 0) {
      SQL columnSQL = constructSelectedColumn(columns);
      sqlStr.append(columnSQL.getSQLStatement());
      values = columnSQL.getValueBuffered();
    }else{
      sqlStr.append("*");
    }

    /* 生成FROM子串, 如果tableName为空,将不构建FROM子句 */
    if (tableName != null && tableName.length() != 0) {
      sqlStr.append(" FROM ").append(tableName);
    }
   
    /* 生成查询条件串 */
    if (condition != null && condition.size() != 0) {
      sqlStr.append(" WHERE ").append(condition.getConditionStatement());
      if(values==null){
        values = condition.getValueBuffered();
      }else{
        values.append(condition.getValueBuffered());
      }
    }
   
    /* 生成GROUP BY串 */
    if (groupby != null && groupby.length() != 0) {
View Full Code Here

      case SQL.SELECT_SP:
        startIndex = sql.getRowStartIndex();
        length = sql.getRowLength();
        if(startIndex>=0 && length>=0){
          //List values = Arrays.asList(sql.getValues());
          ObjectBuffered values = sql.getValueBuffered();
          values.append(new Integer(startIndex));
          values.append(new Integer(length));
          return executeStoredProcedure(sql.getSQLString(), values.toArray(), doClazz);
        }else{
          return executeStoredProcedure(sql.getSQLString(), sql.getValues(), doClazz);
        }
      case SQL.UNDEFINED_SP:
        return executeStoredProcedure(sql.getSQLString(), sql.getValues(), doClazz);
View Full Code Here

          "The name of an table cannot be null.");
    }
    StringBuffered sqlstr = new StringBuffered(4)
      .append("DELETE FROM ")
      .append(tableName);
    ObjectBuffered values = null;
    if (condition != null && condition.size()>0) {
      sqlstr.append(" WHERE ").append(condition.getConditionStatement());
      values = condition.getValueBuffered();
    }
    return new SQL(SQL.UPDATE, sqlstr, values);
View Full Code Here

          "The name of an table cannot be null.");
    }
   
    StringBuffered sqlStr = new StringBuffered(11)
    .append("SELECT ");
    ObjectBuffered values = null;

    /* 生成DISTINCT串 */
    if (distinct) {
      sqlStr.append(" DISTINCT ");
    }
    /* 生成返回列的串 */
    if (columns != null && columns.length != 0) {
      SQL columnSQL = constructSelectedColumn(columns);
      sqlStr.append(columnSQL.getSQLStatement());
      values = columnSQL.getValueBuffered();
    }else{
      sqlStr.append("*");
    }
   
    /* 生成FROM子串, 如果tableName为空,将不构建FROM子句 */
    if (tableName != null && tableName.length() != 0) {
      sqlStr.append(" FROM ").append(tableName);
    }
   
    /* 生成查询条件串 */
    if (condition != null && condition.size() != 0) {
      sqlStr.append(" WHERE ")
            .append(condition.getConditionStatement());
      if(values==null){
        values = condition.getValueBuffered();
      }else{
        values.append(condition.getValueBuffered());
      }
    }
    /* 生成GROUP BY串 */
    if (groupby != null && groupby.length() != 0) {
      sqlStr.append(" GROUP BY ").append(groupby);
View Full Code Here

      String tableName, String fieldName, String attrName,Condition condition) {
    fieldName = fieldName==null?"*":fieldName;

    StringBuffered sqlstr = new StringBuffered(8)
      .append("SELECT COUNT(").append(fieldName).append(") AS ").append(attrName).append(" FROM ").append(tableName);
    ObjectBuffered values = null;
    if (condition != null && condition.size() != 0) {
      sqlstr.append(" WHERE ").append(condition.getConditionStatement());
      values = condition.getValueBuffered();
    }
    return new SQL(SQL.SELECT, sqlstr, values);
View Full Code Here

   * @return  描述列的SQL子语句
   */
  protected SQL constructSelectedColumn(Column[] columns){
    int len = columns.length;
    StringBuffered columnsStr = new StringBuffered(len);
    ObjectBuffered valuesLT = new ObjectBuffered(len+1);
    for(int i=0;i<len;i++){
      Column column = columns[i];
      columnsStr.append(i==0?"":",");
      if(column.isSimpleColumn()){
        columnsStr.append(column.getColumnName());
      }else{
        SQL columnSQL = column.getColumn();
        if(columnSQL.isStringBufferedType()){
          columnsStr.append(columnSQL.getSQLStatement());
        }else{
          columnsStr.append(columnSQL.getSQLString());
        }
       
        ObjectBuffered values = columnSQL.getValueBuffered();
        if(values!=null){
          valuesLT.append(values);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.fto.jthink.lang.ObjectBuffered

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.