net.sf.xbus.base.core.strings
Class CardinalityStrings

java.lang.Object
  extended by net.sf.xbus.base.core.strings.CardinalityStrings

public class CardinalityStrings
extends java.lang.Object

CardinalityStrings offers some methods for treating cardinality strings like "1..*". Allowed cardinality string consist

In case of an interval the lower bound must be a positive integer (including zero) and the upper bound must be a strictly positive integer or "*". "*" means "arbitrary".

Author:
Stephan Düwel

Constructor Summary
CardinalityStrings()
           
 
Method Summary
static int getCardinalityHigh(java.lang.String card, boolean isKnownAsCardinalityInterval)
          getCardinalityHigh extracts the upper bound from a cardinality string like "1..*".
static int getCardinalityLow(java.lang.String card, boolean isKnownAsCardinalityInterval)
          getCardinalityLow extracts the lower bound from a cardinality string like "1..*".
static boolean isCardinalityInterval(java.lang.String card, boolean isKnownAsValidCardinality)
          isCardinalityInterval checks if a given string is a cardinatily interval like "1..*".
static boolean isCardinalityValid(java.lang.String card)
          isCardinalityValid checks if a string is a well-formed cardinality.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardinalityStrings

public CardinalityStrings()
Method Detail

isCardinalityValid

public static boolean isCardinalityValid(java.lang.String card)
isCardinalityValid checks if a string is a well-formed cardinality.

Parameters:
card - the string to check
Returns:
true for well-formed cardinality string, otherwise false

isCardinalityInterval

public static boolean isCardinalityInterval(java.lang.String card,
                                            boolean isKnownAsValidCardinality)
isCardinalityInterval checks if a given string is a cardinatily interval like "1..*".

Parameters:
card - the string to check
isKnownAsValidCardinality - Is the string already known as a well-formed cardinality specification? Otherwise this fact will be checked.
Returns:
true for a well-formed cardinality interval, otherwise false

getCardinalityLow

public static int getCardinalityLow(java.lang.String card,
                                    boolean isKnownAsCardinalityInterval)
                             throws XException
getCardinalityLow extracts the lower bound from a cardinality string like "1..*".

Parameters:
card - the cardinality string
isKnownAsCardinalityInterval - Is the cardinality string already known as a well-formed interval specification? Otherwise this fact will be checked.
Returns:
the extracted lower bound which must be an positive integer
Throws:
XException - in case of a mal-formed cardinality string or a negative lower bound

getCardinalityHigh

public static int getCardinalityHigh(java.lang.String card,
                                     boolean isKnownAsCardinalityInterval)
                              throws XException
getCardinalityHigh extracts the upper bound from a cardinality string like "1..*".

Parameters:
card - the cardinality string
isKnownAsCardinalityInterval - Is the cardinality string already known as a well-formed interval specification? Otherwise this fact will be checked.
Returns:
the extracted upper bound which must be an positive integer, Integer.MAX_VALUE in case of a "*"
Throws:
XException - in case of a mal-formed cardinality string or a negative upper bound