|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.core.value.BLOBFileValue
public class BLOBFileValue
BLOBFileValue represents a binary Value which is
backed by a resource or byte[]. Unlike BinaryValue it has no
state, i.e. the getStream() method always returns a fresh
InputStream instance.
javax.jcr.ValueFactory to create binary values.
| Field Summary | |
|---|---|
protected static String |
DEFAULT_ENCODING
the default encoding |
static int |
TYPE
the property type |
| Constructor Summary | |
|---|---|
BLOBFileValue(byte[] bytes)
Creates a new BLOBFileValue instance from a
byte[] array. |
|
BLOBFileValue(File file)
Creates a new BLOBFileValue instance from a File. |
|
BLOBFileValue(FileSystemResource fsResource)
Creates a new BLOBFileValue instance from a resource in the
virtual file system. |
|
BLOBFileValue(InputStream in)
Creates a new BLOBFileValue instance from an
InputStream. |
|
BLOBFileValue(InputStream in,
boolean temp)
Creates a new BLOBFileValue instance from an
InputStream. |
|
| Method Summary | |
|---|---|
void |
delete()
Deletes the persistent resource backing this BLOBFileValue. |
void |
delete(boolean pruneEmptyParentDirs)
Deletes the persistent resource backing this BLOBFileValue. |
void |
discard()
Frees temporarily allocated resources such as temporary file, buffer, etc. |
boolean |
equals(Object obj)
|
boolean |
getBoolean()
|
Calendar |
getDate()
|
double |
getDouble()
|
long |
getLength()
Returns the length of this BLOBFileValue. |
long |
getLong()
|
InputStream |
getStream()
|
String |
getString()
|
int |
getType()
|
int |
hashCode()
Returns zero to satisfy the Object equals/hashCode contract. |
void |
spool(OutputStream out)
Spools the contents of this BLOBFileValue to the given
output stream. |
String |
toString()
Returns a string representation of this BLOBFileValue
instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE
protected static final String DEFAULT_ENCODING
| Constructor Detail |
|---|
public BLOBFileValue(InputStream in)
throws IOException
BLOBFileValue instance from an
InputStream. The contents of the stream is spooled
to a temporary file or to a byte buffer if its size is smaller than
MAX_BUFFER_SIZE.
The new instance represents a temporary value whose dynamically
allocated resources will be freed explicitly on discard().
in - stream to be represented as a BLOBFileValue instance
IOException - if an error occurs while reading from the stream or
writing to the temporary file
public BLOBFileValue(InputStream in,
boolean temp)
throws IOException
BLOBFileValue instance from an
InputStream. The contents of the stream is spooled
to a temporary file or to a byte buffer if its size is smaller than
MAX_BUFFER_SIZE.
The temp parameter governs whether dynamically allocated
resources will be freed explicitly on discard(). Note that any
dynamically allocated resources (temp file/buffer) will be freed
implicitly once this instance has been gc'ed.
in - stream to be represented as a BLOBFileValue instancetemp - flag indicating whether this instance represents a
temporary value whose resources can be explicitly freed
on discard().
IOException - if an error occurs while reading from the stream or
writing to the temporary filepublic BLOBFileValue(byte[] bytes)
BLOBFileValue instance from a
byte[] array.
bytes - byte array to be represented as a BLOBFileValue
instance
public BLOBFileValue(File file)
throws IOException
BLOBFileValue instance from a File.
file - file to be represented as a BLOBFileValue instance
IOException - if the file can not be read
public BLOBFileValue(FileSystemResource fsResource)
throws IOException
BLOBFileValue instance from a resource in the
virtual file system.
fsResource - resource in virtual file system
IOException - if the resource can not be read| Method Detail |
|---|
public long getLength()
BLOBFileValue.
BLOBFileValue,
or -1L if the length can't be determined.public void discard()
BLOBFileValue is backed by a persistent resource
calling this method will have no effect.
delete(),
delete(boolean)public void delete()
BLOBFileValue.
Same as #delete(false).
If this BLOBFileValue is not backed by a persistent
resource calling this method will have no effect.
discard()public void delete(boolean pruneEmptyParentDirs)
BLOBFileValue.
pruneEmptyParentDirs - if true, empty parent directories
will automatically be deleted
public void spool(OutputStream out)
throws RepositoryException,
IOException
BLOBFileValue to the given
output stream.
out - output stream
RepositoryException - if the input stream for this
BLOBFileValue could not be obtained
IOException - if an error occurs while while spoolingpublic String toString()
BLOBFileValue
instance. The string representation of a resource backed value is
the path of the underlying resource. If this instance is backed by an
in-memory buffer the generic object string representation of the byte
array will be used instead.
toString in class ObjectBLOBFileValue instance.public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class ObjectObject.hashCode()public int getType()
getType in interface Value
public String getString()
throws ValueFormatException,
IllegalStateException,
RepositoryException
getString in interface ValueValueFormatException
IllegalStateException
RepositoryException
public InputStream getStream()
throws IllegalStateException,
RepositoryException
getStream in interface ValueIllegalStateException
RepositoryException
public double getDouble()
throws ValueFormatException,
IllegalStateException,
RepositoryException
getDouble in interface ValueValueFormatException
IllegalStateException
RepositoryException
public Calendar getDate()
throws ValueFormatException,
IllegalStateException,
RepositoryException
getDate in interface ValueValueFormatException
IllegalStateException
RepositoryException
public long getLong()
throws ValueFormatException,
IllegalStateException,
RepositoryException
getLong in interface ValueValueFormatException
IllegalStateException
RepositoryException
public boolean getBoolean()
throws ValueFormatException,
IllegalStateException,
RepositoryException
getBoolean in interface ValueValueFormatException
IllegalStateException
RepositoryException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||