Package org.cip4.jdflib.datatypes
Class JDFIntegerRange
- java.lang.Object
-
- org.cip4.jdflib.datatypes.JDFRange
-
- org.cip4.jdflib.datatypes.JDFIntegerRange
-
- All Implemented Interfaces:
JDFBaseDataTypes
public class JDFIntegerRange extends JDFRange
This class represents an integer range (JDFIntegerRange). It is a pair of 2 integer values separated by a tilde "~", for example "123 ~ 145" negative values are treated differently depending on the value of m_defaultXDef @see getDefaultDef
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
-
-
Field Summary
-
Fields inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
EPSILON, MAX_CMYK_COLOR, MAX_LAB_COLOR, MAX_MATRIX_DIMENSION, MAX_RECTANGLE_DIMENSION, MAX_RGB_COLOR, MAX_SHAPE_DIMENSION, MAX_XY_DIMENSION
-
-
Constructor Summary
Constructors Constructor Description JDFIntegerRange()constructs an empty integer rangeJDFIntegerRange(int x)constructs an integer range with the given int (both values are equal)JDFIntegerRange(int xmin, int xmax)constructs an integer range with the given int valuesJDFIntegerRange(int xmin, int xmax, int xdef)constructs an integer range with the given int valuesJDFIntegerRange(java.lang.String s)constructs an integer range with the given stringJDFIntegerRange(java.lang.String s, int xdef)constructs an integer range with the given stringJDFIntegerRange(JDFIntegerRange ir)constructs an integer range with a given JDFIntegerRange
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanappend(int x)append - appends a value to this range, returns true if possible returns false if the element is not the next element in the list, it only appends on the right side of the range.static JDFIntegerRangecreateIntegerRange(java.lang.String s)factory for JDFIntegerRange that silently returns null in case of illegal stringsbooleanequals(java.lang.Object other)equals - returns true if both JDFIntegerRange are equal otherwise falseintgetDef()getDef - gets xDef, the default value which is used for negative numbersstatic intgetDefaultDef()getDefaultDef - gets the preset for xDef, which will be used when constructing an IntegerRange
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are usedintgetElement(int i)Element - value of the ith element in the range.
If the index is negativ the position is counted from the end of the range.intgetElementCount()getElementCount - returns the number of elements in this range, on the C++ side of the JDF library this method is called NElements if any if any range cannot be resolved due to an unknown negative value without a known default or a negative value > default, -1 is returnedJDFIntegerListgetIntegerList()getIntegerList - returns the integer range as an integer list
for example an integer range of "5~9" will be returned as "5 6 7 8 9"static JDFIntegerRangegetIntegerRange(java.lang.String range)create a JDFIntegerRange from a string - return null if no gointgetLeft()getLeft - returns the left int objectprotected java.lang.IntegergetLeftObject()java.lang.StringgetLeftString(int precision)intgetLowerValue()getLowerValue - returns the lower value of the bounds for example 4~6 return 4, 7~5 return 5intgetRight()getRight - returns the right int objectprotected java.lang.IntegergetRightObject()java.lang.StringgetRightString(int precision)intgetUpperValue()getUpperValue - returns the upper value of the bounds for example 4~6 return 6, 7~5 return 7inthashCode()hashCode complements equals() to fulfill the equals/hashCode contractprotected voidinit(int xmin, int xmax, int xdef)Initializationprotected booleaninObjectRange(java.lang.Object other)booleaninRange(int x)inRange - returns true if (lower value >= x <= upper value)booleanisPartOfRange(JDFRange r)isPartOfRange - is range 'r' within this range?booleanisValid(java.lang.String s)isValid - validate the given Stringvoidscale(int f)scale - scales both values but NOT the defaultvoidsetDef(int xdef)setDef - sets xDef, the default value which is used for negative numbers
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are usedstatic voidsetDefaultDef(int xdef)setDefaultDef - sets the preset for xDef, which will be used when constructing an IntegerRange
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are usedvoidsetLeft(int x)setLeft - sets the left int objectvoidsetLowerValue(int x)setLowerValue - sets the lower value of the boundsvoidsetRight(int x)setRight - sets the right int objectvoidsetUpperValue(int x)setUpperValue - sets the upper value of the bounds-
Methods inherited from class org.cip4.jdflib.datatypes.JDFRange
getString, getXJDFString, toString
-
-
-
-
Constructor Detail
-
JDFIntegerRange
public JDFIntegerRange()
constructs an empty integer range
-
JDFIntegerRange
public JDFIntegerRange(int x)
constructs an integer range with the given int (both values are equal)- Parameters:
x- the given min and max value
-
JDFIntegerRange
public JDFIntegerRange(int xmin, int xmax)constructs an integer range with the given int values- Parameters:
xmin- the given min valuexmax- the given max value
-
JDFIntegerRange
public JDFIntegerRange(int xmin, int xmax, int xdef)constructs an integer range with the given int values- Parameters:
xmin- the given min valuexmax- the given max valuexdef- number of items
-
JDFIntegerRange
public JDFIntegerRange(JDFIntegerRange ir)
constructs an integer range with a given JDFIntegerRange- Parameters:
ir- the given JDFIntegerRange
-
JDFIntegerRange
public JDFIntegerRange(java.lang.String s) throws java.util.zip.DataFormatExceptionconstructs an integer range with the given string- Parameters:
s- the given string- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFIntegerRange
public JDFIntegerRange(java.lang.String s, int xdef) throws java.util.zip.DataFormatExceptionconstructs an integer range with the given string- Parameters:
s- the given stringxdef- value which is used for negative numbers the value that -1 will represent in this range- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
-
Method Detail
-
createIntegerRange
public static JDFIntegerRange createIntegerRange(java.lang.String s)
factory for JDFIntegerRange that silently returns null in case of illegal strings- Parameters:
s- the string to parse- Returns:
- the JDFIntegerRange, null if s is not compatible
-
getIntegerRange
public static JDFIntegerRange getIntegerRange(java.lang.String range)
create a JDFIntegerRange from a string - return null if no go- Parameters:
range-- Returns:
-
init
protected void init(int xmin, int xmax, int xdef)Initialization
-
isValid
public boolean isValid(java.lang.String s)
isValid - validate the given String- Parameters:
s- the given string- Returns:
- boolean - false if the String has not a valid format
-
equals
public boolean equals(java.lang.Object other)
equals - returns true if both JDFIntegerRange are equal otherwise false
-
hashCode
public int hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract
-
getLeft
public int getLeft()
getLeft - returns the left int object- Returns:
- int - the left int object
-
setLeft
public void setLeft(int x)
setLeft - sets the left int object- Parameters:
x- the left int object
-
getRight
public int getRight()
getRight - returns the right int object- Returns:
- int - the right int
-
scale
public void scale(int f)
scale - scales both values but NOT the default- Parameters:
f- the scaling factor
-
setRight
public void setRight(int x)
setRight - sets the right int object- Parameters:
x- the right int object
-
getLowerValue
public int getLowerValue()
getLowerValue - returns the lower value of the bounds for example 4~6 return 4, 7~5 return 5- Returns:
- int - the lower value of the range
-
setLowerValue
public void setLowerValue(int x)
setLowerValue - sets the lower value of the bounds- Parameters:
x- the new lower value of the range
-
getUpperValue
public int getUpperValue()
getUpperValue - returns the upper value of the bounds for example 4~6 return 6, 7~5 return 7- Returns:
- int the upper value of the range
-
setUpperValue
public void setUpperValue(int x)
setUpperValue - sets the upper value of the bounds- Parameters:
x- the new upper value of the range
-
inRange
public boolean inRange(int x)
inRange - returns true if (lower value >= x <= upper value)- Parameters:
x- comparison value- Returns:
- boolean - true if x in range
-
isPartOfRange
public boolean isPartOfRange(JDFRange r)
isPartOfRange - is range 'r' within this range?- Specified by:
isPartOfRangein classJDFRange- Parameters:
r- the range to test- Returns:
- boolean - true if range 'r' is within this range, else false
-
getElementCount
public int getElementCount()
getElementCount - returns the number of elements in this range, on the C++ side of the JDF library this method is called NElements if any if any range cannot be resolved due to an unknown negative value without a known default or a negative value > default, -1 is returned- Returns:
- int - the number of elements in this range, -1 if any range cannot be resolved
-
append
public boolean append(int x)
append - appends a value to this range, returns true if possible returns false if the element is not the next element in the list, it only appends on the right side of the range. For example:"3˜5" append(6) -> "3˜6" "5" append(6) -> "5˜6" "5" append(7) -> "5 7" "5˜9" append(6) -> "5˜9 6" "7˜5" append(4) -> "7˜4"
- Parameters:
x- the new value- Returns:
- boolean - true if successful
-
getElement
public int getElement(int i) throws java.util.NoSuchElementExceptionElement - value of the ith element in the range.
If the index is negativ the position is counted from the end of the range. For example the range is 3~7, the 2nd element is 5 and the -2nd element is 6. On the C++ side of the JDF library this method is called Element.- Parameters:
i- the position, if it is a negativ value start counting from the right side +1- Returns:
- int the value at the ith position
- Throws:
java.util.NoSuchElementException- - if the index is out of range
-
setDef
public void setDef(int xdef)
setDef - sets xDef, the default value which is used for negative numbers
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are used- Parameters:
xdef- the value that will represent negative values in this range
-
setDefaultDef
public static void setDefaultDef(int xdef)
setDefaultDef - sets the preset for xDef, which will be used when constructing an IntegerRange
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are used- Parameters:
xdef- - (int)1 above the value that -1 will represent in this range i.e. the value that -0, were it possible to specify, would represent
-
getDefaultDef
public static int getDefaultDef()
getDefaultDef - gets the preset for xDef, which will be used when constructing an IntegerRange
the value represents the index that is one past the end of the list
if xdef==0 (the default), the neg numbers themselves are used- Returns:
- int - (int)1 above the value that -1 will represent in this range i.e. the value that -0, were it possible to specify, would represent
-
getDef
public int getDef()
getDef - gets xDef, the default value which is used for negative numbers- Returns:
- int - one above the value that -1 will represent in this range i.e. the value that -0, were it possible to specify, would represent
-
getIntegerList
public JDFIntegerList getIntegerList()
getIntegerList - returns the integer range as an integer list
for example an integer range of "5~9" will be returned as "5 6 7 8 9"- Returns:
- JDFIntegerList - the integer list
-
getRightObject
protected java.lang.Integer getRightObject()
- Specified by:
getRightObjectin classJDFRange
-
getLeftObject
protected java.lang.Integer getLeftObject()
- Specified by:
getLeftObjectin classJDFRange
-
inObjectRange
protected boolean inObjectRange(java.lang.Object other)
- Overrides:
inObjectRangein classJDFRange
-
getRightString
public java.lang.String getRightString(int precision)
- Overrides:
getRightStringin classJDFRange
-
getLeftString
public java.lang.String getLeftString(int precision)
- Overrides:
getLeftStringin classJDFRange
-
-