Package adams.data.featureconverter
Class HeaderDefinition
- java.lang.Object
-
- adams.data.featureconverter.HeaderDefinition
-
- All Implemented Interfaces:
CloneHandler<HeaderDefinition>
,Serializable
,Comparable<HeaderDefinition>
public class HeaderDefinition extends Object implements Serializable, Comparable<HeaderDefinition>, CloneHandler<HeaderDefinition>
Container for storing header information.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HeaderDefinition()
Initializes the header with default dataset nameDEFAULT_DATASET_NAME
and empty set of features.HeaderDefinition(String dataset)
Initializes the header with the given dataset name and empty set of features.HeaderDefinition(String dataset, List<String> names, List<DataType> types)
Initializes the header.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, String name, DataType type)
Inserts the definition at the specified position.void
add(HeaderDefinition definition)
Adds all the definitions at the end.void
add(String name, DataType type)
Adds the definition at the end.int
compareTo(HeaderDefinition o)
Compares itself with the specified object.boolean
equals(Object obj)
Returns whether this object is the same as the specified one.HeaderDefinition
getClone()
Returns a clone of the object.String
getDataset()
Returns the name of the dataset.String
getName(int index)
Returns the name at the specified index.List<String>
getNames()
Returns the names.DataType
getType(int index)
Returns the data type at the specified index.List<DataType>
getTypes()
Returns the data types.int
hashCode()
Returns the hashcode.void
remove(int index)
Removes the specified definition.void
rename(int index, String name)
Renames the name at the specified index.void
setDataset(String value)
Sets the name of the dataset.int
size()
Returns the number of fields.String
toString()
Returns the header definition as string.
-
-
-
Field Detail
-
DEFAULT_DATASET_NAME
public static final String DEFAULT_DATASET_NAME
the default dataset name.- See Also:
- Constant Field Values
-
m_Dataset
protected String m_Dataset
the name of the "dataset".
-
m_HashCode
protected Integer m_HashCode
the hashcode.
-
-
Constructor Detail
-
HeaderDefinition
public HeaderDefinition()
Initializes the header with default dataset nameDEFAULT_DATASET_NAME
and empty set of features.
-
HeaderDefinition
public HeaderDefinition(String dataset)
Initializes the header with the given dataset name and empty set of features.- Parameters:
dataset
- the name of the dataset, usesDEFAULT_DATASET_NAME
if null
-
-
Method Detail
-
getClone
public HeaderDefinition getClone()
Returns a clone of the object.- Specified by:
getClone
in interfaceCloneHandler<HeaderDefinition>
- Returns:
- the clone
-
setDataset
public void setDataset(String value)
Sets the name of the dataset.- Parameters:
value
- the name, usesDEFAULT_DATASET_NAME
if null
-
getDataset
public String getDataset()
Returns the name of the dataset.- Returns:
- the name
-
size
public int size()
Returns the number of fields.- Returns:
- the total
-
getName
public String getName(int index)
Returns the name at the specified index.- Parameters:
index
- the index of the name to retrieve- Returns:
- the name
-
getType
public DataType getType(int index)
Returns the data type at the specified index.- Parameters:
index
- the index of the data type to retrieve- Returns:
- the data type
-
rename
public void rename(int index, String name)
Renames the name at the specified index.- Parameters:
index
- the index of the name to renamename
- the new name
-
add
public void add(int index, String name, DataType type)
Inserts the definition at the specified position.- Parameters:
index
- the index to insert the definitionname
- the feature nametype
- the data type of the feature
-
add
public void add(String name, DataType type)
Adds the definition at the end.- Parameters:
name
- the feature nametype
- the data type of the feature
-
add
public void add(HeaderDefinition definition)
Adds all the definitions at the end.- Parameters:
definition
- the definitions to add
-
remove
public void remove(int index)
Removes the specified definition.- Parameters:
index
- the index of the name/type to remove
-
hashCode
public int hashCode()
Returns the hashcode.
-
compareTo
public int compareTo(HeaderDefinition o)
Compares itself with the specified object.- Specified by:
compareTo
in interfaceComparable<HeaderDefinition>
- Parameters:
o
- the object to compare with- Returns:
- returns less than, equal to or greater than zero if this object is less than, equal to or greater than the specified object
-
equals
public boolean equals(Object obj)
Returns whether this object is the same as the specified one.
-
-