public class ApplicationResourceManager extends Object
ApplicationResource
s, can load and store the
resources at any time.ApplicationResource
s are organized in a Map
. Each
resource is associated with a unique key. This key is used to determine, which
stream of bytes belongs to which resource. If data is loaded, the byte-streams
for missing resources will be stored in a buffer that is read as soon as
a missing resource is registered. Additional resources are ignored.Constructor and Description |
---|
ApplicationResourceManager() |
Modifier and Type | Method and Description |
---|---|
void |
put(String name,
ApplicationResource resource)
Stores a resource that might be read or written at any time.
|
void |
readArray(byte[] array)
Reads the contents of this manager from an array of bytes.
|
void |
readFile(File file)
Reads the contents of this manager from
file . |
void |
readPreferences()
Reads the content of this manager from the
Preferences that
represent the package of ApplicationResourceManager . |
void |
readStream(DataInputStream in)
Lets all
ApplicationResource s read from in . |
void |
readXML(XElement element)
Reads the contents of this manager from a xml element.
|
void |
remove(String name)
Removes a resources that was earlier added to this manager.
|
byte[] |
writeArray()
Writes the contents of this manager into an array of bytes.
|
void |
writeFile(File file)
Writes the contents of this manager into
file . |
void |
writePreferences()
Writes the contents of this manager into the
Preferences which
represent the package of ApplicationResourceManager . |
void |
writeStream(DataOutputStream out)
Writes all currently known
ApplicationResource s into
out . |
void |
writeXML(XElement element)
Writes the content of this manager in xml format.
|
public void put(String name, ApplicationResource resource) throws IOException
name
, then resource
will immediately
be asked to read the stream.name
- the unique identifier of the resourceresource
- the new resourceNullPointerException
- if name
of resource
is null
IOException
- if the buffered stream can't be read. The resource
will be stored in this manager even if an exception occurspublic void remove(String name)
name
- the name of the resource to removepublic void writeStream(DataOutputStream out) throws IOException
ApplicationResource
s into
out
.out
- the stream to write intoIOException
- if the operation can't be completedpublic void readStream(DataInputStream in) throws IOException
ApplicationResource
s read from in
.in
- the stream to read fromIOException
- if the operation can't be completedpublic void writeXML(XElement element)
element
- the element to write into, the attributes of this
element will not be changed.public void readXML(XElement element)
element
- the element to readpublic void writeFile(File file) throws IOException
file
.file
- the file to write intoIOException
- if the operation can't be completedpublic void readFile(File file) throws IOException
file
.file
- the file to readIOException
- if the operation can't be completedpublic byte[] writeArray() throws IOException
IOException
- if the operation can't be completedpublic void readArray(byte[] array) throws IOException
array
- the content as stream of bytesIOException
- if the operation can't be completedpublic void writePreferences() throws IOException
Preferences
which
represent the package of ApplicationResourceManager
.IOException
- if the operation can't be completedpublic void readPreferences() throws IOException
Preferences
that
represent the package of ApplicationResourceManager
.IOException
- if the operation can't be completed