Package adams.data.report
Class AbstractField
- java.lang.Object
-
- adams.data.report.AbstractField
-
- All Implemented Interfaces:
CloneHandler<AbstractField>
,Serializable
,Comparable
- Direct Known Subclasses:
Field
public abstract class AbstractField extends Object implements Serializable, Comparable, CloneHandler<AbstractField>
A single report field identifier.- Version:
- $Revision$
- Author:
- dale (dale at cs dot waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DataType
m_DataType
the data type.protected String
m_Name
the name of the field.protected String
m_Prefix
the prefix part of the name (if applicable).protected String
m_Suffix
the suffix part of the name (if applicable).static String
SEPARATOR
the separator.static String
SEPARATOR_DISPLAY
the replacement for tabs in the fields when displaying in the GUI.static String
SEPARATOR_ESCAPED
the escaped separator.
-
Constructor Summary
Constructors Constructor Description AbstractField()
Constructor.AbstractField(AbstractField field)
Uses the values from the given field.AbstractField(String name, DataType dt)
Constructor.AbstractField(String prefix, String suffix, DataType dt)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Object o)
Compares this object with the specified object for order.boolean
equals(Object o)
The equals method (only uses the name).protected static String
escape(String name, String separator)
Escapes the name.static String
fixString(String s)
Replaces ' with `.AbstractField
getClone()
Returns a cloned copy of itself.DataType
getDataType()
Get datatype.String
getName()
Get field name.String
getPrefix()
Returns the prefix for compound fields.String
getSuffix()
Returns the suffix for compound fields.int
hashCode()
Hashcode so can be used as hashtable key.boolean
isCompound()
Checks whether the name is a compound one, i.e., contains a SEPARATOR.abstract AbstractField
newField(String name, DataType dtype)
Returns a new field.static AbstractField
parseField(String s)
Parses the given string and returns the field.AbstractField
replacePrefix(String prefix)
Replaces the prefix of a Field and returns a new Field object.abstract AbstractField
replacePrefix(String prefix, DataType dt)
Replaces the prefix of a Field and returns a new Field object.AbstractField
replaceSuffix(String suffix)
Replaces the suffix of a Field and returns a new Field object.abstract AbstractField
replaceSuffix(String suffix, DataType dt)
Replaces the suffix of a Field and returns a new Field object.String[]
split()
Returns the name split up in its single parts.String
toDisplayString()
Returns the name of the field.String
toParseableString()
Returns the name and the type (format: name[type]).String
toString()
Returns the name of the field.String
toString(Object o)
String representation.protected static String
unescape(String name)
Unescapes the name.Object
valueOf(String s)
Parse string to appropriate datatype.
-
-
-
Field Detail
-
SEPARATOR
public static final String SEPARATOR
the separator.- See Also:
- Constant Field Values
-
SEPARATOR_ESCAPED
public static final String SEPARATOR_ESCAPED
the escaped separator.- See Also:
- Constant Field Values
-
SEPARATOR_DISPLAY
public static final String SEPARATOR_DISPLAY
the replacement for tabs in the fields when displaying in the GUI.- See Also:
- Constant Field Values
-
m_Name
protected String m_Name
the name of the field.
-
m_Prefix
protected String m_Prefix
the prefix part of the name (if applicable).
-
m_Suffix
protected String m_Suffix
the suffix part of the name (if applicable).
-
m_DataType
protected DataType m_DataType
the data type.
-
-
Constructor Detail
-
AbstractField
public AbstractField()
Constructor. Sets the name to null and the type to UNKNOWN.
-
AbstractField
public AbstractField(AbstractField field)
Uses the values from the given field.- Parameters:
field
- the field to use as basis
-
AbstractField
public AbstractField(String prefix, String suffix, DataType dt)
Constructor.- Parameters:
prefix
- the prefix of the compound fieldsuffix
- the prefix of the compound fielddt
- the type of the field, UNKNOWN is used if null
-
-
Method Detail
-
getName
public String getName()
Get field name.- Returns:
- the field name
-
getDataType
public DataType getDataType()
Get datatype.- Returns:
- the data type
-
isCompound
public boolean isCompound()
Checks whether the name is a compound one, i.e., contains a SEPARATOR.- Returns:
- true if name is a compound one
- See Also:
SEPARATOR
-
split
public String[] split()
Returns the name split up in its single parts.- Returns:
- the parts of the compound name
- See Also:
SEPARATOR
-
toParseableString
public String toParseableString()
Returns the name and the type (format: name[type]). Can be restored with parseField.- Returns:
- the name and type
- See Also:
parseField(String)
-
toString
public String toString()
Returns the name of the field.
-
toDisplayString
public String toDisplayString()
Returns the name of the field.- Returns:
- the name
-
toString
public String toString(Object o)
String representation.- Parameters:
o
- the object to turn into a string- Returns:
- the string
-
valueOf
public Object valueOf(String s)
Parse string to appropriate datatype.- Parameters:
s
- the string to parse- Returns:
- the parsed object: STRING, NUMERIC or BOOLEAN
-
escape
protected static String escape(String name, String separator)
Escapes the name.- Parameters:
name
- the name to escapeseparator
- the separator to use- Returns:
- the escaped name
-
unescape
protected static String unescape(String name)
Unescapes the name.- Parameters:
name
- the name to unescape- Returns:
- the unescaped name
-
parseField
public static AbstractField parseField(String s)
Parses the given string and returns the field. The type of the field can be append with parentheses: name[type]. Otherwise, UNKNOWN is used as type.- Parameters:
s
- the string to parse- Returns:
- the parsed field
-
getClone
public AbstractField getClone()
Returns a cloned copy of itself.- Specified by:
getClone
in interfaceCloneHandler<AbstractField>
- Returns:
- the clone
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
The equals method (only uses the name).
-
hashCode
public int hashCode()
Hashcode so can be used as hashtable key. Returns the hashcode of the name.
-
getPrefix
public String getPrefix()
Returns the prefix for compound fields.- Returns:
- the prefix, null if not compound field
-
getSuffix
public String getSuffix()
Returns the suffix for compound fields.- Returns:
- the suffix, null if not compound field
-
newField
public abstract AbstractField newField(String name, DataType dtype)
Returns a new field.- Parameters:
name
- the name of the fielddtype
- the data type of the field- Returns:
- the new field
-
replacePrefix
public AbstractField replacePrefix(String prefix)
Replaces the prefix of a Field and returns a new Field object. The Field must be a compound object, if not a clone of the field is returned.- Parameters:
prefix
- the new prefix- Returns:
- the generated field
-
replacePrefix
public abstract AbstractField replacePrefix(String prefix, DataType dt)
Replaces the prefix of a Field and returns a new Field object. The Field must be a compound object, if not a clone of the field is returned.- Parameters:
prefix
- the new prefixdt
- the data type to use- Returns:
- the generated field
-
replaceSuffix
public AbstractField replaceSuffix(String suffix)
Replaces the suffix of a Field and returns a new Field object. The Field must be a compound object, if not a clone of the field is returned.- Parameters:
suffix
- the new suffix- Returns:
- the generated field
-
replaceSuffix
public abstract AbstractField replaceSuffix(String suffix, DataType dt)
Replaces the suffix of a Field and returns a new Field object. The Field must be a compound object, if not a clone of the field is returned.- Parameters:
suffix
- the new suffixdt
- the data type to use- Returns:
- the generated field
-
-