org.ujoframework.implementation.mapImpl
Class MapImplUjo

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.implementation.mapImpl.MapImplUjo
All Implemented Interfaces:
java.io.Serializable, java.util.Map<java.lang.CharSequence,java.lang.Object>, UjoCloneable, UjoTextable, Ujo
Direct Known Subclasses:
MapImplUjoMiddle

public abstract class MapImplUjo
extends AbstractUjo
implements java.util.Map<java.lang.CharSequence,java.lang.Object>, java.io.Serializable

The abstract String Map Ujo imlementation is an implementation of the UjoMiddle and Map<CharSequence,Object> interfaces. A child implementation can use "public static final UjoProperty" constants for its UjoProperties. The map key can be any CharSequence object include a direct UjoProperty from its implementation.
Notes:

Sample of usage

 import org.ujoframework.implementation.map.*;
 public class Person extends MapImplUjo {

    public static final UjoProperty<Person,String > NAME  = newProperty("name" , String.class);
    public static final UjoProperty<Person,Boolean> MALE  = newProperty("male" , Boolean.class);
    public static final UjoProperty<Person,Date   > BIRTH = newProperty("birth", Date.class);

 }
 

Since:
UJO release 0.85
Author:
Pavel Ponec
See Also:
Property, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
  MapImplUjo()
          Constructor
protected MapImplUjo(java.util.HashMap<java.lang.String,java.lang.Object> aData)
          Constructor
 
Method Summary
 void clear()
          Removes all of the mappings from this map.
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 java.util.Set<java.util.Map.Entry<java.lang.CharSequence,java.lang.Object>> entrySet()
          Returns a Set view of the mappings contained in this map.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped, the null is not supported
 boolean isEmpty()
          Returns the number of key-value mappings in this map.
 java.util.Set<java.lang.CharSequence> keySet()
          Returns a set of String keys.
protected static
<UJO extends MapImplUjo,ITEM>
ListProperty<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> type)
          A ListProperty Factory Method assigns a next property index.
static
<UJO extends MapImplUjo,VALUE>
Property<UJO,VALUE>
newProperty(java.lang.String name, java.lang.Class<VALUE> type)
          Returns a new instance of property where the default value is null.
protected static
<UJO extends MapImplUjo,VALUE>
Property<UJO,VALUE>
newProperty(java.lang.String name, VALUE value)
          A Property Factory Method assigns a next property index.
 java.lang.Object put(java.lang.CharSequence key, java.lang.Object value)
          Associates the specified value with the specified key in this map.
 void putAll(java.util.Map<? extends java.lang.CharSequence,? extends java.lang.Object> m)
           
 java.lang.Object readValue(UjoProperty property)
          It is a common method for reading all object values, however there is strongly recomended to use a method Property.getValue(org.ujoframework.Ujo) to an external access for a better type safe.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for the specified key from this map if present.
 int size()
          Returns the number of key-value mappings in this map
 java.util.Collection<java.lang.Object> values()
          Returns a Collection view of the values contained in this map
 void writeValue(UjoProperty property, java.lang.Object value)
          It is a common method for writing all object values, however there is strongly recomended to use a method Property.setValue(org.ujoframework.Ujo, java.lang.Object) to an external access for a better type safe.
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
clone, equals, init, init, readAuthorization, readProperties, readUjoManager, readValueString, toString, writeValueString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MapImplUjo

public MapImplUjo()
Constructor


MapImplUjo

protected MapImplUjo(java.util.HashMap<java.lang.String,java.lang.Object> aData)
Constructor

Method Detail

writeValue

public void writeValue(UjoProperty property,
                       java.lang.Object value)
It is a common method for writing all object values, however there is strongly recomended to use a method Property.setValue(org.ujoframework.Ujo, java.lang.Object) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and validators.
NOTE: If property is an incorrect then no exception is throwed.

Specified by:
writeValue in interface Ujo
Parameters:
property - Property must be a direct type only!
See Also:
Property.setValue(Ujo,Object)

readValue

public java.lang.Object readValue(UjoProperty property)
It is a common method for reading all object values, however there is strongly recomended to use a method Property.getValue(org.ujoframework.Ujo) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and convertors.
NOTE: If property is an incorrect then method returns a null value.

Specified by:
readValue in interface Ujo
Parameters:
property - Property must be a direct type only!
Returns:
Property value
See Also:
Property.getValue(org.ujoframework.Ujo)

size

public int size()
Returns the number of key-value mappings in this map

Specified by:
size in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

isEmpty

public boolean isEmpty()
Returns the number of key-value mappings in this map.

Specified by:
isEmpty in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

containsKey

public boolean containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface java.util.Map<java.lang.CharSequence,java.lang.Object>
Parameters:
key - Any CharSequence include a direct UjoProperty

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value.

Specified by:
containsValue in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped, the null is not supported

Specified by:
get in interface java.util.Map<java.lang.CharSequence,java.lang.Object>
Parameters:
key - Any CharSequence include a direct UjoProperty

put

public java.lang.Object put(java.lang.CharSequence key,
                            java.lang.Object value)
Associates the specified value with the specified key in this map.

Specified by:
put in interface java.util.Map<java.lang.CharSequence,java.lang.Object>
Parameters:
key - Any CharSequence include a direct UjoProperty
value -
Returns:
the previous value associated with key, or null if there was no mapping for key.

remove

public java.lang.Object remove(java.lang.Object key)
Removes the mapping for the specified key from this map if present.

Specified by:
remove in interface java.util.Map<java.lang.CharSequence,java.lang.Object>
Parameters:
key - Any CharSequence include a direct UjoProperty
Returns:
the previous value associated with key, or null if there was no mapping for key.

putAll

public void putAll(java.util.Map<? extends java.lang.CharSequence,? extends java.lang.Object> m)
Specified by:
putAll in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

clear

public void clear()
Removes all of the mappings from this map. The map will be empty after this call returns.

Specified by:
clear in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

keySet

public java.util.Set<java.lang.CharSequence> keySet()
Returns a set of String keys.

Specified by:
keySet in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

values

public java.util.Collection<java.lang.Object> values()
Returns a Collection view of the values contained in this map

Specified by:
values in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.CharSequence,java.lang.Object>> entrySet()
Returns a Set view of the mappings contained in this map.

Specified by:
entrySet in interface java.util.Map<java.lang.CharSequence,java.lang.Object>

newProperty

public static <UJO extends MapImplUjo,VALUE> Property<UJO,VALUE> newProperty(java.lang.String name,
                                                                             java.lang.Class<VALUE> type)
Returns a new instance of property where the default value is null. Method assigns a next property index.


newProperty

protected static <UJO extends MapImplUjo,VALUE> Property<UJO,VALUE> newProperty(java.lang.String name,
                                                                                VALUE value)
A Property Factory Method assigns a next property index.


newListProperty

protected static <UJO extends MapImplUjo,ITEM> ListProperty<UJO,ITEM> newListProperty(java.lang.String name,
                                                                                      java.lang.Class<ITEM> type)
A ListProperty Factory Method assigns a next property index.



Copyright © 2010. All Rights Reserved.