public ClobInputStream(JDBCClobClient clob, long offset, long length, int blockSize) throws SQLException { if (!JDBCClobClient.isInLimits(clob.length(), offset, length)) { throw Util.outOfRangeArgument(); } this.clob = clob; this.availableLength = offset + length; this.currentPosition = offset; this.streamBlockSize = blockSize; }
private void readIntoBuffer() throws SQLException { long readLength = availableLength - currentPosition; if (readLength <= 0) {} if (readLength > streamBlockSize) { readLength = streamBlockSize; } buffer = clob.getChars(currentPosition, (int) readLength); bufferOffset = currentPosition; }
private void checkClosed() throws IOException { if (isClosed || clob.isClosed()) { throw new IOException(Error.getMessage(ErrorCode.BLOB_STREAM_IS_CLOSED)); } }
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; }