|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap<String,Object> com.endeca.infront.assembler.BasicContentItem
public class BasicContentItem
Convenience class to extend when implementing ContentItem
This class implements a copy constructor and a constructor that requires only the content item type. In addition, it implements all of the typed getters from ContentItem
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
BasicContentItem()
Creates a new BasicContentItem without a type. |
|
BasicContentItem(ContentItem pContentItem)
Copy constructor. |
|
BasicContentItem(String pType)
Creates a new BasicContentItem without the specified type. |
Method Summary | ||
---|---|---|
boolean |
getBooleanProperty(String key,
boolean defaultValue)
Convenience method for getting a boolean property value. |
|
int |
getIntProperty(String key,
int defaultValue)
Convenience method for getting an int property value. |
|
long |
getLongProperty(String key,
long defaultValue)
Convenience method for getting a long property value. |
|
String |
getType()
Returns the type of this content item. |
|
|
getTypedProperty(String key)
Convenience method for returning a property value without having to cast the return value to the desired type. |
|
protected void |
setType(String type)
Sets the type for this content item. |
Methods inherited from class java.util.HashMap |
---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public BasicContentItem()
public BasicContentItem(String pType)
pType
- the content item typegetType()
public BasicContentItem(ContentItem pContentItem)
pContentItem
- the contents for this instanceMethod Detail |
---|
public String getType()
getType
in interface ContentItem
protected void setType(String type)
public <T> T getTypedProperty(String key)
e.g. instead of
Object value = contentItem.get("record"); Record record = (Record)value;use
Record record = contentItem.getTypedProperty("record");
key
- key whose associated value is to be returned.
ClassCastException
- if the property value could not be coerced
to the required typeHashMap.put(K, V)
public int getIntProperty(String key, int defaultValue)
key
- key whose associated int value is to be returned.
The value may be of type Integer or a String that
parses to an int.defaultValue
- the value to return if the ContentItem
does not contain the given key.
RuntimeException
- if the value associated with the key cannot
be parsed into an intpublic long getLongProperty(String key, long defaultValue)
key
- key whose associated long value is to be returned.
The value may be of type Long or a String that
parses to a long.defaultValue
- the value to return if the ContentItem
does not contain the given key.
RuntimeException
- if the value associated with the key cannot
be parsed into a longpublic boolean getBooleanProperty(String key, boolean defaultValue)
key
- key whose associated boolean value is to be
returned. The value may be of type Boolean or a
String that parses to a boolean.defaultValue
- the value to return if the ContentItem
does not contain the specified key.
RuntimeException
- if the value associated with the key cannot
be parsed into a boolean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |