|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.io.BinaryData
public class BinaryData
allows to keep an instance that will produce an InputStream on demand
while supporting serialization of the same.
If a URL is set as the source, only the URL is serialized;
if an SQLValueRetriever is used, only the same is serialized;
in any other case, a byte array is generated and serialized.
Placeholder,
ImageHolder,
Serialized Form| Constructor Summary | |
|---|---|
BinaryData()
|
|
BinaryData(byte[] array)
|
|
BinaryData(Connection con,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
|
|
BinaryData(Connection con,
String table,
String keyColumn,
String keyValue,
String dataColumn)
|
|
BinaryData(DBClassStore<?> store,
Object keyValue,
String dataColumn)
|
|
BinaryData(File file)
serialized versions will store the entire stream and not a reference to the file. |
|
BinaryData(InputStream in)
|
|
BinaryData(SQLValueRetriever sr)
|
|
BinaryData(URL url)
|
|
BinaryData(ValueRetriever<Connection> conRetriever,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
|
|
BinaryData(ValueRetriever<InputStream> retriever)
|
|
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
|
void |
addVetoableChangeListener(VetoableChangeListener listener)
|
BinaryData |
cacheInFile(File file,
boolean serializeAsURL)
note that the caller has to take care that the given file is later deleted when it's not used anymore |
BinaryData |
convertToByteArray()
replaces the existing retriever with one that holds the relevant data in-memory as byte array. |
static ValueRetriever<InputStream> |
createRetriever(ValueRetriever<Connection> conRetriever,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
allows to easily retrieve binary data from a specific database entry |
InputStream |
getInputStream()
same as getRelevantValue() |
URL |
getInternalURL()
|
PropertyChangeListener[] |
getPropertyChangeListeners()
|
Reader |
getReader()
|
Reader |
getReader(String charset)
|
InputStream |
getRelevantValue()
returns the relevant value for this instance at the time of calling |
VetoableChangeListener[] |
getVetoableChangeListeners()
|
boolean |
isBasedOnURL()
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
|
void |
removeVetoableChangeListener(VetoableChangeListener listener)
|
void |
setData(byte[] array)
|
void |
setDatabaseValue(SQLValueRetriever dbdata)
on serialization, only the given parameter is serialized |
void |
setRelevantValue(ValueRetriever<InputStream> retriever)
sets the relevant value for this instance with the given value |
void |
setRetriever(ValueRetriever<InputStream> retriever)
|
void |
setURL(URL url)
on serialization, only the URL is serialized |
void |
setValue(InputStream in)
requires that the entire stream fits into memory |
void |
storeTo(File file)
|
byte[] |
toByteArray()
|
ValueRetriever<InputStream> |
unwrap()
returns the embedded instance that this wrapper encloses |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BinaryData()
public BinaryData(byte[] array)
public BinaryData(InputStream in)
public BinaryData(URL url)
public BinaryData(SQLValueRetriever sr)
public BinaryData(File file)
BinaryData(URL) instead.
public BinaryData(Connection con,
String table,
String keyColumn,
String keyValue,
String dataColumn)
BinaryData(ValueRetriever, String, String, Object, String, DBTransaction)
public BinaryData(Connection con,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
BinaryData(ValueRetriever, String, String, Object, String, DBTransaction)
public BinaryData(ValueRetriever<Connection> conRetriever,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
createRetriever(ValueRetriever, String, String, Object, String, DBTransaction)
public BinaryData(DBClassStore<?> store,
Object keyValue,
String dataColumn)
public BinaryData(ValueRetriever<InputStream> retriever)
| Method Detail |
|---|
public static ValueRetriever<InputStream> createRetriever(ValueRetriever<Connection> conRetriever,
String table,
String keyColumn,
Object keyValue,
String dataColumn,
DBTransaction tx)
conRetriever - the retriever for the database connectiontable - the table from which the data is to be retrievedkeyColumn - specifies the column that identifies the row that is to be selectedkeyValue - the value of the id column that specifies the row to be selecteddataColumn - the column that contains the binary datatx - if non-null, the data is retrieved within a transactional context
public BinaryData convertToByteArray()
throws IOException,
OutOfMemoryError
OutOfMemoryError if the data is too big
IOException
OutOfMemoryError
public byte[] toByteArray()
throws IOException
IOException
public BinaryData cacheInFile(File file,
boolean serializeAsURL)
throws IOException
IOException
public void storeTo(File file)
throws IOException
IOExceptionpublic void setData(byte[] array)
public void setDatabaseValue(SQLValueRetriever dbdata)
public void setURL(URL url)
public boolean isBasedOnURL()
public URL getInternalURL()
throws OptionNotAvailableWarning
OptionNotAvailableWarning
public final void setRetriever(ValueRetriever<InputStream> retriever)
throws IllegalArgumentException
IllegalArgumentException - if a VetoableChangeListener
is throwing a PropertyVetoException
public void setValue(InputStream in)
throws IOException,
OutOfMemoryError
IOException
OutOfMemoryErrorpublic final void setRelevantValue(ValueRetriever<InputStream> retriever)
ValueSetter
setRelevantValue in interface ValueSetter<ValueRetriever<InputStream>>public void addPropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public PropertyChangeListener[] getPropertyChangeListeners()
public void addVetoableChangeListener(VetoableChangeListener listener)
public void removeVetoableChangeListener(VetoableChangeListener listener)
public VetoableChangeListener[] getVetoableChangeListeners()
public ValueRetriever<InputStream> unwrap()
Wrapped
unwrap in interface Wrapped<ValueRetriever<InputStream>>
public final InputStream getRelevantValue()
throws IOException
ValueRetriever
getRelevantValue in interface ValueRetriever<InputStream>IOException - if any resource to fulfill the request is not accessible
public InputStream getInputStream()
throws IOException
IOException
public Reader getReader()
throws IOException
IOException
public Reader getReader(String charset)
throws IOException
IOException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||