public class blob extends BinaryData implements LargeObject
BinaryData.RangeCheck
BaseDataType.Type, BaseDataType.WrapperHandler
Modifier and Type | Field and Description |
---|---|
private FieldReference |
fRef
The parent buffer field where this object was obtained by dereferenciation, if this is the case.
|
private static int |
MAX_SIZE
Maximum size of the blob
|
private java.sql.Blob |
sqlBlob
SQL BLOB object
|
private byte[] |
value
Backing data
|
unknown
Constructor and Description |
---|
blob()
Default constructor.
|
blob(BaseDataType value)
Constructor which initializes an instance from a POLY value.
|
blob(blob value)
Copy constructor.
|
blob(java.sql.Blob sqlBlob)
Constructor which is initialized from a database record.
|
blob(byte[] value)
Constructor which initializes an instance from the given data.
|
blob(memptr value)
Constructor which initializes an instance from a memptr object.
|
blob(raw value)
Constructor which initializes an instance from a raw object.
|
blob(java.lang.String def)
Constructor used for creating initial field from default
String . |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
asByteArray()
Return the entire contents of the current buffer as an array.
|
byte[] |
asByteArray(long pos,
long len)
Return all or some of the contents of the current buffer as an array.
|
void |
assign(blob value)
Assigns a blob value.
|
protected void |
deallocate()
Release any resources associated with the instance.
|
BaseDataType |
duplicate()
Does the same as standard
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException . |
protected void |
extendBytes(long len)
Helper to create a new byte array with the same contents as the given
byte array and the specified length.
|
protected long |
findNextNull(long pos)
Returns the next index position into the array which is the
null byte,
starting at a given index position. |
FieldReference |
getFieldReference()
Obtain the
FieldReference reference, if any. |
BaseDataType.Type |
getType()
Get the type
|
BaseDataType |
instantiateUnknown()
Creates a new instance of the same type that represents the
unknown value . |
protected long |
internalLength()
The actual size of the buffer (in bytes).
|
protected boolean |
isAutoExtend()
Determines if the array of binary data stored in an instance of this
class must be automatically extended in length when operations
write past the current length.
|
boolean |
isCharacterData()
Indicate whether this object manages character data (as opposed to binary data).
|
protected boolean |
isLengthLimited()
Determines if the array of binary data stored in an instance of this
class must be limited in length.
|
boolean |
isUninitialized()
Reports if this instance represents an uninitialized buffer.
|
protected long |
lengthLimit()
Determines the maximum length of the array of binary data stored in an
instance of this class.
|
protected byte |
readByte(long pos)
Read the byte at the given location.
|
protected byte[] |
readByteRange(long pos,
long len,
boolean endian)
Read the bytes at the given location.
|
void |
readData()
Read data from the SQL BLOB used to initialize this object.
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
protected void |
replaceContents(byte[] value)
Replace the entire contents of the current buffer with the given array.
|
void |
setFieldReference(FieldReference fr)
Sets the
FieldReference reference. |
BinaryData |
setLength(long len)
Sets the length of the buffer/array to a given length.
|
java.lang.String |
toString(java.lang.String fmt)
The function
STRING(blob-value, format) always generates error 11382 in OE. |
java.lang.String |
toStringExport()
Creates a string representation of the instance data using the 'export'
format.
|
java.lang.String |
toStringMessage()
Creates a string representation of the instance data in a form that is compatible with the
MESSAGE language statement. |
protected long |
visibleLength()
The length of the buffer as reported to P4GL application.
|
void |
write(boolean overlay,
byte[] data,
int offset,
boolean trim)
Write the given byte data into the data managed by this object, overwriting the data
that are at the given location, if any.
|
protected void |
writeByte(byte val,
long pos)
Write the byte into the given location.
|
protected void |
writeByteRange(byte[] data,
long pos,
long len,
boolean endian)
Write the bytes at the given location.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
assign, assign, assign, assign, clearUnknown, compareTo, defaultFormatString, genIndexError, genLimitedLengthError, genUninitializedError, getByte, getByte, getByteArray, getBytes, getBytes, getBytes, getBytes, getDouble, getDouble, getFloat, getFloat, getInt64, getInt64, getLong, getLong, getShort, getShort, getString, getString, getString, getString, getString, getString, getUnprocessedDouble, getUnsignedLong, getUnsignedLong, getUnsignedShort, getUnsignedShort, hashCode, isUnknown, length, length, lengthOf, reverseBytes, setByte, setByte, setByte, setByte, setBytes, setBytes, setDouble, setDouble, setDouble, setDouble, setFloat, setFloat, setFloat, setFloat, setInt64, setInt64, setInt64, setInt64, setLength, setLength, setLong, setLong, setLong, setLong, setShort, setShort, setShort, setShort, setString, setString, setString, setString, setString, setString, setString, setString, setString, setString, setString, setString, setUnknown, setUnsignedLong, setUnsignedLong, setUnsignedLong, setUnsignedLong, setUnsignedShort, setUnsignedShort, setUnsignedShort, setUnsignedShort
assign, assign, calcFormatLength, createProxy, createProxy, deepCopy, elementsOfType, equals, fallback, formatLength, fromTypeName, generateDefault, generateUnknown, getAssigner, getSize, getTypeName, incompatibleTypesOnConversion, initialize, initializeDefaultExtent, instantiateDefault, instantiateDefaultExtent, invalidInitializer, isAllKnown, isAllKnown, isAssignDirect, isIncompatibleTypesOnConversion, isProxy, isUnknownValue, maximum, minimum, notUnknownValue, sameType, val, variable
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
_getCodePage, binaryEquals, isUnknown, lengthOf, readBytes, readChars, write
private static final int MAX_SIZE
private byte[] value
private java.sql.Blob sqlBlob
private FieldReference fRef
public blob()
public blob(java.lang.String def)
String
.def
- default valuepublic blob(blob value)
value
- Blob to be copied.public blob(java.sql.Blob sqlBlob) throws java.sql.SQLException
sqlBlob
- SQL BLOB from which data is read.java.sql.SQLException
- if there is an error reading data.public blob(byte[] value)
value
- Data.public blob(memptr value)
value
- Pointer from which data is copied.public blob(raw value)
value
- Raw object from which data is copied.public blob(BaseDataType value)
value
- POLY value from which data is copied.public BaseDataType.Type getType()
getType
in class BaseDataType
public void readData() throws java.sql.SQLException
java.sql.SQLException
- if there is an error reading data.public boolean isCharacterData()
isCharacterData
in interface LargeObject
false
.public BinaryData setLength(long len)
This implementation is a no-op.
setLength
in class BinaryData
len
- New length of the buffer/array.public boolean isUninitialized()
unknown
is also different from being uninitialized.isUninitialized
in class BinaryData
true
if this instance is uninitialized.public BaseDataType duplicate()
BaseDataType
clone()
method but returns an
instance of BaseDataType
and doesn't throw the
CloneNotSupportedException
.duplicate
in class BaseDataType
This class is not undoable, so return a reference to this object.
public BaseDataType instantiateUnknown()
unknown value
.instantiateUnknown
in class BaseDataType
unknown value
.public java.lang.String toString(java.lang.String fmt)
STRING(blob-value, format)
always generates error 11382 in OE.toString
in class BaseDataType
fmt
- The format string to use.public java.lang.String toStringMessage()
MESSAGE
language statement. Regardless the instance represents the unknown
value or not,
a "?" character value will always be returned.toStringMessage
in interface LargeObject
toStringMessage
in class BaseDataType
public java.lang.String toStringExport()
unknown value
, a
'?' will be returned.toStringExport
in class BaseDataType
public byte[] asByteArray(long pos, long len)
asByteArray
in interface LargeObject
pos
- Starting offset position.len
- Length of range to return.unknown
or has an undefined size, then null
will be returned.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class BinaryData
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class BinaryData
in
- The input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.protected void deallocate()
deallocate
in class BinaryData
protected boolean isLengthLimited()
isLengthLimited
in class BinaryData
true
if the length must be limited.protected long lengthLimit()
lengthLimit
in class BinaryData
protected boolean isAutoExtend()
null
bytes.isAutoExtend
in class BinaryData
true
if the length must automatically extended.protected void extendBytes(long len)
This is safe to use on 0 length arrays.
This implementation is a no-op.
extendBytes
in class BinaryData
len
- The output array length.protected void replaceContents(byte[] value)
replaceContents
in class BinaryData
value
- The new contents.protected byte[] asByteArray()
asByteArray
in class BinaryData
unknown
, then null
will be returned.protected long internalLength()
internalLength
in class BinaryData
protected long visibleLength()
visibleLength
in class BinaryData
protected long findNextNull(long pos)
null
byte,
starting at a given index position.
This implementation is a no-op.
findNextNull
in class BinaryData
pos
- The 0-based index into the array at which to start searching.null
byte or the length
of the array if no null
byte exists. This implementation always
returns 0.protected byte readByte(long pos)
readByte
in class BinaryData
pos
- The 0-based index position at which to read the byte.protected void writeByte(byte val, long pos)
writeByte
in class BinaryData
val
- The byte to write.pos
- The 0-based index position at which to read the byte.protected byte[] readByteRange(long pos, long len, boolean endian)
readByteRange
in class BinaryData
pos
- The 0-based index position at which to read the bytes.len
- The number of bytes to read.endian
- true
to force the returned data to be ordered by the endian-ness of the
instance.protected void writeByteRange(byte[] data, long pos, long len, boolean endian)
This implementation is a no-op.
writeByteRange
in class BinaryData
data
- The bytes to write.pos
- The 0-based index position at which to start writing the bytes.len
- How many bytes should be written. -1 means write everything to the end of the
array.endian
- true
to honor the endian-ness of the instance. The data
array MUST be ordered in little-endian order if the endian flag is on.public void write(boolean overlay, byte[] data, int offset, boolean trim)
This implementation:
trim
option (i.e., any existing bytes beyond the end of the
write are left in place if trim
is false
or truncated if trim
is true
);write
in interface LargeObject
overlay
- Flag indicating if the OVERLAY option is used.data
- Data to be assigned to this object.offset
- Offset position (in characters) in the target large object.trim
- true
to truncate any remaining data in the target large object; false
to leave remaining data alone.public void assign(blob value)
value
- Value to assign.public void setFieldReference(FieldReference fr)
FieldReference
reference. This is only used when the object is obtained by a
dereferenciation (::
) operation.setFieldReference
in interface LargeObject
fr
- The source of this LOB.public FieldReference getFieldReference()
FieldReference
reference, if any.getFieldReference
in interface LargeObject
FieldReference
from which this LOB was obtained by dereferenciation.