planetj.database.field
Class BlobField

java.lang.Object
  |
  +--planetj.database.Field
        |
        +--planetj.database.field.BlobField
All Implemented Interfaces:
Blob, Cloneable, ICSVField, IExternallyNamed, IFDFObject, IGuarded, INamed, IXMLObject, Serializable

public class BlobField
extends Field
implements Cloneable, Serializable, Blob

Author:
PlanetJ Corporation
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class planetj.database.Field
Field.FieldLocation
 
Field Summary
 
Fields inherited from interface planetj.dataengine.security.IGuarded
TYPE_ID_UNKNOWN, TYPE_NAME_FIELD, TYPE_NAME_SQLOPERATION, TYPE_SECURED_BY_LEVEL, TYPE_SECURED_BY_OPERATION, TYPE_UNSECURED
 
Constructor Summary
BlobField()
           
 
Method Summary
 Object createObject(String pStringValue)
          Create an object for this Field type using the given String.
 InputStream getBinaryStream()
          Retrieves the BLOB designated by this Blob instance as a stream.
 byte[] getBytes()
           
 byte[] getBytes(long pos, int length)
          Returns as an array of bytes part or all of the BLOB value that this Blob object designates.
 Object getCopiedValue()
          Gets an independent copy of this field's value.
 String getDefaultDatabaseValue()
          Subclass must override this method and return a default value to be placed in the database when this field is Non-nullable and not required.
 String getSQLValue(boolean pUseOriginalValue)
          Returns the Field's value in SQL format.
 boolean getValueAsBoolean()
          Subclasses must override this to determine what their boolean value is.
 boolean isValueEqual(Object obj)
          Return a boolean indicating if the passed in Object is equal to this Fields value.
 boolean isValueGreaterThan(Object obj)
          Returns a boolean indicating if this field is greater than the supplied object.
 boolean isValueLessThan(Object obj)
          Returns a boolean indicating if this field is less then the supplied object.
 long length()
          Returns the number of bytes in the BLOB value designated by this Blob object.
 long position(Blob pattern, long start)
          Determines the byte position in the BLOB value designated by this Blob object at which pattern begins.
 long position(byte[] pattern, long start)
          Determines the byte position at which the specified byte pattern begins within the BLOB value that this Blob object represents.
 void setValue(Object pValue)
          Sets the current value of the Field to the specified value, and also sets the old value to the previous value.
 
Methods inherited from class planetj.database.Field
addFieldClassForDataClass, addPropertyChangeListener, appendSQLColumnDefinition, appendSQLNameAndValue, appendSQLNameAndValue, clearValidationExceptions, cloneField, commitValue, concat, create, create, createFromDataType, divide, equals, executeGetterMethod, executeSetterMethod, getAssociationOperation, getAttribute, getAutoUpdateValue, getColumnSpan, getConfigProperty, getCSVField, getCurrentValue, getCurrentValueAsString, getDataSQLOperation, getDate, getDefaultExternalName, getDefaultUsageId, getDefaultValue, getDisplayHeight, getDisplayLength, getDisplayOrder, getDisplayValue, getDisplayWidth, getExternalName, getExternalValidationKey, getFDFData, getFieldClassForDataClass, getFieldDescriptor, getFieldDescriptorSource, getFieldIncrementor, getIndex, getLibrary, getLibraryName, getMaxLength, getMaxLength, getMetaDataSystemAlias, getName, getOldValue, getOldValueAsString, getPossibleValues, getPossibleValues, getPreferredDisplayLength, getPreferredJavaDataType, getRow, getSecuredTypeId, getSecuredTypeName, getSecurityType, getSQLColumnDefinition, getSQLColumnDefinition, getSQLNameAndDefaultValue, getSQLNameAndValue, getSQLNameAndValue, getSQLObject, getSQLType, getSQLType, getSQLTypeName, getSQLTypeName, getSQLValue, getSQLValue, getStaticAttribute, getStyleClass, getStyleClass, getSystem, getSystemAlias, getSystemURL, getTable, getTableName, getValidationExceptions, getValidationInvalidLengthString, getValidationInvalidMinLengthString, getValidationInvalidValueString, getValidationInvalidValueString, getValidationRequiredString, getValidValuesString, getValue, getValueAsByte, getValueAsDate, getValueAsDouble, getValueAsFloat, getValueAsFullLengthString, getValueAsInt, getValueAsLong, getValueAsNumber, getValueAsShort, getValueAsString, getXMLData, getXMLTag, guessFieldClassProbability, handlePossibleValueOperation, hasMultipleStyleClasses, hasOldValue, hasPossibleValuesKeyClassOrOp, hasPossibleValuesSQLOperation, hasPossibleValuesSQLOperation, hasValue, isApplicable, isAuthorizedForEdit, isAuthorizedForRead, isAutoUpdateValue, isBoolean, isChanged, isContainsValue, isCurrentValueField, isCurrentValueString, isDate, isDecimalSQLType, isDecimalSQLType, isDefaultValue, isDerived, isDisplayable, isFieldContentDisplayable, isFieldValueDatabaseDefault, isFieldValueNotBlank, isFieldValueNull, isFileUpload, isGuarded, isHelpTextPresent, isInitialized, isNumeric, isNumericSQLType, isNumericSQLType, isPassword, isPhysical, isPossibleValuesSearch, isReadOnly, isReadOnly, isRequired, isRequired, isRequiredOnSearch, isSkeleton, isString, isStringSQLType, isStringSQLType, isTime, isUpdateable, isValidationRequiredForAutoPopulate, isValidLength, isValidLength, isValidMinLength, isValidRequired, isValidRequired, isValidValue, isValidValue, isValueEqualToString, lessThan, removePropertyChangeListener, rollbackChanges, setAttribute, setChanged, setClonedValues, setDate, setFieldContentDisplayable, setFieldDescriptor, setInitialValue, setInitialValueAsString, setMaxLength, setName, setRow, setSavepoint, setSQLType, setSQLTypeName, setStaticAttribute, setTable, setValue, setValue, setValueAsString, setValueToDefault, toString, toUpperCase, validate, validate, validate
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Blob
setBinaryStream, setBytes, setBytes, truncate
 

