pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.site.content
Class ContentLocalizationMap

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.site.content.ContentLocalizationMap
All Implemented Interfaces:
java.io.Serializable, JDOMable

@Entity
public class ContentLocalizationMap
extends AbstractBasicEntity
implements JDOMable

marks a set of Contents to be localizations of each other.

Within a ContentLocalizationMap each Locale and Content may only appear once. Moreover all Contents have to be of the exact same type.

The put(Locale, Content) method does not comply with the general Map contract, as it does not support the overwriting of values!

Version:
$Revision: 1822 $
Author:
Thomas Weber, Daniel Dietz
See Also:
Serialized Form

Constructor Summary
protected ContentLocalizationMap()
          Deprecated. 
  ContentLocalizationMap(java.util.Locale l, Content c)
          creates a new ContentLocalizationMap for the given Content and the given Locale.
 
Method Summary
 void clear()
          removes all 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.
 org.jdom.Element deserializeToJDOM()
          Always throws PulseException.
 java.util.Set<java.util.Map.Entry<java.util.Locale,Content>> entrySet()
          returns a set view of the mappings contained in this map.
 Content get(java.lang.Object key)
          returns the value to which this map maps the specified key.
 boolean isEmpty()
          returns true if this map contains no key-value mappings.
 java.util.Set<java.util.Locale> keySet()
          returns a set view of the keys contained in this map.
 Content put(java.util.Locale key, Content value)
          puts a new mapping from key to value provided both the key and value are not yet part of the ContentLocalizationMap and the Content is of the same type as the other values already present in the map.
 void putAll(java.util.Map<? extends java.util.Locale,? extends Content> t)
          copies all of the mappings from the specified map to this map.
 Content remove(java.lang.Object key)
          removes the mapping for this key from this map if it is present.
 int size()
          returns the number of key-value mappings in this map.
 java.util.Collection<Content> values()
          returns a collection view of the values contained in this map.
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentLocalizationMap

@Deprecated
protected ContentLocalizationMap()
Deprecated. 

used by HibernateTM.


ContentLocalizationMap

public ContentLocalizationMap(java.util.Locale l, Content c)
creates a new ContentLocalizationMap for the given Content and the given Locale.

Parameters:
l - the locale
c - the content
Method Detail

clear

public final void clear()
removes all mappings from this map.


containsKey

public final boolean containsKey(java.lang.Object key)
                          throws java.lang.ClassCastException,
                                 java.lang.NullPointerException
returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)

Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
java.lang.ClassCastException - if the key is of an inappropriate type for this map.
java.lang.NullPointerException - if the key is null.

containsValue

public final boolean containsValue(java.lang.Object value)
                            throws java.lang.ClassCastException,
                                   java.lang.NullPointerException
returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the map size for most implementations of the Map interface.

Parameters:
value - value whose presence in this map is to be tested.
Returns:
true if this map maps one or more keys to the specified value.
Throws:
java.lang.ClassCastException - if the value is of an inappropriate type for this map.
java.lang.NullPointerException - if the value is null and this map does not permit null values.

entrySet

public final java.util.Set<java.util.Map.Entry<java.util.Locale,Content>> entrySet()
returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:
a set view of the mappings contained in this map.

get

public final Content get(java.lang.Object key)
                  throws java.lang.ClassCastException,
                         java.lang.NullPointerException
returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.
Throws:
java.lang.ClassCastException - if the key is of an inappropriate type for this map.
java.lang.NullPointerException - if the key is null.
See Also:
containsKey(Object)

isEmpty

public final boolean isEmpty()
returns true if this map contains no key-value mappings.

Returns:
true if this map contains no key-value mappings.

keySet

public final java.util.Set<java.util.Locale> keySet()
returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.

Returns:
a set view of the keys contained in this map.

put

public final Content put(java.util.Locale key, Content value)
                  throws InconsistentLocalizationException
puts a new mapping from key to value provided both the key and value are not yet part of the ContentLocalizationMap and the Content is of the same type as the other values already present in the map.

Parameters:
key - the locale
value - the content
Returns:
null (to match the Map interface)
Throws:
InconsistentLocalizationException - when a precondition for putting the association fails

putAll

public final void putAll(java.util.Map<? extends java.util.Locale,? extends Content> t)
copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of calling put(Locale, Content) on this map once for each mapping from key k to value v in the specified map. The behaviour of this operation is unspecified if the specified map is modified while the operation is in progress.

Parameters:
t - Mappings to be stored in this map.

remove

public final Content remove(java.lang.Object key)
                     throws java.lang.ClassCastException,
                            java.lang.NullPointerException
removes the mapping for this key from this map if it is present. More formally, if this map contains a mapping from key k to value v such that (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or null if there was no mapping for key.
Throws:
java.lang.ClassCastException - if the key is of an inappropriate type for this map.
java.lang.NullPointerException - if the key is null.

size

public final int size()
returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of key-value mappings in this map.

values

public final java.util.Collection<Content> values()
returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:
a collection view of the values contained in this map.

deserializeToJDOM

public final org.jdom.Element deserializeToJDOM()
Always throws PulseException.

ONLY here to satisfy: ContentLocalizationMap extends AbstractBasicEntity.

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
always throws PulseException