|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.meta.support.AbstractMetadataResource
public abstract class AbstractMetadataResource
Abstract base implementation of MetadataResource
to help
make implementing this API easier.
This class keeps a Map of List objects. Values can be added to the
List instances by calling setValue(String, Object)
or
setValues(String, Collection)
. The getValue(String,Locale)
method will return the first available value for the given key.
The getValues(String,Locale)
will return an unmodifiable
List
of all values (or an empty List if no values are available
for that key).
The Locale
parameters in getValue(String, Locale)
and
getValues(String, Locale)
are not used by this class. Extending
implementations can choose to support this as needed.
Field Summary | |
---|---|
protected org.apache.log4j.Logger |
log
A class-level logger. |
Constructor Summary | |
---|---|
AbstractMetadataResource()
|
Method Summary | |
---|---|
protected void |
addError(java.lang.String key,
java.lang.String msg)
Set an error message for a particular key. |
protected void |
addValue(java.lang.String key,
java.lang.Object value)
Add a value to a key. |
protected void |
clearValues(java.lang.String key)
Clear all values for a key. |
java.lang.Iterable<java.lang.String> |
getParsedKeys()
Get an Iterable of all successfully parsed metadata keys. |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getParseErrors()
Get a Map of errors that occured while parsing the metadata resource. |
java.lang.Object |
getValue(java.lang.String key,
java.util.Locale locale)
Get a single metadata value based on an arbitrary key. |
protected java.util.List<java.lang.Object> |
getValueList(java.lang.String key)
Get the List associated with a key. |
java.lang.Iterable<?> |
getValues(java.lang.String key,
java.util.Locale locale)
Get all available metadata values based on an arbitrary key. |
protected void |
setValue(java.lang.String key,
java.lang.Object value)
Set a value for a key. |
protected void |
setValues(java.lang.String key,
java.util.Collection<?> values)
Set a collection of values for a key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.log4j.Logger log
Constructor Detail |
---|
public AbstractMetadataResource()
Method Detail |
---|
protected final void setValue(java.lang.String key, java.lang.Object value)
This replaces any values currently associated with the key.
key
- the key to usevalue
- the value to setprotected final void setValues(java.lang.String key, java.util.Collection<?> values)
This replaces any values currently associated with the key.
key
- the key to usevalues
- the values to setprotected final void addValue(java.lang.String key, java.lang.Object value)
Null values will not be added. Empty String values will not be added, either.
key
- the key to add the value tovalue
- the value to addprotected final void clearValues(java.lang.String key)
key
- the key to clearprotected final java.util.List<java.lang.Object> getValueList(java.lang.String key)
If a non-null List is returned, this is a "live" list of values associated with this key, and changes made to the List will affect what is stored with this key.
key
- the key
protected final void addError(java.lang.String key, java.lang.String msg)
When an error is encountered while parsing a particular metadata value, an error message can be added for that key
key
- the key to set the error message formsg
- the error messagepublic java.lang.Object getValue(java.lang.String key, java.util.Locale locale)
MetadataResource
Keys are implementation specific. If more than one metadata of the specified key is available, this will return the first available one.
An optional Locale parameter may be provided. Some metadata values might have Locale-specific variations. The Locale parameter may be null in which case the platform's default Locale will be used.
getValue
in interface MetadataResource
key
- the keylocale
- a Locale
public java.lang.Iterable<?> getValues(java.lang.String key, java.util.Locale locale)
MetadataResource
Keys are implementation specific.
An optional Locale parameter may be provided. Some metadata values might have Locale-specific variations. The Locale parameter may be null in which case the platform's default Locale will be used.
getValues
in interface MetadataResource
key
- the keylocale
- a Locale
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParseErrors()
MetadataResource
The Map has keys based on the metadata names, and the List associated with each key holds the error message(s) that occurred while processing the metadata values for that key.
If no errors occurred while processing, this will return an empty Map (never null).
getParseErrors
in interface MetadataResource
public java.lang.Iterable<java.lang.String> getParsedKeys()
MetadataResource
No sorting should be implied by the returned Iterator, but implementations are free to order the results in any way they see fit.
getParsedKeys
in interface MetadataResource
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |