org.cip4.jdflib.datatypes
Class JDFIntegerRangeList

java.lang.Object
  extended by org.cip4.jdflib.datatypes.JDFRangeList
      extended by org.cip4.jdflib.datatypes.JDFIntegerRangeList
All Implemented Interfaces:
JDFBaseDataTypes

public class JDFIntegerRangeList
extends JDFRangeList

This class is a representation of an integer range list (JDFIntegerRangeList). It is a whitespace separated list of integer ranges, for example "12~15 19~33"


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
 
Field Summary
 
Fields inherited from class org.cip4.jdflib.datatypes.JDFRangeList
rangeList
 
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
JDFIntegerRangeList()
          constructs an empty range list
JDFIntegerRangeList(JDFIntegerRange ir)
          constructs a JDFIntegerRangeList with the given JDFIntegerRange and sets xDef
JDFIntegerRangeList(JDFIntegerRangeList irl)
          constructs a JDFIntegerRangeList with the given JDFIntegerRangeList and sets the number of items
JDFIntegerRangeList(String s)
          constructs a JDFIntegerRangeList with the given string the default value for -1 is set to 0, i.e positive and negative numbers are handled explicitly
JDFIntegerRangeList(String s, int xdef)
          constructs a JDFIntegerRangeList with the given String and sets the number of items
 
Method Summary
 void append(int x)
          append - appends an integer to the last IntegerRange of the IntegerRangelist if possible, examples if the last range list element looks like: "3˜5" append(6) -> "3˜6" "5" append(6) -> "5˜6" "5" append(7) -> "5 7" "5 6" append(7) -> "5 ˜ 7" "3˜7 5˜7" append(8) -> "3˜7 5˜8" "3˜7 5˜9" append(8) -> "3˜7 5˜9 8" "3˜7 5˜7" append(18) -> "3˜7 5˜7 18" note that lists are not preserved.
 void append(int xMin, int xMax)
          append - appends a new IntegerRange to the IntegerRangeList
 void append(JDFIntegerRange r)
          append - appends a new IntegerRange to the IntegerRangeList
static JDFIntegerRangeList createIntegerRangeList(String rangelist)
          create a JDFIntegerRangeList from a string - return null if no go
 JDFIntegerRangeList deepCopy()
          deepCopy - a deep copy of this JDFIntegerRangeList
 int getDef()
          getDef - gets xDef, the default value which is used for negative numbers
 int getElement(int i)
          Element - value of the ith element in the range.
 int getElementCount()
          getElementCount - returns the number of elements in the list.
 JDFIntegerList getIntegerList()
          getIntegerList - returns this integer range list as a JDFIntegerList
static JDFIntegerRangeList getIntegerRangeList(String rangelist)
          Deprecated. use createIntegerRangeList
 boolean inRange(int x)
          inRange - returns true if the given int value is in one of the ranges of the range list
 boolean isOrdered()
          isOrdered - tests if 'this' is OrderedRangeList
 boolean isOverlapping(JDFIntegerRange newRange, JDFIntegerRange oldRange)
          isOverlapping
 boolean isUniqueOrdered()
          isUniqueOrdered - tests if 'this' is UniqueOrdered RangeList
 boolean isValid(String s)
          isValid - validate the given String
 void normalize(boolean bSort)
          normalize this range by removing any consecutive entries and creating ranges instead
 void setDef(int xdef)
          setDef - sets xDef, the default value which is used for negative numbers
if xdef==0 (the default), the neg numbers themselves are used
the value represents the index that is one past the end of the list
 void setString(String s)
          setString - parse the given string and set the integer ranges
 
Methods inherited from class org.cip4.jdflib.datatypes.JDFRangeList
at, begin, clear, elementAt, end, equals, erase, getString, getString, hashCode, isList, isPartOfRange, isPartOfRange, isUnique, remove, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDFIntegerRangeList

public JDFIntegerRangeList()
constructs an empty range list


JDFIntegerRangeList

public JDFIntegerRangeList(String s)
                    throws DataFormatException
constructs a JDFIntegerRangeList with the given string the default value for -1 is set to 0, i.e positive and negative numbers are handled explicitly

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

JDFIntegerRangeList

public JDFIntegerRangeList(String s,
                           int xdef)
                    throws DataFormatException
constructs a JDFIntegerRangeList with the given String and sets the number of items

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

JDFIntegerRangeList

public JDFIntegerRangeList(JDFIntegerRangeList irl)
constructs a JDFIntegerRangeList with the given JDFIntegerRangeList and sets the number of items

