tuwien.auto.calimero.datapoint
Class DatapointMap

java.lang.Object
  extended by tuwien.auto.calimero.datapoint.DatapointMap
All Implemented Interfaces:
DatapointModel

public class DatapointMap
extends java.lang.Object
implements DatapointModel

A datapoint model storing datapoints with no defined order or hierarchy using a map implementation.


Constructor Summary
DatapointMap()
          Creates a new empty datapoint map.
DatapointMap(java.util.Collection datapoints)
          Creates a new datapoint map and adds all datapoints to the map.
 
Method Summary
 void add(Datapoint dp)
          Adds a datapoint to this model.
 boolean contains(Datapoint dp)
          Checks whether this model contains the specified datapoint.
 boolean contains(GroupAddress main)
          Checks whether this model contains the datapoint identified using the specified main address.
 Datapoint get(GroupAddress main)
          Returns the datapoint identified using the specified main address, if found in this model.
 java.util.Collection getDatapoints()
          Returns all datapoints currently contained in this map.
 void load(XMLReader r)
          Loads a datapoint model from XML input into this model.
 void remove(Datapoint dp)
          Removes the specified datapoint from this model, if that datapoint is found.
 void removeAll()
          Removes all datapoints contained in this model.
 void save(XMLWriter w)
          Saves the datapoint model to XML using the supplied writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatapointMap

public DatapointMap()
Creates a new empty datapoint map.


DatapointMap

public DatapointMap(java.util.Collection datapoints)
Creates a new datapoint map and adds all datapoints to the map.

A datapoint to be added has to be unique according its main address, the attempt to add two datapoints using the same main address results in a KNXIllegalArgumentException.

Parameters:
datapoints - collection with entries of type Datapoint
Throws:
KNXIllegalArgumentException - on duplicate datapoint
Method Detail

add

public void add(Datapoint dp)
Description copied from interface: DatapointModel
Adds a datapoint to this model.

An implementation might throw KNXIllegalArgumentException if tried to add a duplicate datapoint.

Specified by:
add in interface DatapointModel
Parameters:
dp - datapoint to add

contains

public boolean contains(Datapoint dp)
Description copied from interface: DatapointModel
Checks whether this model contains the specified datapoint.

Specified by:
contains in interface DatapointModel
Parameters:
dp - datapoint to look up
Returns:
true iff such datapoint is found, false otherwise

contains

public boolean contains(GroupAddress main)
Description copied from interface: DatapointModel
Checks whether this model contains the datapoint identified using the specified main address.

Specified by:
contains in interface DatapointModel
Parameters:
main - KNX group address to look up
Returns:
true iff such datapoint is found, false otherwise

get

public Datapoint get(GroupAddress main)
Description copied from interface: DatapointModel
Returns the datapoint identified using the specified main address, if found in this model.

If no datapoint is found with that address, null is returned.

Specified by:
get in interface DatapointModel
Parameters:
main - KNX group address to get the datapoint for
Returns:
the datapoint or null

getDatapoints

public java.util.Collection getDatapoints()
Returns all datapoints currently contained in this map.

Returns:
unmodifiable collection with entries of type Datapoint

load

public void load(XMLReader r)
          throws KNXMLException
Description copied from interface: DatapointModel
Loads a datapoint model from XML input into this model.

Datapoints already contained in this model are not required to be removed before loading, the loaded model will be added to the already existing datapoints.

Specified by:
load in interface DatapointModel
Parameters:
r - a XML reader
Throws:
KNXMLException - on error loading the datapoint model, or on duplicate loaded datapoint

remove

public void remove(Datapoint dp)
Description copied from interface: DatapointModel
Removes the specified datapoint from this model, if that datapoint is found.

Specified by:
remove in interface DatapointModel
Parameters:
dp - datapoint to remove

removeAll

public void removeAll()
Description copied from interface: DatapointModel
Removes all datapoints contained in this model.

Specified by:
removeAll in interface DatapointModel

save

public void save(XMLWriter w)
          throws KNXMLException
Description copied from interface: DatapointModel
Saves the datapoint model to XML using the supplied writer.

Specified by:
save in interface DatapointModel
Parameters:
w - a XML writer
Throws:
KNXMLException - on error saving the datapoint model