Constructor Detail

BlobField

public BlobField()
Method Detail

createObject

public Object createObject(String pStringValue)
                    throws CMException
Create an object for this Field type using the given String.

Specified by:
createObject in class Field
Parameters:
pStringValue - String
CMException

getBinaryStream

public InputStream getBinaryStream()
                            throws SQLException
Retrieves the BLOB designated by this Blob instance as a stream.

Specified by:
getBinaryStream in interface Blob
Returns:
a stream containing the BLOB data
Throws:
SQLException - if there is an error accessing the BLOB

getBytes

public byte[] getBytes()

getBytes

public byte[] getBytes(long pos,
                       int length)
                throws SQLException
Returns as an array of bytes part or all of the BLOB value that this Blob object designates. The byte array contains up to length consecutive bytes starting at position pos.

Specified by:
getBytes in interface Blob
Parameters:
pos - the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
length - is the number of consecutive bytes to be copied
Returns:
a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos.
Throws:
SQLException - if there is an error accessing the BLOB

getCopiedValue

public Object getCopiedValue()
Gets an independent copy of this field's value. If the value is immutable, then this method can simply return the value. Otherwise, a clone of the value should be returned.

Specified by:
getCopiedValue in class Field

getDefaultDatabaseValue

public String getDefaultDatabaseValue()
                               throws CMException
Subclass must override this method and return a default value to be placed in the database when this field is Non-nullable and not required.

Example: A SS# is not required to be filled in by users, but the database does not allow nulls in that field. SocialSecurityField must override this method and return a default value like -1; Creation date: (5/29/2003 7:12:45 AM)

Specified by:
getDefaultDatabaseValue in class Field
CMException

getSQLValue

public String getSQLValue(boolean pUseOriginalValue)
                   throws CMException
Returns the Field's value in SQL format. For example, if this field's value is the number 3 then the String "3" is returned. If this field's value is the String "Hello" then the String "'Hello'" is returned.

Specified by:
getSQLValue in class Field
Parameters:
pUseOriginalValue - If this is true then the value used will be this field's original value as it was read from the database. Otherwise its current value is used.
CMException

getValueAsBoolean

public boolean getValueAsBoolean()
Subclasses must override this to determine what their boolean value is. Returns a primitive that represents the value in the specified field.

Specified by:
getValueAsBoolean in class Field
Returns:
boolean

isValueEqual

public boolean isValueEqual(Object obj)
Return a boolean indicating if the passed in Object is equal to this Fields value.

Specified by:
isValueEqual in class Field

isValueGreaterThan

public boolean isValueGreaterThan(Object obj)
Returns a boolean indicating if this field is greater than the supplied object. the Row the Field belongs to. Subclasses should override and implement as appropriate.

Specified by:
isValueGreaterThan in class Field
Returns:
boolean

isValueLessThan

public boolean isValueLessThan(Object obj)
Returns a boolean indicating if this field is less then the supplied object. the Row the Field belongs to. Subclasses should override and return the appropriate response.

Specified by:
isValueLessThan in class Field
Returns:
boolean

length

public long length()
            throws SQLException
Returns the number of bytes in the BLOB value designated by this Blob object.

Specified by:
length in interface Blob
Returns:
length of the BLOB in bytes
Throws:
SQLException - if there is an error accessing the length of the BLOB

position

public long position(byte[] pattern,
                     long start)
              throws SQLException
Determines the byte position at which the specified byte pattern begins within the BLOB value that this Blob object represents. The search for patternstart.

Specified by:
position in interface Blob
Parameters:
pattern - the byte array for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the pattern appears, else -1.
Throws:
SQLException - if there is an error accessing the BLOB

position

public long position(Blob pattern,
                     long start)
              throws SQLException
Determines the byte position in the BLOB value designated by this Blob object at which pattern begins. The search begins at position start.

Specified by:
position in interface Blob
Parameters:
pattern - the Blob object designating the BLOB value for which to search
start - the position in the BLOB value at which to begin searching; the first position is 1
Returns:
the position at which the pattern begins, else -1
Throws:
SQLException - if there is an error accessing the BLOB

setValue

public void setValue(Object pValue)
              throws CMException
Sets the current value of the Field to the specified value, and also sets the old value to the previous value. If called and the Field is not updatable a CMException is thrown.

Overrides:
setValue in class Field
CMException