Parameters:
irl - the given JDFIntegerRangeList

JDFIntegerRangeList

public JDFIntegerRangeList(JDFIntegerRange ir)
constructs a JDFIntegerRangeList with the given JDFIntegerRange and sets xDef

Parameters:
ir - the given JDFIntegerRange
Method Detail

getIntegerRangeList

@Deprecated
public static JDFIntegerRangeList getIntegerRangeList(String rangelist)
Deprecated. use createIntegerRangeList

create a JDFIntegerRangeList from a string - return null if no go

Parameters:
rangelist -
Returns:

createIntegerRangeList

public static JDFIntegerRangeList createIntegerRangeList(String rangelist)
create a JDFIntegerRangeList from a string - return null if no go

Parameters:
rangelist -
Returns:

inRange

public boolean inRange(int x)
inRange - returns true if the given int value is in one of the ranges of the range list

Parameters:
x - the given int value to compare
Returns:
boolean - true if in range otherwise false

setString

public void setString(String s)
               throws DataFormatException
setString - parse the given string and set the integer ranges

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

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

getElementCount

public int getElementCount()
getElementCount - returns the number of elements in the list. On the C++ side of the JDF library this method is called NElements.
E.g. the following list has 14 elements: "1~5 10~15 20~22" 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

getElement

public int getElement(int i)
               throws NoSuchElementException
Element - value of the ith element in the range. If the index is negative, 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.

performace warning: don't loop over getElement for potentially large lists with many individual elements.
Prefer to call getIntegerList() and loop over the list.

Parameters:
i - the position, if it is a negative 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

append

public void append(JDFIntegerRange r)
append - appends a new IntegerRange to the IntegerRangeList

Parameters:
r - the given JDFIntegerRange

append

public void append(int xMin,
                   int xMax)
append - appends a new IntegerRange to the IntegerRangeList

Parameters:
xMin - the left value of the new range
xMax - the right value of the new range

append

public void append(int x)
append - appends an integer to the last IntegerRange of the IntegerRangelist if possible, examples if the last range list element looks like:
 "3˜5"        append(6)   -> "3˜6"
 "5"          append(6)   -> "5˜6"
 "5"          append(7)   -> "5 7"
 "5 6"        append(7)   -> "5 ˜ 7"
 "3˜7 5˜7"    append(8)   -> "3˜7 5˜8"
 "3˜7 5˜9"    append(8)   -> "3˜7 5˜9 8"
 "3˜7 5˜7"    append(18)  -> "3˜7 5˜7 18"
 
note that lists are not preserved. If you want to guarantee individual entries use append(x,x);

Parameters:
x - the given int x

getIntegerList

public JDFIntegerList getIntegerList()
getIntegerList - returns this integer range list as a JDFIntegerList

Returns:
JDFIntegerList - the integer range list as a JDFIntegerList

setDef

public void setDef(int xdef)
setDef - sets xDef, the default value which is used for negative numbers
if xdef==0 (the default), the neg numbers themselves are used
the value represents the index that is one past the end of the list

Parameters:
xdef - one 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

isOrdered

public boolean isOrdered()
isOrdered - tests if 'this' is OrderedRangeList

Specified by:
isOrdered in class JDFRangeList
Returns:
boolean - true if 'this' is a OrdneredRangeList

isUniqueOrdered

public boolean isUniqueOrdered()
isUniqueOrdered - tests if 'this' is UniqueOrdered RangeList

Specified by:
isUniqueOrdered in class JDFRangeList
Returns:
boolean - true if 'this' is UniqueOrdered RangeList

deepCopy

public JDFIntegerRangeList deepCopy()
                             throws DataFormatException
deepCopy - a deep copy of this JDFIntegerRangeList

Returns:
JDFIntegerRangeList - this object
Throws:
DataFormatException

isOverlapping

public boolean isOverlapping(JDFIntegerRange newRange,
                             JDFIntegerRange oldRange)
isOverlapping

Parameters:
newRange - the range to check, if is overlapping one of the ranges in the list

x: x.upper < y.lower,
z: z.lower > y.upper,
one of these situation, means there is no overlapping

newRange -
oldRange - the JDFRangeList removed from the RangeList, before check for overlap. If null, the oldRange is ignored
Returns:
boolean - true if there is an overlapping, otherwise false

normalize

public void normalize(boolean bSort)
normalize this range by removing any consecutive entries and creating ranges instead

Parameters:
bSort - if true, sort the rangelist prior to normalizing


Copyright © 2013. All Rights Reserved.