de.bsd.x2svg
Class Cardinality

java.lang.Object
  extended by de.bsd.x2svg.Cardinality

public class Cardinality
extends java.lang.Object

Cardinalities for elements. This is expressed as [from,to] with from being the lower bound and to the upper. If 'from' is 0, the Cardinality is optional. If the flag 'empty' is set, then the Cardinality is optional, but from is marked as the empty string. This is done to allow for rendering of elements like a non-optional element, while still having a an empty 'from value.

Author:
hwr@pilhuhn.de

Nested Class Summary
static class Cardinality.DTDValues
          Cardinalities as found in DTDs
 
Field Summary
private  boolean empty
           
private  java.lang.String from
          lower value
private  java.lang.String to
          upper value
 
Constructor Summary
Cardinality(boolean empty)
          Construct a Cardinality object where to and from are empty.
Cardinality(Cardinality.DTDValues dtdValue)
          Construct a Cardinality object by means of values from a DTD
Cardinality(int from, int to)
          Construct a Cardinality object with explicitly given from and to Note: infinite must be given as Integer.MAX_VALUE
Cardinality(java.lang.String from, java.lang.String to)
          Construct a Cardinality object with explicitly given from and to as String
 
Method Summary
 java.lang.String getFrom()
           
 java.lang.String getTo()
           
 boolean isOptional()
          Is this element optional (from is 0 or empty or null)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

from

private java.lang.String from
lower value


to

private java.lang.String to
upper value


empty

private boolean empty
Constructor Detail

Cardinality

public Cardinality(boolean empty)
Construct a Cardinality object where to and from are empty. This can be used if X2svg renders structures where giving a Cardinality makes no sense.

Parameters:
empty - true if no cardinality should be used.

Cardinality

public Cardinality(java.lang.String from,
                   java.lang.String to)
Construct a Cardinality object with explicitly given from and to as String

Parameters:
from - the lower value of the cardinality pair
to - upper value of cardinality pair. Infinite should be given as Asterisk ('*')

Cardinality

public Cardinality(int from,
                   int to)
Construct a Cardinality object with explicitly given from and to Note: infinite must be given as Integer.MAX_VALUE

Parameters:
from - the lower value of the cardinality pair
to - upper value of cardinality pair. Unbounded is expressed as -1

Cardinality

public Cardinality(Cardinality.DTDValues dtdValue)
Construct a Cardinality object by means of values from a DTD

Parameters:
dtdValue - Cardinalities as found in DTDs
Method Detail

isOptional

public boolean isOptional()
Is this element optional (from is 0 or empty or null)

Returns:
true if the element is an optional element

getFrom

public java.lang.String getFrom()
Returns:
the lower value of the cardinality pair

getTo

public java.lang.String getTo()
Returns:
the higher value of the cardinality pair


x2svg version 1.2.1