Package adams.core.base
Class BaseInterval
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.AbstractBaseString
-
- adams.core.base.BaseInterval
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,Serializable
,Comparable
public class BaseInterval extends AbstractBaseString
For specifying mathematical intervals like (1;1.2] or [-3.1;7.8].- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALL
the placeholder for all.static int
DEFAULT_NUM_DECIMALS
the default number of decimals to use.static int
DOUBLE_TOSTRING
the number of decimals value for just using Double.toString method.protected boolean
m_Infinite
from negative to positive infinity.protected double
m_Lower
the lower bound of the interval.protected boolean
m_LowerInclusive
whether the lower is inclusive.protected int
m_NumDecimals
the number of decimals to display (-1 for Double.toString).protected double
m_Upper
the upper bound of the interval.protected boolean
m_UpperInclusive
whether the upper is inclusive.static String
NEGATIVE_INFINITY
the placeholder for -Inf.static String
POSITIVE_INFINITY
the placeholder for +Inf.-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BaseInterval()
Initializes the string with empty string.BaseInterval(double lower, boolean lowerInclusive, double upper, boolean upperInclusive)
Initializes the object with the specified bounds.BaseInterval(double lower, boolean lowerInclusive, double upper, boolean upperInclusive, int numDecimals)
Initializes the object with the specified bounds.BaseInterval(double lower, double upper)
Initializes the object with the specified (inclusive) bounds.BaseInterval(double lower, double upper, int numDecimals)
Initializes the object with the specified (inclusive) bounds.BaseInterval(int numDecimals)
Initializes the string with empty string.BaseInterval(String s)
Initializes the object with the specified interval.BaseInterval(String s, int numDecimals)
Initializes the object with the specified interval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
convert(String value)
Converts the string according to the specified conversion.double
getLower()
Returns the lower bound.int
getNumDecimals()
Returns the number of decimals to use in the ranges.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).double
getUpper()
Returns the upper bound.protected void
initialize()
Initializes the members.boolean
isInfinite()
Returns whether the range is from negative to positive infinity.boolean
isInside(double value)
Checks whether the value falls inside the bounds, taking the inclusivity of the bounds into account.boolean
isLowerInclusive()
Returns whether the lower bound is inclusive.boolean
isUpperInclusive()
Returns whether the upper bound is inclusive.boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.protected Object[]
parse(String value)
Parses the string.void
setNumDecimals(int value)
Sets the number of decimals to use in the ranges.-
Methods inherited from class adams.core.base.AbstractBaseString
getValue, isEmpty, length, setValue, stringValue
-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Field Detail
-
NEGATIVE_INFINITY
public static final String NEGATIVE_INFINITY
the placeholder for -Inf.- See Also:
- Constant Field Values
-
POSITIVE_INFINITY
public static final String POSITIVE_INFINITY
the placeholder for +Inf.- See Also:
- Constant Field Values
-
ALL
public static final String ALL
the placeholder for all.- See Also:
- Constant Field Values
-
DOUBLE_TOSTRING
public static final int DOUBLE_TOSTRING
the number of decimals value for just using Double.toString method.- See Also:
- Constant Field Values
-
DEFAULT_NUM_DECIMALS
public static final int DEFAULT_NUM_DECIMALS
the default number of decimals to use.- See Also:
- Constant Field Values
-
m_Infinite
protected boolean m_Infinite
from negative to positive infinity.
-
m_Lower
protected double m_Lower
the lower bound of the interval.
-
m_LowerInclusive
protected boolean m_LowerInclusive
whether the lower is inclusive.
-
m_Upper
protected double m_Upper
the upper bound of the interval.
-
m_UpperInclusive
protected boolean m_UpperInclusive
whether the upper is inclusive.
-
m_NumDecimals
protected int m_NumDecimals
the number of decimals to display (-1 for Double.toString).
-
-
Constructor Detail
-
BaseInterval
public BaseInterval()
Initializes the string with empty string.
-
BaseInterval
public BaseInterval(int numDecimals)
Initializes the string with empty string.- Parameters:
numDecimals
- the number of decimals to use for printing the ranges; -1 for Double.toString
-
BaseInterval
public BaseInterval(String s)
Initializes the object with the specified interval.- Parameters:
s
- the interval to parse
-
BaseInterval
public BaseInterval(String s, int numDecimals)
Initializes the object with the specified interval.- Parameters:
s
- the interval to parsenumDecimals
- the number of decimals to use for printing the ranges; -1 for Double.toString
-
BaseInterval
public BaseInterval(double lower, double upper)
Initializes the object with the specified (inclusive) bounds.- Parameters:
lower
- the lower boundupper
- the upper bound
-
BaseInterval
public BaseInterval(double lower, double upper, int numDecimals)
Initializes the object with the specified (inclusive) bounds.- Parameters:
lower
- the lower boundupper
- the upper boundnumDecimals
- the number of decimals to use for printing the ranges; -1 for Double.toString
-
BaseInterval
public BaseInterval(double lower, boolean lowerInclusive, double upper, boolean upperInclusive)
Initializes the object with the specified bounds.- Parameters:
lower
- the lower boundlowerInclusive
- whether the lower bound is inclusiveupper
- the upper boundupperInclusive
- whether the upper bound is inclusive
-
BaseInterval
public BaseInterval(double lower, boolean lowerInclusive, double upper, boolean upperInclusive, int numDecimals)
Initializes the object with the specified bounds.- Parameters:
lower
- the lower boundlowerInclusive
- whether the lower bound is inclusiveupper
- the upper boundupperInclusive
- whether the upper bound is inclusivenumDecimals
- the number of decimals to use for printing the ranges; -1 for Double.toString
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractBaseString
-
setNumDecimals
public void setNumDecimals(int value)
Sets the number of decimals to use in the ranges.- Parameters:
value
- the number of decimals; -1 for Double.toString
-
getNumDecimals
public int getNumDecimals()
Returns the number of decimals to use in the ranges.- Returns:
- the number of decimals; -1 for Double.toString
-
parse
protected Object[] parse(String value)
Parses the string.- Parameters:
value
- the string value to parse- Returns:
- null if failed to parse, otherwise lower incl/lower/upper/upper incl
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Overrides:
isValid
in classAbstractBaseString
- Parameters:
value
- the string value to check- Returns:
- true if empty or interval
-
convert
protected String convert(String value)
Converts the string according to the specified conversion.- Overrides:
convert
in classAbstractBaseString
- Parameters:
value
- the string to convert- Returns:
- the converted string
-
isLowerInclusive
public boolean isLowerInclusive()
Returns whether the lower bound is inclusive.- Returns:
- true if inclusive
-
getLower
public double getLower()
Returns the lower bound.- Returns:
- the lower bound
-
isUpperInclusive
public boolean isUpperInclusive()
Returns whether the upper bound is inclusive.- Returns:
- true if inclusive
-
getUpper
public double getUpper()
Returns the upper bound.- Returns:
- the upper bound
-
isInside
public boolean isInside(double value)
Checks whether the value falls inside the bounds, taking the inclusivity of the bounds into account.- Parameters:
value
- the value to check- Returns:
- true if within bounds
-
isInfinite
public boolean isInfinite()
Returns whether the range is from negative to positive infinity.- Returns:
- true if no bounds
- See Also:
ALL
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classAbstractBaseString
- Returns:
- the tool tip
-
-