public class ResourceCollection
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ResourceCollection.Resource
Class Resource holds a string path which may be a file, url or java resource
path.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
description
The description
|
protected java.lang.String |
id
The id of this collection
|
protected java.util.Hashtable |
idToPath
A mapping from id (String) to the resource path
|
protected java.util.Hashtable |
pathToId
A mapping from resource path to id
|
protected int |
writableIndex
Index of the writable index
|
protected ResourceCollection.Resource |
writableResource
Path to the writable resource
|
Constructor and Description |
---|
ResourceCollection(java.lang.String id)
Create a ResourceCollection with the given id.
|
ResourceCollection(java.lang.String id,
java.util.List resources)
Ctor
|
ResourceCollection(java.lang.String id,
ResourceCollection that)
copy ctor
|
ResourceCollection(java.lang.String id,
java.lang.String description)
Create a ResourceCollection with the given id ad description
|
ResourceCollection(java.lang.String id,
java.lang.String writable,
java.util.List resources)
Deprecated.
not good anymore
|
Modifier and Type | Method and Description |
---|---|
void |
addLabels(java.util.Hashtable labelMap)
Deprecated.
not used anymore
|
void |
addResource(ResourceCollection.Resource resource)
Add the resource.
|
void |
addResource(java.lang.String resource)
Add the resource.
|
void |
addResourceAtStart(ResourceCollection.Resource resource)
Add the given resource to the beginning of the list
|
void |
addResourceAtStart(java.lang.String resourcePath)
Add the resource.
|
void |
addResourceAtStart(java.lang.String resourcePath,
java.lang.String label)
Add the given resource to the beginning of the list
|
void |
addResources(java.util.List rs)
Add the list of resources
|
void |
clearCache()
Clear the cache
|
boolean |
contains(java.lang.String path)
Do we contain the given path
|
void |
deleteAllFiles()
Delete, if possible, all resource files.
|
java.lang.Object |
get(int i)
Return the name of the i'th resource
|
boolean |
getCanLoadMore()
Should we keep loading resources from this collection.
|
java.lang.String |
getDescription()
Get the Description property.
|
java.lang.String |
getId()
The id of the resource collection
|
java.lang.String |
getLabel(int resourceIdx)
Return the label (or null if none defined)
for the given resource.
|
java.lang.String |
getPathFromId(java.lang.String id)
Find the path for the given id
|
java.lang.String |
getProperty(java.lang.String name,
int resourceIdx)
Get the named property from the given resource
|
java.lang.String |
getResourceId(int idx)
Find the id for the given resource index
|
java.util.List |
getResources()
Get the list of resources
|
java.lang.String |
getShortName(int resourceIdx)
Return an abbreviated name of the given resource for display purposes.
|
java.lang.String |
getWritable()
Get the string path of the writable file resource.
|
boolean |
hasWritableResource()
Do we have a writable resource
|
boolean |
isHttp(int i)
Is the given index an http based path
|
boolean |
isHttp(java.lang.String resource)
Is the given path an http based path
|
boolean |
isValid(int i)
Is the given resource index valid.
|
boolean |
isWritable(int i)
Is the i'th resource writable
|
boolean |
isWritableResource(int i)
Is the ith resource a writable resource
|
java.lang.String |
read(int i)
Read the ith resource
|
java.lang.String |
read(int i,
boolean lookAtCache)
Read the ith resource
|
protected java.lang.String |
read(ResourceCollection.Resource resource,
boolean lookAtCache)
Read and return the contents of the resource.
|
java.lang.String |
readWritableResource()
Read in the writable resource file
|
void |
removeAll()
Reset all structures
|
void |
removeResource(int index)
Remove the index'th resource
|
void |
removeWritable()
Delete, if possible, the writable resource file
|
void |
setCanLoadMore(boolean lm)
Set if we can keep loading resources
|
void |
setDescription(java.lang.String value)
Set the Description property.
|
void |
setId(java.lang.String id)
Set the id of the resource collection
|
void |
setIdForPath(java.lang.String id,
java.lang.String path)
Associate the resource id with the path
|
int |
size()
How many resources
|
java.lang.String |
toString()
The toString method
|
void |
writeWritableResource(java.lang.String contents)
Write the given contents into the writable resource file
|
protected java.lang.String id
protected java.lang.String description
protected java.util.Hashtable idToPath
protected java.util.Hashtable pathToId
protected ResourceCollection.Resource writableResource
protected int writableIndex
public ResourceCollection(java.lang.String id)
id
- The id of this ResourceCollectionpublic ResourceCollection(java.lang.String id, java.lang.String description)
id
- The id of this ResourceCollectiondescription
- The description of this ResourceCollectionpublic ResourceCollection(java.lang.String id, java.util.List resources)
id
- Resource idresources
- List of resourcespublic ResourceCollection(java.lang.String id, java.lang.String writable, java.util.List resources)
id
- Resource idresources
- List of resourceswritable
- The writable resourcepublic ResourceCollection(java.lang.String id, ResourceCollection that)
id
- new idthat
- resourcecollection to copy frompublic boolean contains(java.lang.String path)
path
- the resource pathpublic void setIdForPath(java.lang.String id, java.lang.String path)
id
- The idpath
- The pathpublic java.lang.String getPathFromId(java.lang.String id)
id
- The idpublic java.lang.String getResourceId(int idx)
idx
- The resource indexpublic boolean getCanLoadMore()
public void setCanLoadMore(boolean lm)
lm
- valuepublic java.lang.String getId()
public void setId(java.lang.String id)
id
- The idpublic boolean isValid(int i)
i
- Resource indexpublic java.lang.String getLabel(int resourceIdx)
resourceIdx
- public java.lang.String getProperty(java.lang.String name, int resourceIdx)
name
- property nameresourceIdx
- which resourcepublic java.lang.String getShortName(int resourceIdx)
resourceIdx
- public void addLabels(java.util.Hashtable labelMap)
labelMap
- Pat to label mappublic void addResources(java.util.List rs)
rs
- List of Resource-spublic void removeResource(int index)
index
- the index to removepublic void addResource(java.lang.String resource)
resource
- The resource pathpublic void addResource(ResourceCollection.Resource resource)
resource
- The resourcepublic void addResourceAtStart(java.lang.String resourcePath)
resourcePath
- the path to the resourcepublic void addResourceAtStart(java.lang.String resourcePath, java.lang.String label)
resourcePath
- resource pathlabel
- labelpublic void addResourceAtStart(ResourceCollection.Resource resource)
resource
- The resourcepublic int size()
public boolean isWritable(int i)
i
- Resource indexpublic boolean isHttp(java.lang.String resource)
resource
- Resource pathpublic boolean isHttp(int i)
i
- Resource indexpublic java.lang.Object get(int i)
i
- The resource indexpublic boolean isWritableResource(int i)
i
- Resource indexpublic java.lang.String readWritableResource()
public void writeWritableResource(java.lang.String contents) throws java.io.FileNotFoundException, java.io.IOException
contents
- java.io.FileNotFoundException
java.io.IOException
protected java.lang.String read(ResourceCollection.Resource resource, boolean lookAtCache)
resource
- The resourcelookAtCache
- Should we look in the cache or rereadpublic java.lang.String read(int i, boolean lookAtCache)
i
- The resource indexlookAtCache
- Should we look in the cache or rereadpublic java.lang.String read(int i)
i
- The resource indexpublic java.util.List getResources()
public void removeWritable()
public void clearCache()
public void deleteAllFiles()
public void removeAll()
public java.lang.String getWritable()
public boolean hasWritableResource()
public java.lang.String toString()
toString
in class java.lang.Object
public void setDescription(java.lang.String value)
value
- The new value for Descriptionpublic java.lang.String getDescription()