com.datumbox.framework.common.dataobjects
Class AssociativeArray
- java.lang.Object
-
- com.datumbox.framework.common.dataobjects.AbstractDataStructure<T>
-
- com.datumbox.framework.common.dataobjects.AbstractDataStructureMap<java.util.Map<java.lang.Object,java.lang.Object>>
-
- com.datumbox.framework.common.dataobjects.AssociativeArray
-
- All Implemented Interfaces:
- java.io.Serializable
public class AssociativeArray extends AbstractDataStructureMap<java.util.Map<java.lang.Object,java.lang.Object>>
Data structure which stores internally a Map- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AssociativeArray()Default constructor which initializes the internal data with a LinkedHashMap.AssociativeArray(java.util.Map<java.lang.Object,java.lang.Object> internalData)Constructor that initializes the internal data with the provided map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddValues(AssociativeArray array)Adds the provided associative array to the current object.static AssociativeArrayconvert2Unmodifiable(AssociativeArray original)Converts the internal data of the provided AssociativeArray to unmondifiable but it does not copy its values.AssociativeArraycopy()static AssociativeArraycopy2Unmodifiable(AssociativeArray original)Copies the provided AssociativeArray and builds a new which is unmodifiable.java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>entrySet()Returns the entrySet of the internal map.booleanequals(java.lang.Object o)java.lang.Objectget(java.lang.Object key)Returns the value which is associated with the provided key.java.lang.DoublegetDouble(java.lang.Object key)Gets value of the particular key from the map and converts it into a Double.inthashCode()java.util.Set<java.lang.Object>keySet()Returns the keySet of the internal map.voidmultiplyValues(double multiplier)Multiplies the values of the object with a particular multiplier.voidoverwrite(java.util.Map<java.lang.Object,java.lang.Object> data)Overwrites the contents of the internal data of this object with the ones of the provided map.java.lang.Objectput(java.lang.Object key, java.lang.Object value)Adds a particular key-value into the internal map.voidputAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> m)Adds all the key-value combinations of the provided map in the internal map.java.lang.Objectremove(java.lang.Object key)Removes a particular key from the internal map and returns the value associated with that key if present in the map.voidsubtractValues(AssociativeArray array)Subtracts the provided associative array to the current object.FlatDataCollectiontoFlatDataCollection()Returns a FlatDataCollection with the values of the internal map.FlatDataListtoFlatDataList()Returns a FlatDataList with the values of the internal map.java.lang.StringtoString()java.util.Collection<java.lang.Object>values()Returns the values of the internal map.-
Methods inherited from class com.datumbox.framework.common.dataobjects.AbstractDataStructureMap
clear, containsKey, isEmpty, size
-
-
-
-
Constructor Detail
-
AssociativeArray
public AssociativeArray()
Default constructor which initializes the internal data with a LinkedHashMap.
-
AssociativeArray
public AssociativeArray(java.util.Map<java.lang.Object,java.lang.Object> internalData)
Constructor that initializes the internal data with the provided map.- Parameters:
internalData-
-
-
Method Detail
-
copy2Unmodifiable
public static AssociativeArray copy2Unmodifiable(AssociativeArray original)
Copies the provided AssociativeArray and builds a new which is unmodifiable.- Parameters:
original-- Returns:
-
convert2Unmodifiable
public static AssociativeArray convert2Unmodifiable(AssociativeArray original)
Converts the internal data of the provided AssociativeArray to unmondifiable but it does not copy its values. This means that if the original AssociativeArray gets modified, the data of the new object will be modified too. This method is not as safe as copy2Unmodifiable() but it should be preferred when speed is crucial.- Parameters:
original-- Returns:
-
copy
public AssociativeArray copy()
-
overwrite
public final void overwrite(java.util.Map<java.lang.Object,java.lang.Object> data)
Overwrites the contents of the internal data of this object with the ones of the provided map.- Parameters:
data-
-
addValues
public final void addValues(AssociativeArray array)
Adds the provided associative array to the current object. All the columns of this object should be numeric or boolean or else an exception is thrown.- Parameters:
array-
-
subtractValues
public final void subtractValues(AssociativeArray array)
Subtracts the provided associative array to the current object. All the columns of this object should be numeric or boolean or else an exception is thrown.- Parameters:
array-
-
multiplyValues
public final void multiplyValues(double multiplier)
Multiplies the values of the object with a particular multiplier. All the columns of this object should be numeric or boolean or else an exception is thrown.- Parameters:
multiplier-
-
remove
public final java.lang.Object remove(java.lang.Object key)
Removes a particular key from the internal map and returns the value associated with that key if present in the map.- Parameters:
key-- Returns:
-
get
public final java.lang.Object get(java.lang.Object key)
Returns the value which is associated with the provided key.- Parameters:
key-- Returns:
-
getDouble
public final java.lang.Double getDouble(java.lang.Object key)
Gets value of the particular key from the map and converts it into a Double. If not found null is returned. The value must be numeric or boolean or else an exception is thrown.- Parameters:
key-- Returns:
-
put
public final java.lang.Object put(java.lang.Object key, java.lang.Object value)Adds a particular key-value into the internal map. It returns the previous value which was associated with that key.- Parameters:
key-value-- Returns:
-
putAll
public void putAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> m)
Adds all the key-value combinations of the provided map in the internal map.- Parameters:
m-
-
entrySet
public final java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
Returns the entrySet of the internal map.- Returns:
-
keySet
public final java.util.Set<java.lang.Object> keySet()
Returns the keySet of the internal map.- Returns:
-
values
public final java.util.Collection<java.lang.Object> values()
Returns the values of the internal map.- Returns:
-
toFlatDataCollection
public FlatDataCollection toFlatDataCollection()
Returns a FlatDataCollection with the values of the internal map. The method does not copy the data.- Returns:
-
toFlatDataList
public FlatDataList toFlatDataList()
Returns a FlatDataList with the values of the internal map. The method might require to copy the data.- Returns:
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG