Package com.cedarsoftware.ncube
Class Column
- java.lang.Object
-
- com.cedarsoftware.ncube.Column
-
- All Implemented Interfaces:
java.lang.Comparable<java.lang.Comparable>
public class Column extends java.lang.Object implements java.lang.Comparable<java.lang.Comparable>
Holds the value of a 'column' on an axis. This class exists in order to allow additional columns to be inserted onto an axis, without having to "move" the existing cells. Furthermore, for some axis types (String), it is often better for display purposes to use the display order, as opposed to it's sort order (e.g., months-of-year, days-of-week) for display.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_VALUE
protected long
id
protected java.util.Map<java.lang.String,java.lang.Object>
metaProps
static java.lang.String
NAME
-
Constructor Summary
Constructors Constructor Description Column(Column source)
Column(java.lang.Comparable value)
Column(java.lang.Comparable value, long id)
Column(java.lang.Comparable value, long id, java.util.Map metaP)
Column(java.lang.Comparable value, long id, java.util.Map metaP, int order)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMetaProperties(java.util.Map<java.lang.String,java.lang.Object> allAtOnce)
Add a Map of meta properties all at once.void
clearMetaProperties()
Remove all meta properties associated to this Column.int
compareTo(java.lang.Comparable that)
boolean
equals(java.lang.Object that)
java.lang.String
getColumnName()
Get the optional name of a column.int
getDisplayOrder()
long
getId()
java.util.Map<java.lang.String,java.lang.Object>
getMetaProperties()
java.lang.Object
getMetaProperty(java.lang.String key)
Fetch the value associated to the passed in Key from the MetaProperties (if any exist).java.lang.Comparable
getValue()
java.lang.Comparable
getValueThatMatches()
int
hashCode()
boolean
isDefault()
java.lang.Object
removeMetaProperty(java.lang.String key)
Remove a meta-property entryvoid
setColumnName(java.lang.String name)
Set the optional name of a column.protected void
setDisplayOrder(int order)
protected void
setId(long id)
java.lang.Object
setMetaProperty(java.lang.String key, java.lang.Object metaPropValue)
Set (add / overwrite) a Meta Property associated to this Column.protected void
setValue(java.lang.Comparable v)
Set the value of a column.java.lang.String
toString()
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_VALUE
public static final java.lang.String DEFAULT_VALUE
- See Also:
- Constant Field Values
-
id
protected long id
-
metaProps
protected java.util.Map<java.lang.String,java.lang.Object> metaProps
-
-
Constructor Detail
-
Column
public Column(java.lang.Comparable value)
-
Column
public Column(java.lang.Comparable value, long id)
-
Column
public Column(java.lang.Comparable value, long id, java.util.Map metaP)
-
Column
public Column(java.lang.Comparable value, long id, java.util.Map metaP, int order)
-
Column
public Column(Column source)
-
-
Method Detail
-
getMetaProperties
public java.util.Map<java.lang.String,java.lang.Object> getMetaProperties()
- Returns:
- Map (case insensitive keys) containing meta (additional) properties for the n-cube.
-
getMetaProperty
public java.lang.Object getMetaProperty(java.lang.String key)
Fetch the value associated to the passed in Key from the MetaProperties (if any exist). If none exist, null is returned.- Parameters:
key
- String key- Returns:
- Value associated to meta-property key
-
setMetaProperty
public java.lang.Object setMetaProperty(java.lang.String key, java.lang.Object metaPropValue)
Set (add / overwrite) a Meta Property associated to this Column.- Parameters:
key
- String key name of meta propertymetaPropValue
- Object value to associate to key- Returns:
- prior value associated to key or null if none was associated prior
-
removeMetaProperty
public java.lang.Object removeMetaProperty(java.lang.String key)
Remove a meta-property entry- Parameters:
key
- String- Returns:
- Value associated to meta-property key
-
addMetaProperties
public void addMetaProperties(java.util.Map<java.lang.String,java.lang.Object> allAtOnce)
Add a Map of meta properties all at once.- Parameters:
allAtOnce
- Map of meta properties to add
-
clearMetaProperties
public void clearMetaProperties()
Remove all meta properties associated to this Column.
-
getId
public long getId()
- Returns:
- long ID of this column. Note that the ID of a column is guaranteed to by unique within a given n-cube, but not across n-cubes.
-
setId
protected void setId(long id)
-
getColumnName
public java.lang.String getColumnName()
Get the optional name of a column. Since names are optional they are stored within meta-properties. Any column used on any type of axis can have a name.- Returns:
- String name of Column if one is set, otherwise return null.
-
setColumnName
public void setColumnName(java.lang.String name)
Set the optional name of a column. Since names are optional they are stored within meta-properties. Any column used on any type of axis can have a name.- Parameters:
name
- String name for column.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equals
in classjava.lang.Object
-
getValue
public java.lang.Comparable getValue()
- Returns:
- Comparable value of the column.
-
setValue
protected void setValue(java.lang.Comparable v)
Set the value of a column.- Parameters:
v
- Comparable instance to store as the column value.
-
isDefault
public boolean isDefault()
- Returns:
- boolean true if this is the Default column, false otherwise. The Default Column's value is always null.
-
getValueThatMatches
public java.lang.Comparable getValueThatMatches()
- Returns:
- a value that will match this column. This returns column value if it is a DISCRETE axis column. If it is a Range axis column, the 'low' value will be returned (low is inclusive, high is exclusive). If it is a RangeSet axis column, then the first value will be returned. If it is a Range, then the low value of that Range will be returned. In all cases, the returned value can be used to match against an axis including this column and the returned value will match this column.
-
setDisplayOrder
protected void setDisplayOrder(int order)
-
getDisplayOrder
public int getDisplayOrder()
-
compareTo
public int compareTo(java.lang.Comparable that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<java.lang.Comparable>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-