jInfer

cz.cuni.mff.ksi.jinfer.base.regexp
Class RegexpInterval

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.base.regexp.RegexpInterval

public final class RegexpInterval
extends Object

Class representing interval of each regexp. As in character regexp, which can have intervals for occurrences in form: {m, n} - at least m, at most n {m, } - at least m to infinity {, n} - zero to at most n Every regexp has an interval. Every interval has minimum as a natural number. Maximum can be unbounded and for this case, calling 'isUnbounded' will reveal. Calling getMax when interval is unbounded causes exception. There are some helper functions for common cases (*;+;?;{m,};{1,1})


Method Summary
static RegexpInterval getBounded(int min, int max)
          Get a bounded interval, specify min, max integers
 RegexpInterval getCopy()
          Clone existing interval\
static RegexpInterval getKleeneCross()
          Get KleeneCross, that is + quantification, min= 1, max is unbounded
static RegexpInterval getKleeneStar()
          Get KleeneStar *, asterisk.
 int getMax()
          Get the maximum value, throws exception on unbounded interval (ask using isUnbounded() before calling getMax().
 int getMin()
          Get minimum value
static RegexpInterval getOnce()
          Get interval with exactly once meaning, that is min=max=1
static RegexpInterval getOptional()
          Get ? quantification, that is zero or once.
static RegexpInterval getUnbounded(int min)
          Get right unbounded interval, specify only minimum, maximum is considered unbounded
static RegexpInterval intersectIntervals(RegexpInterval first, RegexpInterval second)
          Create an interval that is within both intervals provided as arguments.
 boolean isKleeneCross()
          Whether interval is +
 boolean isKleeneStar()
          Whether interval is *
 boolean isOnce()
          Whether interval is bounded {1,1}.
 boolean isOptional()
          Whether interval is ?
 boolean isUnbounded()
          Whether interval is unbouded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getCopy

public RegexpInterval getCopy()
Clone existing interval\

Returns:
copy of interval

getBounded

public static RegexpInterval getBounded(int min,
                                        int max)
Get a bounded interval, specify min, max integers

Parameters:
min - interval min
max - interval max
Returns:
new interval

getUnbounded

public static RegexpInterval getUnbounded(int min)
Get right unbounded interval, specify only minimum, maximum is considered unbounded

Parameters:
min - interval min
Returns:
new interval

getOnce

public static RegexpInterval getOnce()
Get interval with exactly once meaning, that is min=max=1

Returns:
new interval

getOptional

public static RegexpInterval getOptional()
Get ? quantification, that is zero or once. min = 0, max = 1

Returns:
new interval

getKleeneStar

public static RegexpInterval getKleeneStar()
Get KleeneStar *, asterisk. That is zero or more, unbounded. min =0, max is unbounded.

Returns:
new interval

getKleeneCross

public static RegexpInterval getKleeneCross()
Get KleeneCross, that is + quantification, min= 1, max is unbounded

Returns:
new interval

isUnbounded

public boolean isUnbounded()
Whether interval is unbouded.

Returns:
true when interval is unbounded

isOnce

public boolean isOnce()
Whether interval is bounded {1,1}.

Returns:
true when interval is "exactly once", false otherwise

isOptional

public boolean isOptional()
Whether interval is ?

Returns:
true when interval is {0,1}

isKleeneStar

public boolean isKleeneStar()
Whether interval is *

Returns:
true when interval is unbounded {0,}

isKleeneCross

public boolean isKleeneCross()
Whether interval is +

Returns:
true when interval is unbounded {1,}

getMax

public int getMax()
Get the maximum value, throws exception on unbounded interval (ask using isUnbounded() before calling getMax().

Returns:
max value

getMin

public int getMin()
Get minimum value

Returns:
min value

intersectIntervals

public static RegexpInterval intersectIntervals(RegexpInterval first,
                                                RegexpInterval second)
                                         throws IllegalArgumentException
Create an interval that is within both intervals provided as arguments. Method is symmetrical, so the arguments can be exchanged.

Parameters:
first - First of the intervals.
second - Second of the intervals.
Returns:
Intersection of intervals or null.
Throws:
IllegalArgumentException - When either of the arguments is null, or intervals have no intersection.

toString

public String toString()
Overrides:
toString in class Object

jInfer

Generated on Fri Dec 9 00:01:25 CET 2011