⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultset.java

📁 招标投标网上系统
💻 JAVA
字号:
/*
 * @(#)ResultSet.java 
 *
 * Copyright 2003 by SYNTC, All rights reserved.
 *
 * This software is the confidential and proprietary information of SYNTC.
 * ("Confidential Information").
 */

package cn.com.syntc.common.type;

import java.util.LinkedList;
import java.util.Hashtable;
import java.io.ByteArrayInputStream;

/**
 * @title:        ResultSet <p>
 * @description:  the resultSet can store all kinds of db result from SqlStatementExecute<p>
 * @authority:    Copyright (c) <p>
 * @company:      SYNTC <p>
 * @author:       wang yong <p>
 * @version:      1.0 <p>
 */


public class ResultSet {

  private LinkedList resultSetList = null;
  private Hashtable targetRowTable = null;
  public int currentWatchRowNumber = 0;


  public ResultSet() {
    resultSetList = new LinkedList();
  }

  public void setRow(int rowNumber,String columnName,Object object){
    Hashtable targetRowTable;
    // This method add data set as row of database
    try{
      if(rowNumber > this.size()){
        //System.out.println("ResultSet new Row create(" + rowNumber + ")");
        targetRowTable = new Hashtable();
        targetRowTable.remove(columnName);
        targetRowTable.put(columnName,object);
        resultSetList.add(rowNumber-1,targetRowTable);
      } else {
        targetRowTable = (Hashtable)resultSetList.get(rowNumber-1);
        targetRowTable.remove(columnName);
        targetRowTable.put(columnName,object);
      }
    }catch(Exception e){
      // Error
    }
  }

  public Object getRow(int rowNumber,String columnName){
    Object object = null;
    try{
      // get Value of taget RowTable of target rowNum
      try{
        Hashtable targetRowTable = (Hashtable)resultSetList.get(rowNumber);
        object = targetRowTable.get(columnName);
      }catch(IndexOutOfBoundsException e){
        System.out.println("This row number(" + rowNumber + " is not exist");
      }catch(Exception e){
        System.out.println("Ooops! getRow unexpected Exception was catched");
      }
    }catch(Exception e){
      // Error
    }
    return object;
  }


  public int size(){
    int listRowSize = -1;
    try{
      listRowSize = resultSetList.size();
      //System.out.println("ResultSet size = " + listRowSize + "at size()");
    }catch(Exception e){
      // Error
    }
    return listRowSize;
  }
  public String getSize(){
    int listRowSize = -1;
    try{
      listRowSize = resultSetList.size();
      //System.out.println("ResultSet size = " + listRowSize + "at getSize()");
    }catch(Exception e){
      // Error
    }
    return Integer.toString(listRowSize);
  }


  public boolean next(){
    boolean isNextRowExist = false;
    try{
      if(currentWatchRowNumber >= this.size()){
        targetRowTable = null;
        isNextRowExist = false;
      } else {
        // set rowTable
        targetRowTable = (Hashtable)resultSetList.get(currentWatchRowNumber);
        currentWatchRowNumber++;
        isNextRowExist = true;
      }
    }catch(Exception e){
      // Error
    }
    return isNextRowExist;
  }
 
  public boolean isLast(){
    boolean isLast = false;
    try{
      if(currentWatchRowNumber >= this.size()){
        isLast = true;
      }
    }catch(Exception e){
      // Error
    }
    return isLast;
  }

  public void rewind(){
    currentWatchRowNumber = 0;
  }

  public int getInt(String columnName){
    int value = 0;
    try{
      value = ((Integer)targetRowTable.get(columnName.toUpperCase())).intValue();
    }catch(Exception e){
      // Error
    }
    return value;
  }

  public String getString(String columnName){
    String value = null;
    try{
      value = (String)targetRowTable.get(columnName.toUpperCase());
    }catch(Exception e){
      // Error
    }
    return value;
  }

  public java.sql.Date getDate(String columnName){
 
    java.sql.Date value = null;
    try{
      value = (java.sql.Date)targetRowTable.get(columnName.toUpperCase());
    }catch(Exception e){
      // Error
    }
    return value;
  }

  public ByteArrayInputStream getBlob(String columnName){
    ByteArrayInputStream value = null;
    try{
      value = (ByteArrayInputStream)targetRowTable.get(columnName.toUpperCase());
    }catch(Exception e){
      // Error
    }
    return value;
  }


  public void setResultSet(LinkedList list){
    // change another list( for test)
    resultSetList.clear();
    resultSetList = list;
  }
  /**
   * replace "" or null  to "<BR>"
   */
  public String outBr(String value){
    try{
      if(value == null)return "<BR>";
      if(value.equals(""))return "<BR>";
      return value;
    }catch(Exception e){
      // Error
      return value;
    }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -