public class Resources
extends java.lang.Object
Constructor | Description |
---|---|
Resources() |
Constructs a new CMLib object for the current thread group.
|
Modifier and Type | Method | Description |
---|---|---|
void |
_clearResources() |
Instantly and permanently removes all resources.
|
static boolean |
_compressed() |
Returns whether resource objects are being compressed
|
boolean |
_findRemoveProperty(CMFile F,
java.lang.String match) |
Opens the given CMFile as a properties type file, ignoring comment lines, and looking
for a property entry that matches [match]=[whatever], removing it if found, and if found,
re-saving the file.
|
java.util.Iterator<java.lang.String> |
_findResourceKeys(java.lang.String srch) |
Returns an iterator of all resource keys that pass a substring
search of the given srch string.
|
java.lang.StringBuffer |
_getFileResource(java.lang.String filename,
boolean reportErrors) |
Returns the stringbuffer content for the given resource filename.
|
java.lang.StringBuffer |
_getRawFileResource(java.lang.String filename,
boolean reportErrors) |
Returns the stringbuffer content for the given resource filename.
|
java.lang.String |
_getRawFileResourceName(java.lang.String filename,
boolean withPrefix) |
Returns the final vfs filename of a raw resource file, accounting
for resource/-ifying, and for private resource paths from the ini
file.
|
java.lang.Object |
_getResource(java.lang.String ID) |
Returns the resource object with the given case insensitive ID.
|
boolean |
_isFileResource(java.lang.String filename) |
Returns true if there is a resource file object stored under the
given filename OR if there exists a file with the given filename
(and is thus potentially a file resource).
|
boolean |
_isResource(java.lang.String ID) |
Checks the resource object with the given case insensitive ID.
|
void |
_removeResource(java.lang.String ID) |
Removes the given resource with the given ID, if found.
|
boolean |
_saveFileResource(java.lang.String filename,
MOB whoM,
java.lang.StringBuffer myRsc) |
Saves the given stringbuffer of data to the given resource filename, to
the filesystem on behalf of the given user/player, without touching the cache.
|
java.lang.Object |
_submitResource(java.lang.String ID,
java.lang.Object obj) |
Adds or updates the given resource object at the given resource id/key.
|
java.lang.StringBuffer |
_toStringBuffer(java.lang.Object o) |
Returns the string-like object given as a StringBuffer.
|
boolean |
_updateFileResource(java.lang.String filename,
java.lang.Object obj) |
Saves the given stringbuffer of data to the given resource filename, to
the filesystem while also updating the internal cache for the resources.
|
static java.lang.Iterable<Resources> |
all() |
Returns all resource objects in existence.
|
static java.lang.String |
buildResourcePath(java.lang.String path) |
Adds resources/ before the given path, and always adds a / at the end.
|
static void |
clearResources() |
Removes all resources for the current calling thread group
|
static boolean |
findRemoveProperty(CMFile F,
java.lang.String match) |
Opens the given CMFile as a properties type file, ignoring comment lines, and looking
for a property entry that matches [match]=[whatever], removing it if found, and if found,
re-saving the file.
|
static java.util.Iterator<java.lang.String> |
findResourceKeys(java.lang.String srch) |
Does a case-insensitive instring search of all resources for the
current calling thread group and returns an iterator of all FULL keys
that match.
|
static java.util.Map<java.lang.String,java.lang.String> |
getAllPropResources(java.lang.String section) |
The "Resource Properties" is a special VFS file containing normal properties divided into
sections headed by a bracketed [BLOCK].
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getCachedMultiLists(java.lang.String filename,
boolean createIfNot) |
A multi-list is, in code, a string-key map of string lists.
|
static java.lang.String |
getEOLineMarker(java.lang.StringBuffer buf) |
Scans the given stringbuffer for the first occurrence of an end-of-line and
returns the end of line character(s) encountered.
|
static java.util.List<java.lang.String> |
getFileLineVector(java.lang.StringBuffer buf) |
Scans the given stringbuffer for end of line markers, and adds each line
encountered to a string list, returning that list object.
|
static java.lang.StringBuffer |
getFileResource(java.lang.String filename,
boolean reportErrors) |
Returns the stringbuffer content for the given resource filename, from
the resources for the current calling thread group.
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getMultiLists(java.lang.String filename) |
A multi-list is, in code, a string-key map of string lists.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getPersonalMap(java.lang.Object key,
boolean createIfNecc) |
Returns the string/object map assigned to the given object key.
|
static java.lang.String |
getPropResource(java.lang.String section,
java.lang.String key) |
The "Resource Properties" is a special VFS file containing normal properties divided into
sections headed by a bracketed [BLOCK].
|
static java.lang.StringBuffer |
getRawFileResource(java.lang.String filename,
boolean reportErrors) |
Returns the stringbuffer content for the given resource filename, from
the resources for the current calling thread group.
|
static java.lang.String |
getRawFileResourceName(java.lang.String filename,
boolean withPrefix) |
Returns the final vfs filename of a raw resource file, accounting
for resource/-ifying, and for private resource paths from the ini
file.
|
static java.lang.Object |
getResource(java.lang.String ID) |
Returns the raw resource object for the given case-insensitive ID, from
the resources for the current calling thread group.
|
static Resources |
initialize() |
Creates and returns a new Resources object for the current calling thread
|
static Resources |
instance() |
Returns the Resources instance tied to this particular thread group, or a new one if not yet created.
|
static Resources |
instance(char c) |
Returns the Resources instance tied to the given thread group, or null if not yet created.
|
static boolean |
isFileResource(java.lang.String filename) |
Checks the resources for the current calling thread group for a file resource
of the given name.
|
static boolean |
isPropResource(java.lang.String section,
java.lang.String key) |
The "Resource Properties" is a special VFS file containing normal properties divided into
sections headed by a bracketed [BLOCK].
|
static boolean |
isResource(java.lang.String ID) |
Checks the current resources for the current calling thread group for the ID.
|
static java.lang.String |
makeFileResourceName(java.lang.String filename) |
Adds resources/ to the beginning of the given filename.
|
static Resources |
newResources() |
Creates and returns a new Resources object for the current calling thread
|
static java.lang.Object |
prepareObject(java.lang.Object obj) |
Prepares an object for storage in resources by trimming any vectors,
and compressing any stringbuffers, if necessary.
|
static boolean |
removeMultiLists(java.lang.String filename) |
A multi-list is, in code, a string-key map of string lists.
|
static void |
removePersonalMap(java.lang.Object key) |
Removes and Deletes the string/object map assigned to the given object key.
|
static void |
removeResource(java.lang.String ID) |
Removes the current resources for the current calling thread group.
|
static boolean |
saveFileResource(java.lang.String filename,
MOB whom,
java.lang.StringBuffer myRsc) |
Saves the given stringbuffer of data to the given resource filename, to
the filesystem on behalf of the given user/player, without touching the cache.
|
static void |
savePropResources() |
The "Resource Properties" is a special VFS file containing normal properties divided into
sections headed by a bracketed [BLOCK].
|
static void |
setCompression(boolean truefalse) |
Turn on or off resource compression.
|
static void |
setPropResource(java.lang.String section,
java.lang.String key,
java.lang.String value) |
The "Resource Properties" is a special VFS file containing normal properties divided into
sections headed by a bracketed [BLOCK].
|
static void |
shareWith(char code) |
Forces the current thread group to share a Resources object with the one at the given
threadcode.
|
static void |
shutdown() |
Saves any cached resource properties for the current calling thread group.
|
static Resources |
staticInstance() |
Returns the Resources instance tied to this particular thread group, or null if not yet created.
|
static void |
submitResource(java.lang.String ID,
java.lang.Object obj) |
Adds or replaces a raw resource object at the given case-insensitive ID, into
the resources for the current calling thread group.
|
static boolean |
updateCachedMultiLists(java.lang.String filename) |
A multi-list is, in code, a string-key map of string lists.
|
static boolean |
updateFileResource(java.lang.String filename,
java.lang.Object obj) |
Saves the given stringbuffer of data to the given resource filename, to
the filesystem while also updating the internal cache for the resources
of the calling threads thread group.
|
static void |
updateMultiListFile(java.lang.String filename,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> lists) |
A multi-list is, in code, a string-key map of string lists.
|
public Resources()
public static java.lang.Iterable<Resources> all()
public static void shareWith(char code)
code
- the threadcode with an existing Resourcespublic static final Resources initialize()
public static final Resources instance()
public static final Resources instance(char c)
c
- the code for the thread group to return (0-255)public static final Resources staticInstance()
public static final Resources newResources()
public static final void clearResources()
public static final void shutdown()
public static final void removeResource(java.lang.String ID)
ID
- the resource ID to remove, case insensitive as alwayspublic static final boolean isResource(java.lang.String ID)
ID
- the resource ID to check forpublic static final java.util.Iterator<java.lang.String> findResourceKeys(java.lang.String srch)
srch
- the instring string to search forpublic static final java.lang.Object getResource(java.lang.String ID)
ID
- the resource ID to returnpublic static final void submitResource(java.lang.String ID, java.lang.Object obj)
ID
- the resource ID to store the given object atobj
- the object to store at the given IDpublic static final boolean isFileResource(java.lang.String filename)
filename
- the resource filename to check for (/resources/[FILENAME])public static final java.lang.StringBuffer getFileResource(java.lang.String filename, boolean reportErrors)
filename
- the resource filename (/resources/[FILENAME])reportErrors
- if true, file errors will be loggedpublic static final java.lang.String getRawFileResourceName(java.lang.String filename, boolean withPrefix)
filename
- the initial filename/pathwithPrefix
- whether to restore ::// prefixes if sentpublic static final java.lang.StringBuffer getRawFileResource(java.lang.String filename, boolean reportErrors)
filename
- the resource filename (/resources/[FILENAME])reportErrors
- if true, file errors will be loggedpublic static final boolean saveFileResource(java.lang.String filename, MOB whom, java.lang.StringBuffer myRsc)
filename
- the resource filename to save to (/resources/[FILENAME])whom
- the mob whose permissions to check, or null to always savemyRsc
- the string data to store in the filepublic static final boolean updateFileResource(java.lang.String filename, java.lang.Object obj)
filename
- the resource filename to save to (/resources/[FILENAME])obj
- the string data to store in the file, stringbuffer, byte array, etcpublic static final boolean findRemoveProperty(CMFile F, java.lang.String match)
F
- the properties file to potentially modifymatch
- the property file entry to removepublic static final java.lang.String getEOLineMarker(java.lang.StringBuffer buf)
buf
- the stringbuffer to scanpublic static final java.util.List<java.lang.String> getFileLineVector(java.lang.StringBuffer buf)
buf
- the stringbuffer to scan for linespublic static final java.lang.String buildResourcePath(java.lang.String path)
path
- a path stringpublic static final void updateMultiListFile(java.lang.String filename, java.util.Map<java.lang.String,java.util.List<java.lang.String>> lists)
filename
- the resource filename to save tolists
- the multi-listpublic static final java.util.Map<java.lang.String,java.lang.Object> getPersonalMap(java.lang.Object key, boolean createIfNecc)
key
- the key to look forcreateIfNecc
- true to create the missing mapgetPersonalMap(Object, boolean)
public static final void removePersonalMap(java.lang.Object key)
key
- the key to look forgetPersonalMap(Object, boolean)
public static final boolean removeMultiLists(java.lang.String filename)
filename
- the filename of the parsed multi-list filepublic static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> getCachedMultiLists(java.lang.String filename, boolean createIfNot)
filename
- the filename of the parsed multi-list filecreateIfNot
- true to create a multilist object if not loaded, false if notpublic static final boolean updateCachedMultiLists(java.lang.String filename)
filename
- the filename of the parsed multi-list filepublic static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMultiLists(java.lang.String filename)
filename
- the filename of the parsed multi-list filepublic static final java.lang.String makeFileResourceName(java.lang.String filename)
filename
- the filename to resource normalizepublic static final void setCompression(boolean truefalse)
truefalse
- true to turn on compression, false to turn it offpublic static final boolean _compressed()
public final void _clearResources()
public final java.util.Iterator<java.lang.String> _findResourceKeys(java.lang.String srch)
srch
- the substring srch stringpublic final java.lang.Object _getResource(java.lang.String ID)
ID
- the key of the object to returnpublic final boolean _isResource(java.lang.String ID)
ID
- the key of the object to look forpublic static final java.lang.Object prepareObject(java.lang.Object obj)
obj
- the object to prepare for storagepublic final java.lang.Object _submitResource(java.lang.String ID, java.lang.Object obj)
ID
- the key to store the resource asobj
- the object to storepublic final void _removeResource(java.lang.String ID)
ID
- the key the resource is stored aspublic final boolean _isFileResource(java.lang.String filename)
filename
- the filename to look in the cache or filesystem forpublic final java.lang.StringBuffer _toStringBuffer(java.lang.Object o)
o
- the string, stringbuffer, or stringbuilder to convert to stringbufferpublic final java.lang.StringBuffer _getFileResource(java.lang.String filename, boolean reportErrors)
filename
- the resource filename (/resources/[FILENAME])reportErrors
- if true, file errors will be loggedpublic final java.lang.String _getRawFileResourceName(java.lang.String filename, boolean withPrefix)
filename
- the initial filename/pathwithPrefix
- whether to restore ::// prefixes if sentpublic final java.lang.StringBuffer _getRawFileResource(java.lang.String filename, boolean reportErrors)
filename
- the resource filename (/resources/[FILENAME])reportErrors
- if true, file errors will be loggedpublic final boolean _updateFileResource(java.lang.String filename, java.lang.Object obj)
filename
- the resource filename to save to (/resources/[FILENAME])obj
- the string data to store in the file, stringbuffer, byte array, etcpublic final boolean _saveFileResource(java.lang.String filename, MOB whoM, java.lang.StringBuffer myRsc)
filename
- the resource filename to save to (/resources/[FILENAME])whoM
- the mob whose permissions to check, or null to always savemyRsc
- the string data to store in the filepublic final boolean _findRemoveProperty(CMFile F, java.lang.String match)
F
- the properties file to potentially modifymatch
- the property file entry to removepublic static final java.util.Map<java.lang.String,java.lang.String> getAllPropResources(java.lang.String section)
section
- the section in the resource properties to get entries frompublic static final boolean isPropResource(java.lang.String section, java.lang.String key)
section
- the section to look inkey
- the property key to look for in that sectionpublic static final java.lang.String getPropResource(java.lang.String section, java.lang.String key)
section
- the section of the resource properties to look inkey
- the key in the section to look forpublic static final void setPropResource(java.lang.String section, java.lang.String key, java.lang.String value)
section
- the section of the resource properties to add the key tokey
- the key in the section to setvalue
- the new value of the key, or "" to removepublic static final void savePropResources()