org.cip4.jdflib.datatypes
Class JDFIntegerRange

java.lang.Object
  extended by org.cip4.jdflib.datatypes.JDFRange
      extended by 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
JDFIntegerRange()
          constructs an empty integer range
JDFIntegerRange(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 values
JDFIntegerRange(int xmin, int xmax, int xdef)
          constructs an integer range with the given int values
JDFIntegerRange(JDFIntegerRange ir)
          constructs an integer range with a given JDFIntegerRange
JDFIntegerRange(String s)
          constructs an integer range with the given string
JDFIntegerRange(String s, int xdef)
          constructs an integer range with the given string
 
Method Summary
 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.
static JDFIntegerRange createIntegerRange(String s)
          factory for JDFIntegerRange that silently returns null in case of illegal strings
 boolean equals(Object other)
          equals - returns true if both JDFIntegerRange are equal otherwise false
 int getDef()
          getDef - gets xDef, the default value which is used for negative numbers
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
 int getElement(int i)
          Element - value of the ith element in the range.
 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, -1 is returned
 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"
static JDFIntegerRange getIntegerRange(String range)
          create a JDFIntegerRange from a string - return null if no go
 int getLeft()
          getLeft - returns the left int object
protected  Object getLeftObject()
           
 int getLowerValue()
          getLowerValue - returns the lower value of the bounds for example 4~6 return 4, 7~5 return 5
 int getRight()
          getRight - returns the right int object
protected  Object getRightObject()
           
 int getUpperValue()
          getUpperValue - returns the upper value of the bounds for example 4~6 return 6, 7~5 return 7
 int hashCode()
          hashCode complements equals() to fulfill the equals/hashCode contract
protected  void init(int xmin, int xmax, int xdef)
          Initialization
protected  boolean inObjectRange(Object other)
           
 boolean inRange(int x)
          inRange - returns true if (lower value >= x <= upper value)
 boolean isPartOfRange(JDFRange r)
          isPartOfRange - is range 'r' within this range?
 boolean isValid(String s)
          isValid - validate the given String
 void scale(int f)
          scale - scales both values but NOT the default
 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
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
 void setLeft(int x)
          setLeft - sets the left int object
 void setLowerValue(int x)
          setLowerValue - sets the lower value of the bounds
 void setRight(int x)
          setRight - sets the right int object
 void setUpperValue(int x)
          setUpperValue - sets the upper value of the bounds
 String toString()
          toString
 
Methods inherited from class org.cip4.jdflib.datatypes.JDFRange
getString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 value
xmax - 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 value
xmax - the given max value
xdef - number of items

JDFIntegerRange

public JDFIntegerRange(JDFIntegerRange ir)
constructs an integer range with a given JDFIntegerRange

Parameters:
ir - the given JDFIntegerRange

JDFIntegerRange

public JDFIntegerRange(String s)
                throws DataFormatException
constructs an integer range with the given string

Parameters:
s - the given string
Throws:
DataFormatException - - if the String has not a valid format

JDFIntegerRange

public JDFIntegerRange(String s,
                       int xdef)
                throws DataFormatException
constructs an integer range with the given string

Parameters:
s - the given string
xdef - value which is used for negative numbers the value that -1 will represent in this range
Throws:
DataFormatException - - if the String has not a valid format
Method Detail

createIntegerRange

public static JDFIntegerRange createIntegerRange(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(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


toString

public String toString()
toString

Overrides:
toString in class Object
Returns:
String

isValid

public boolean isValid(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(Object other)
equals - returns true if both JDFIntegerRange are equal otherwise false

Overrides:
equals in class JDFRange
Parameters:
other - Object to compare
Returns:
boolean - true if equal otherwise false

hashCode

public int hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract

Overrides:
hashCode in class JDFRange
Returns:
int

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:
isPartOfRange in class JDFRange
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, -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 NoSuchElementException
Element - 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:
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 Object getRightObject()
Specified by:
getRightObject in class JDFRange

getLeftObject

protected Object getLeftObject()
Specified by:
getLeftObject in class JDFRange

inObjectRange

protected boolean inObjectRange(Object other)
Overrides:
inObjectRange in class JDFRange


Copyright © 2013. All Rights Reserved.