Package org.fto.jthink.lang

Examples of org.fto.jthink.lang.StringBuffered


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


  /**
   * 返回SQL语句串
   *
   */
  public StringBuffered getSQLStatement(){
    return sqlBuff!=null?sqlBuff:new StringBuffered(sql);
  }
View Full Code Here

   *
   * @return 条件串
   */
  public StringBuffered getConditionStatement(){
    Iterator conditionsIT = conditions.iterator();
    StringBuffered whereStr = new StringBuffered();
    while(conditionsIT.hasNext()){
      Object[] CondiItem = (Object[])conditionsIT.next();
      String logicOperator = (String)CondiItem[0];
      if(whereStr.length()==0){
        if(logicOperator.equals(AND) || logicOperator.equals(OR)){
          logicOperator = "";
        }else if(logicOperator.equals(AND_NOT) || logicOperator.equals(OR_NOT)){
          logicOperator = "NOT";
        }
      }
      logicOperator = (whereStr.length()==0 && (logicOperator.equals(AND) || logicOperator.equals(OR)))?"":logicOperator;
      if (CondiItem[1] instanceof ConditionItem) {
        ConditionItem item = (ConditionItem) CondiItem[1];
        whereStr.append(logicOperator).append(" ").append(item.getConditionItemStatement());
      }else{
        Condition condition = (Condition) CondiItem[1];
        StringBuffered subCondnStr = condition.getConditionStatement();
        if(subCondnStr.length()>0){
          whereStr.append(logicOperator).append(" (").append(subCondnStr).append(") ");
        }
      }
     
    }
View Full Code Here

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

    StringBuffered sqlStr = new StringBuffered(17)
      .append("SELECT ");
    ObjectBuffered values = null;//new ObjectBuffered();
   
    /* 生成limit串 */
    if (rowLen != -1) {
      sqlStr.append(" LIMIT ").append(startIndex).append(" ").append(rowLen).append(" ");
    }
   
    /* 生成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());
      ObjectBuffered objBuff = condition.getValueBuffered();
      if(values!=null){
        values.append(objBuff);
      }else{
        values = objBuff;
      }
    }
   
    /* 生成GROUP BY串 */
    if (groupby != null && groupby.length() != 0) {
      sqlStr.append(" GROUP BY ").append(groupby);
    }
   
    /* 生成ORDER BY串 */
    if (orderby != null && orderby.length() != 0) {
      sqlStr.append(" ORDER BY ").append(orderby);
    }
   
    return new SQL(SQL.SELECT, sqlStr, values, startIndex, rowLen);
  }
View Full Code Here

TOP

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

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.