Package bibliothek.gui.dock.support.util
Class ApplicationResourceManager
java.lang.Object
bibliothek.gui.dock.support.util.ApplicationResourceManager
Manages a set of
The
Note that there is no order how the resources are stored in the file.
ApplicationResources, can load and store the
resources at any time.The
ApplicationResources 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.Note that there is no order how the resources are stored in the file.
- Author:
- Benjamin Sigg
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidput(String name, ApplicationResource resource) Stores a resource that might be read or written at any time.voidreadArray(byte[] array) Reads the contents of this manager from an array of bytes.voidReads the contents of this manager fromfile.voidReads the content of this manager from thePreferencesthat represent the package ofApplicationResourceManager.voidLets allApplicationResources read fromin.voidReads the contents of this manager from a xml element.voidRemoves a resources that was earlier added to this manager.byte[]Writes the contents of this manager into an array of bytes.voidWrites the contents of this manager intofile.voidWrites the contents of this manager into thePreferenceswhich represent the package ofApplicationResourceManager.voidWrites all currently knownApplicationResources intoout.voidWrites the content of this manager in xml format.
-
Constructor Details
-
ApplicationResourceManager
public ApplicationResourceManager()
-
-
Method Details
-
put
Stores a resource that might be read or written at any time. If a stream was already read by this manager, and if there was an entry in that stream that equalsname, thenresourcewill immediately be asked to read the stream.- Parameters:
name- the unique identifier of the resourceresource- the new resource- Throws:
NullPointerException- ifnameofresourceisnullIOException- if the buffered stream can't be read. The resource will be stored in this manager even if an exception occurs
-
remove
Removes a resources that was earlier added to this manager.- Parameters:
name- the name of the resource to remove
-
writeStream
Writes all currently knownApplicationResources intoout.- Parameters:
out- the stream to write into- Throws:
IOException- if the operation can't be completed
-
readStream
Lets allApplicationResources read fromin.- Parameters:
in- the stream to read from- Throws:
IOException- if the operation can't be completed
-
writeXML
Writes the content of this manager in xml format.- Parameters:
element- the element to write into, the attributes of this element will not be changed.
-
readXML
Reads the contents of this manager from a xml element.- Parameters:
element- the element to read
-
writeFile
Writes the contents of this manager intofile.- Parameters:
file- the file to write into- Throws:
IOException- if the operation can't be completed
-
readFile
Reads the contents of this manager fromfile.- Parameters:
file- the file to read- Throws:
IOException- if the operation can't be completed
-
writeArray
Writes the contents of this manager into an array of bytes.- Returns:
- the contents as stream of bytes
- Throws:
IOException- if the operation can't be completed
-
readArray
Reads the contents of this manager from an array of bytes.- Parameters:
array- the content as stream of bytes- Throws:
IOException- if the operation can't be completed
-
writePreferences
Writes the contents of this manager into thePreferenceswhich represent the package ofApplicationResourceManager.- Throws:
IOException- if the operation can't be completed
-
readPreferences
Reads the content of this manager from thePreferencesthat represent the package ofApplicationResourceManager.- Throws:
IOException- if the operation can't be completed
-