public int hashCode() { int hashCode = ArrayUtil.computeHashCode(array); hashCode = (31 * hashCode) + baseType; if(null != sqlTypeName) hashCode = (31 * hashCode) + sqlTypeName.hashCode(); hashCode = (31 * hashCode) + (wasFreeCalled ? 31 : 62); return hashCode; }
public void write(int byteValue) throws IOException { byte[] bytes = new byte[] {(byte)byteValue}; ArrayUtil.addBytesToList(bytes, blobData, index); index++; } }
public MockArray(Object array) { this.array = ArrayUtil.convertToArray(array); }
public long position(byte[] pattern, long start) throws SQLException { if(wasFreeCalled) { throw new SQLException("free() was called"); } byte[] data = ArrayUtil.getByteArrayFromList(blobData); int index = ArrayUtil.indexOf(data, pattern, (int)(start - 1)); if(-1 != index) index += 1; return index; }
/** * Returns a byte array containing the bytes from the <code>List</code>. * The <code>List</code> must contain <code>Byte</code> objects. * <code>null</code> entries in the <code>List</code> are * allowed, the resulting byte will be 0. * @param data the <code>List</code> * @return the resulting byte array */ public static byte[] getByteArrayFromList(List data) { return getByteArrayFromList(data, 0); }
public boolean equals(Object obj) { if(null == obj) return false; if(!obj.getClass().equals(this.getClass())) return false; MockArray other = (MockArray)obj; if(baseType != other.baseType) return false; if(null == sqlTypeName && null != other.sqlTypeName) return false; if(null != sqlTypeName && !sqlTypeName.equals(other.sqlTypeName)) return false; if(wasFreeCalled != other.wasFreeCalled()) return false; return ArrayUtil.areArraysEqual(array, other.array); }
/** * Returns a truncated copy of <i>sourceArray</i>. <i>len</i> * entries are copied. * @param sourceArray the source array * @param len the truncate length * @return the truncated array * @throws IllegalArgumentException if the specified object * is not an array (either of reference or primitive * component type) */ public static Object truncateArray(Object sourceArray, int len) { return truncateArray(sourceArray, 0, len); }
public ResultSet getResultSet(long index, int count) throws SQLException { if(wasFreeCalled) { throw new SQLException("free() was called"); } Integer[] firstColumn = new Integer[count]; for(int ii = 0; ii < count; ii++) { firstColumn[ii] = new Integer(ii + 1); } Object[] secondColumn = ArrayUtil.convertToObjectArray(array); secondColumn = (Object[])ArrayUtil.truncateArray(secondColumn, (int)(index - 1), count); MockResultSet resultSet = new MockResultSet(String.valueOf(hashCode())); resultSet.setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); resultSet.setResultSetConcurrency(ResultSet.CONCUR_READ_ONLY); resultSet.addColumn(firstColumn); resultSet.addColumn(secondColumn); return resultSet; }
public MockUpdateCountArrayWrapper(int[] updateCounts, Map parameters) { super(parameters); this.updateCounts = (Integer[])ArrayUtil.convertToObjectArray(updateCounts); }
public Object clone() { try { MockArray copy = (MockArray)super.clone(); copy.array = ArrayUtil.copyArray(array); return copy; } catch(CloneNotSupportedException exc) { throw new NestedApplicationException(exc); } } }
public MockBlob(byte[] data) { blobData = ArrayUtil.getListFromByteArray(data); wasFreeCalled = false; }
/** * Returns the index of the first occurence of the * array <i>bytes</i> in the array <i>source</i>. * @param source the array in which to search * @param bytes the array to search * @return the index of the first occurence or * -1, if <i>source</i> does not contain <i>bytes</i> */ public static int indexOf(byte[] source, byte[] bytes) { return indexOf(source, bytes, 0); }
/** * Returns a byte array containing the bytes from the <code>List</code>. * The <code>List</code> must contain <code>Byte</code> objects. * <code>null</code> entries in the <code>List</code> are * allowed, the resulting byte will be 0. * @param data the <code>List</code> * @return the resulting byte array */ public static byte[] getByteArrayFromList(List data) { return getByteArrayFromList(data, 0); }
public boolean equals(Object object) { if(!super.equals(object)) return false; MockStreamableByteArrayRecord other = (MockStreamableByteArrayRecord)object; return ArrayUtil.areArraysEqual(content, other.content); }
public long position(byte[] pattern, long start) throws SQLException { if(wasFreeCalled) { throw new SQLException("free() was called"); } byte[] data = ArrayUtil.getByteArrayFromList(blobData); int index = ArrayUtil.indexOf(data, pattern, (int)(start - 1)); if(-1 != index) index += 1; return index; }
/** * Returns a truncated copy of <i>sourceArray</i>. <i>len</i> * entries are copied. * @param sourceArray the source array * @param len the truncate length * @return the truncated array * @throws IllegalArgumentException if the specified object * is not an array (either of reference or primitive * component type) */ public static Object truncateArray(Object sourceArray, int len) { return truncateArray(sourceArray, 0, len); }
public ResultSet getResultSet(long index, int count) throws SQLException { if(wasFreeCalled) { throw new SQLException("free() was called"); } Integer[] firstColumn = new Integer[count]; for(int ii = 0; ii < count; ii++) { firstColumn[ii] = new Integer(ii + 1); } Object[] secondColumn = ArrayUtil.convertToObjectArray(array); secondColumn = (Object[])ArrayUtil.truncateArray(secondColumn, (int)(index - 1), count); MockResultSet resultSet = new MockResultSet(String.valueOf(hashCode())); resultSet.setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); resultSet.setResultSetConcurrency(ResultSet.CONCUR_READ_ONLY); resultSet.addColumn(firstColumn); resultSet.addColumn(secondColumn); return resultSet; }
public MockUpdateCountArrayWrapper(int[] updateCounts, Map parameters) { super(parameters); this.updateCounts = (Integer[])ArrayUtil.convertToObjectArray(updateCounts); }
public Object clone() { try { MockArray copy = (MockArray)super.clone(); copy.array = ArrayUtil.copyArray(array); return copy; } catch(CloneNotSupportedException exc) { throw new NestedApplicationException(exc); } } }
public MockBlob(byte[] data) { blobData = ArrayUtil.getListFromByteArray(data); wasFreeCalled = false; }