public abstract class NumericalValue extends Object
SingleNumericalValue
and NumericalValueRange
. Objects of these two
classes represent single integers and integer intervals, respectively, and can be parsed from any properly formatted
key=value pair value, be they formatted in decimal, hexadecimal, or Base64 notation.
Instances of NumericalValue
can be intersected, i.e. that by using either the
intersect(NumericalValue)
or the intersect(NumericalValue, NumericalValue)
, a
NumericalValue
can be created which encompasses all integers that are part of the range of values represented
by the intersected NumericalValue
objects.
For example, if the interval [1,10] is intersected with the interval [5,15], the result would be a
NumericalValueRange
representing the interval [5,10]. Intersecting an interval with a single number would
return the number, but only if the number is part of the interval. Generally, both methods return null
if there is no overlap.
Modifier and Type | Field and Description |
---|---|
static Pattern |
BASE_64_CONSTANT_PATTERN
A precompiled pattern for matching Base64 integer
String . |
static Pattern |
DECIMAL_CONSTANT_PATTERN
A precompiled pattern for matching decimal integer
String . |
static Pattern |
HEX_CONSTANT_PATTERN
A precompiled pattern for matching hexadecimal integer
String . |
static Pattern |
NUMERICAL_RANGE_PATTERN
A precompiled pattern for matching decimal, hexadecimal, and Base64 integer interval
String (two integers
separated by '~'). |
static Pattern |
SINGLE_CONSTANT_PATTERN
A precompiled pattern for matching decimal, hexadecimal, and Base64 integer
String . |
Constructor and Description |
---|
NumericalValue() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
contains(int value)
Returns true if the passed integer lies completely inside the interval represented by this
NumericalValue
. |
abstract boolean |
contains(Object value)
Returns true if the passed
Integer or NumericalValue lies completely inside the interval
represented by this NumericalValue . |
NumericalValue |
intersect(NumericalValue value)
Returns a
NumericalValue spanning the overlap of this NumericalValue and the parameter. |
static NumericalValue |
intersect(NumericalValue a,
NumericalValue b)
Returns a
NumericalValue representing the intersection of the two parameters |
static NumericalValue |
parseNumericalValue(String value)
Parses a
NumericalValue from a String . |
public static final Pattern DECIMAL_CONSTANT_PATTERN
String
.public static final Pattern HEX_CONSTANT_PATTERN
String
.public static final Pattern BASE_64_CONSTANT_PATTERN
String
.public static final Pattern SINGLE_CONSTANT_PATTERN
String
.public static final NumericalValue parseNumericalValue(String value)
NumericalValue
from a String
.value
- the String
to parse.NumericalValue
or null
if the parameter does not match any of the supported
patterns (specified by the iSCSI standard).public NumericalValue intersect(NumericalValue value)
NumericalValue
spanning the overlap of this NumericalValue
and the parameter.value
- the NumericalValue
to be intersected with this objectNumericalValue
representing the intersection of this NumericalValue
with the parameterpublic static NumericalValue intersect(NumericalValue a, NumericalValue b)
NumericalValue
representing the intersection of the two parametersa
- the first NumericalValue
b
- the second NumericalValue
NumericalValue
representing the intersection of the two parameterspublic abstract boolean contains(Object value)
Integer
or NumericalValue
lies completely inside the interval
represented by this NumericalValue
. If the parameter is not an Integer
or a
NumericalValue
, the method will return false
.value
- the Integer
or NumericalValue
to checktrue
if the value is complete contained, false
if it is notpublic abstract boolean contains(int value)
NumericalValue
.value
- the integer to checktrue
if the value is complete contained, false
if it is notCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.