com.miginfocom.util.repetition
Class DefaultRepetition

java.lang.Object
  extended by com.miginfocom.util.repetition.DefaultRepetition
All Implemented Interfaces:
Repetition, java.io.Serializable
Direct Known Subclasses:
GridLineRepetition

public class DefaultRepetition
extends java.lang.Object
implements Repetition

A class that defines a behaviour like "every other" or "every fifth" as well as defines first, last and an optional valid range.

See Also:
Serialized Form

Field Summary
static int INTERVAL_ONCE
          Interval to use for specification of a singe valid index.
static int OFFSET_LAST
          Offset that will be interpreted as the last index in the range.
 
Constructor Summary
DefaultRepetition()
          Constructor for a repetition with index 0 and interval 1, which means all..
DefaultRepetition(int offset, int interval)
          Constructor.
DefaultRepetition(int offset, int interval, AtRefRangeNumber startIndex, AtRefRangeNumber endIndex)
          Constructor.
DefaultRepetition(int first, int last, int interval)
          Constructor.
 
Method Summary
 boolean appliesTo(int n, int count)
          Returns if an index (n) should be applies to something with count size.
 boolean equals(java.lang.Object o)
           
 AtRefRangeNumber getEndIndex()
          Returns the maximum index to accept.
 int getInterval()
          Returns the modulo to use for specification of a singe valid index.
 int getOffset()
          Returns the offset that will be interpreted as the last index in the range.
 AtRefRangeNumber getStartIndex()
          Returns the minimum index to accept.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INTERVAL_ONCE

public static final int INTERVAL_ONCE
Interval to use for specification of a singe valid index.

See Also:
Constant Field Values

OFFSET_LAST

public static final int OFFSET_LAST
Offset that will be interpreted as the last index in the range.

See Also:
appliesTo(int, int), Constant Field Values
Constructor Detail

DefaultRepetition

public DefaultRepetition()
Constructor for a repetition with index 0 and interval 1, which means all..

See Also:
INTERVAL_ONCE, OFFSET_LAST

DefaultRepetition

public DefaultRepetition(int offset,
                         int interval)
Constructor.

Parameters:
offset - The offset (>= 0) to add before the modulo remainder are checked. Offset 3 means (if modulo 2) that rows 1, 3, 5, 7, 9... are targeted. It is NOT the lower boundary, it is just to offset the modulo.

Note! One offset and modulo has special meanings. One specific line can be specified with modulo MODULO_ONE_SHOT. If offset is OFFSET_LAST it specifies the last grid line. Both should be before any other restraints though, since they are eveluated in order.

interval - The modulo for which the remainder has to be 0 for the other row properties to apply to that row. Modulo 2 means every second row. Must be > 0.
See Also:
INTERVAL_ONCE, OFFSET_LAST

DefaultRepetition

public DefaultRepetition(int first,
                         int last,
                         int interval)
Constructor.

Parameters:
first - The first repetition to accept.
last - The last repetition to accept. Inclusive. If it is less than first it means "forever".
interval - The modulo for which the remainder has to be 0 for the other row properties to apply to that row. Modulo 2 means every second row. Must be > 0.
See Also:
INTERVAL_ONCE, OFFSET_LAST

DefaultRepetition

public DefaultRepetition(int offset,
                         int interval,
                         AtRefRangeNumber startIndex,
                         AtRefRangeNumber endIndex)
Constructor.

Parameters:
offset - The offset (>= 0) to add before the modulo remainder are checked. Offset 3 means (if modulo 2) that rows 3, 5, 7, 9... are targeted.
Note! One offset and modulo has special meanings. One specific line can be specified with modulo MODULO_ONE_SHOT. If offset is OFFSET_LAST it specifies the last grid line. Both should be before any other restraints though, since they are eveluated in order.
interval - The modulo for which the remainder has to be 0 for the other row properties to apply to that row. Modulo 2 means every second row. Must be > 0.
startIndex - The minimum index to accept. Value can be absolute or relative and relative to 0 or count (I.e. upper/lower bound). null means no lower bounds.
endIndex - The maximum index to accept. Value can be absolute or relative and relative to 0 or count (I.e. upper/lower bound). null means no lower bounds.
See Also:
INTERVAL_ONCE, OFFSET_LAST
Method Detail

appliesTo

public boolean appliesTo(int n,
                         int count)
Description copied from interface: Repetition
Returns if an index (n) should be applies to something with count size.

Specified by:
appliesTo in interface Repetition
Parameters:
n - The index. Must be less than count and >= 0.
count - The total number of entities in the range. Used for knowing when the "last" index is asked for.
Returns:
If n should be applied to something with count size.

getOffset

public int getOffset()
Returns the offset that will be interpreted as the last index in the range.

Returns:
The offset that will be interpreted as the last index in the range.

getInterval

public int getInterval()
Returns the modulo to use for specification of a singe valid index. I.e. The repetition interval.

Returns:
the modulo to use for specification of a singe valid index. I.e. The repetition interval.

getStartIndex

public AtRefRangeNumber getStartIndex()
Returns the minimum index to accept. Value can be absolute or relative and relative to 0 or count (I.e. upper/lower bound). null means no lower bounds.

Returns:
The minimum index to accept. Can be null.

getEndIndex

public AtRefRangeNumber getEndIndex()
Returns the maximum index to accept. Value can be absolute or relative and relative to 0 or count (I.e. upper/lower bound). null means no lower bounds.

Returns:
The maximum index to accept. Can be null.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.