public static ResultMetaData newGeneratedColumnsMetaData(
      int[] columnIndexes, String[] columnNames) {

    if (columnIndexes != null) {
      ResultMetaData md = new ResultMetaData(GENERATED_INDEX_METADATA);

      md.columnCount = columnIndexes.length;
      md.extendedColumnCount = columnIndexes.length;
      md.colIndexes = new int[columnIndexes.length];

      for (int i = 0; i < columnIndexes.length; i++) {
        md.colIndexes[i] = columnIndexes[i] - 1;
      }

      return md;
    } else if (columnNames != null) {
      ResultMetaData md = new ResultMetaData(GENERATED_NAME_METADATA);

      md.columnLabels = new String[columnNames.length];
      md.columnCount = columnNames.length;
      md.extendedColumnCount = columnNames.length;
      md.columnLabels = columnNames;

      return md;
    } else {
      return null;
    }
  }
  public static ResultMetaData newResultMetaData(
      Type[] types, int[] baseColumnIndexes, int colCount, int extColCount) {

    ResultMetaData md = new ResultMetaData(RESULT_METADATA);

    md.columnLabels = new String[colCount];
    md.columns = new ColumnBase[colCount];
    md.columnTypes = types;
    md.colIndexes = baseColumnIndexes;
    md.columnCount = colCount;
    md.extendedColumnCount = extColCount;

    return md;
  }
示例#3
0
  private Result newColumnResult(long position, int count) throws SQLException {

    int mArraySize = 0;
    String mArrayStruct = data.getTypeStructure();
    ArrayList<Integer> dimSize = getDimSize(mArrayStruct);
    ArrayList<Integer> iterIndex = new ArrayList<>(); // go through all the array values

    for (int i = 0; i < dimSize.size(); i++) {
      mArraySize += dimSize.get(i);
    }

    // tests if the required elements exist. The limits are determined
    // by computing the product of each dimension's size
    if (!JDBCClobClient.isInLimits(mArraySize, position, count)) {
      throw JDBCUtil.outOfRangeArgument();
    }

    Type[] types = new Type[2];

    types[0] = Type.SQL_VARCHAR;
    types[1] = elementType;

    ResultMetaData meta = ResultMetaData.newSimpleResultMetaData(types);

    meta.columnLabels = new String[] {"C1", "C2"};
    meta.colIndexes = new int[] {-1, -1};
    meta.columns = new ColumnBase[2];

    ColumnBase column = new ColumnBase("", "", "", "");

    column.setType(types[0]);

    meta.columns[0] = column;
    column = new ColumnBase("", "", "", "");

    column.setType(types[1]);

    meta.columns[1] = column;

    RowSetNavigatorClient navigator = new RowSetNavigatorClient();

    for (int i = (int) position; i < position + count; i++) {
      Object[] rowData = new Object[2];

      rowData[0] = Integer.valueOf(i + 1);
      try {
        rowData[1] = data.getCell(new RasPoint(1, 1));
      } catch (RasDimensionMismatchException | RasIndexOutOfBoundsException e) {
        System.err.println("Can't get the cell at point (1, 1)");
        e.printStackTrace();
      }

      navigator.add(rowData);
    }

    Result result = Result.newDataResult(meta);

    result.setNavigator(navigator);

    return result;
  }