/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (buf == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialBlob instance once free() has been called."); } }
/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (elements == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialArray instance once free() has been called."); } }
/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (buf == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialClob instance once free() has been called."); } }
/** * Constructs a new <code>SerialDatalink</code> object from the given * <code>java.net.URL</code> object. * <P> * @param url the {@code URL} to create the {@code SerialDataLink} from * @throws SerialException if url parameter is a null */ public SerialDatalink(URL url) throws SerialException { if (url == null) { throw new SerialException("Cannot serialize empty URL instance"); } this.url = url; }
/** * Returns a new URL that is a copy of this <code>SerialDatalink</code> * object. * * @return a copy of this <code>SerialDatalink</code> object as a * <code>URL</code> object in the Java programming language. * @throws SerialException if the <code>URL</code> object cannot be de-serialized */ public URL getDatalink() throws SerialException { URL aURL = null; try { aURL = new URL((this.url).toString()); } catch (java.net.MalformedURLException e) { throw new SerialException("MalformedURLException: " + e.getMessage()); } return aURL; }
/** * Returns an <code>Object</code> representing the SQL structured type * to which this <code>SerialRef</code> object refers. * * @return an object instance resolved from the Ref reference * @throws SerialException if an error is encountered in the reference * resolution */ public Object getObject() throws SerialException { if (reference != null) { try { return reference.getObject(); } catch (SQLException e) { throw new SerialException("SQLException: " + e.getMessage()); } } if (object != null) { return object; } throw new SerialException("The object is not set"); }
/** * Returns an <code>Object</code> representing the SQL structured type * to which this <code>SerialRef</code> object refers. The attributes * of the structured type are mapped according to the given type map. * * @param map a <code>java.util.Map</code> object containing zero or * more entries, with each entry consisting of 1) a <code>String</code> * giving the fully qualified name of a UDT and 2) the * <code>Class</code> object for the <code>SQLData</code> implementation * that defines how the UDT is to be mapped * @return an object instance resolved from the Ref reference and mapped * according to the supplied type map * @throws SerialException if an error is encountered in the reference * resolution */ public Object getObject(java.util.Map<String,Class<?>> map) throws SerialException { map = new Hashtable<String, Class<?>>(map); if (object != null) { return map.get(object); } else { throw new SerialException("The object is not set"); } }
@Override public Reader getCharacterStream() throws SerialException { throw new SerialException(); } };
/** * Sets the SQL structured type that this <code>SerialRef</code> object * references to the given <code>Object</code> object. * * @param obj an <code>Object</code> representing the SQL structured type * to be referenced * @throws SerialException if an error is encountered generating the * the structured type referenced by this <code>SerialRef</code> object */ public void setObject(Object obj) throws SerialException { try { reference.setObject(obj); } catch (SQLException e) { throw new SerialException("SQLException: " + e.getMessage()); } object = obj; }
/** * Retrieves a <code>ResultSet</code> object that contains all of * the elements in the <code>ARRAY</code> value that this * <code>SerialArray</code> object represents. * If appropriate, the elements of the array are mapped using the connection's * type map; otherwise, the standard mapping is used. * * @return a <code>ResultSet</code> object containing all of the * elements in this <code>SerialArray</code> object, with a * separate row for each element * @throws SerialException if called with the cause set to * {@code UnsupportedOperationException} */ public ResultSet getResultSet() throws SerialException { SerialException se = new SerialException(); se.initCause(new UnsupportedOperationException()); throw se; }
/** * Retrieves a <code>ResultSet</code> object holding the elements of * the subarray that starts at * index <i>index</i> and contains up to <i>count</i> successive elements. * This method uses the connection's type map to map the elements of * the array if the map contains * an entry for the base type. Otherwise, the standard mapping is used. * * @param index the index into this <code>SerialArray</code> object * of the first element to be copied; the index of the * first element in the array is <code>0</code> * @param count the number of consecutive elements to be copied, starting * at the given index * @return a <code>ResultSet</code> object containing the designated * elements in this <code>SerialArray</code> object, with a * separate row for each element * @throws SerialException if called with the cause set to * {@code UnsupportedOperationException} */ public ResultSet getResultSet(long index, int count) throws SerialException { SerialException se = new SerialException(); se.initCause(new UnsupportedOperationException()); throw se; }
isValid(); if (pos < 1 || pos > this.length()) { throw new SerialException("Invalid position in BLOB object set"); throw new SerialException("length is < 1 or pos + length >" + "total number of bytes");
/** * Truncates the <code>CLOB</code> value that this <code>SerialClob</code> * object represents so that it has a length of <code>len</code> * characters. * <p> * Truncating a <code>SerialClob</code> object to length 0 has the effect of * clearing its contents. * * @param length the length, in bytes, to which the <code>CLOB</code> * value should be truncated * @throws SerialException if there is an error accessing the * <code>CLOB</code> value; * if the {@code free} method had been previously called on this object */ public void truncate(long length) throws SerialException { isValid(); if (length > len) { throw new SerialException ("Length more than what can be truncated"); } else { len = length; // re-size the buffer if (len == 0) { buf = new char[] {}; } else { buf = (this.getSubString(1, (int)len)).toCharArray(); } } }
/** * Constructor for <code>SerialJavaObject</code> helper class. * <p> * * @param obj the Java <code>Object</code> to be serialized * @throws SerialException if the object is found not to be serializable */ public SerialJavaObject(Object obj) throws SerialException { // if any static fields are found, an exception // should be thrown // get Class. Object instance should always be available Class<?> c = obj.getClass(); // determine if object implements Serializable i/f if (!(obj instanceof java.io.Serializable)) { setWarning(new RowSetWarning("Warning, the object passed to the constructor does not implement Serializable")); } // can only determine public fields (obviously). If // any of these are static, this should invalidate // the action of attempting to persist these fields // in a serialized form fields = c.getFields(); if (hasStaticFields(fields)) { throw new SerialException("Located static fields in " + "object instance. Cannot serialize"); } this.obj = obj; }
throw new SerialException(e.getMessage());
/** * Truncates the <code>BLOB</code> value that this <code>Blob</code> * object represents to be <code>len</code> bytes in length. * * @param length the length, in bytes, to which the <code>BLOB</code> * value that this <code>Blob</code> object represents should be * truncated * @throws SerialException if there is an error accessing the Blob value; * or the length to truncate is greater that the SerialBlob length; * if {@code free} had previously been called on this object */ public void truncate(long length) throws SerialException { isValid(); if (length > len) { throw new SerialException ("Length more than what can be truncated"); } else if((int)length == 0) { buf = new byte[0]; len = length; } else { len = length; buf = this.getBytes(1, (int)len); } }
/** * Retrieves a stream to be used to write Ascii characters to the * <code>CLOB</code> value that this <code>SerialClob</code> object represents, * starting at position <code>pos</code>. This method forwards the * <code>setAsciiStream()</code> call to the underlying <code>Clob</code> object in * the event that this <code>SerialClob</code> object is instantiated with a * <code>Clob</code> object. If this <code>SerialClob</code> object is instantiated * with a <code>char</code> array, a <code>SerialException</code> object is thrown. * * @param pos the position at which to start writing to the * <code>CLOB</code> object * @return the stream to which ASCII encoded characters can be written * @throws SerialException if SerialClob is not instantiated with a * Clob object; * if the {@code free} method had been previously called on this object * @throws SQLException if there is an error accessing the * <code>CLOB</code> value * @see #getAsciiStream */ public java.io.OutputStream setAsciiStream(long pos) throws SerialException, SQLException { isValid(); if (this.clob != null) { return this.clob.setAsciiStream(pos); } else { throw new SerialException("Unsupported operation. SerialClob cannot " + "return a writable ascii stream\n unless instantiated with a Clob object " + "that has a setAsciiStream() implementation"); } }
/** * Retrieves the <code>CLOB</code> value designated by this <code>SerialClob</code> * object as an ascii stream. This method forwards the <code>getAsciiStream</code> * call to the underlying <code>Clob</code> object in the event that this * <code>SerialClob</code> object is instantiated with a <code>Clob</code> * object. If this <code>SerialClob</code> object is instantiated with * a <code>char</code> array, a <code>SerialException</code> object is thrown. * * @return a <code>java.io.InputStream</code> object containing * this <code>SerialClob</code> object's data * @throws SerialException if this {@code SerialClob} object was not * instantiated with a <code>Clob</code> object; * if {@code free} had previously been called on this object * @throws SQLException if there is an error accessing the * <code>CLOB</code> value represented by the <code>Clob</code> object * that was used to create this <code>SerialClob</code> object */ public java.io.InputStream getAsciiStream() throws SerialException, SQLException { isValid(); if (this.clob != null) { return this.clob.getAsciiStream(); } else { throw new SerialException("Unsupported operation. SerialClob cannot " + "return a the CLOB value as an ascii stream, unless instantiated " + "with a fully implemented Clob object."); } }
return this.clob.setCharacterStream(pos); } else { throw new SerialException("Unsupported operation. SerialClob cannot " + "return a writable character stream\n unless instantiated with a Clob object " + "that has a setCharacterStream implementation");
throw new SerialException(e.getMessage());