Copyright (C) 2003,2004 dr. Cristiano Sadun

org.sadun.text.ffp
Class CountCondition

java.lang.Object
  extended byorg.sadun.text.ffp.CountCondition
All Implemented Interfaces:
FlatFileParser.Condition

public class CountCondition
extends java.lang.Object
implements FlatFileParser.Condition

A condition which compares the numer of physical/logical lines read so far with a given number (pivot number), checking for a specific simple numeric relationship.

Author:
Cristiano Sadun

Field Summary
static int EQUAL
          Relation constant
static int EVEN
          Relation constant
static int GREATER
          Relation constant
static int GREATER_OR_EQUAL
          Relation constant
static int LOGICAL_LINES
          Constant to indicate that comparisons will occur with logical lines count.
static int LOWER
          Relation constant
static int LOWER_OR_EQUAL
          Relation constant
static int ODD
          Relation constant
static int PHYSICAL_LINES
          Constant to indicate that comparisons will occur with physical lines count.
 
Constructor Summary
CountCondition(int pivotNumber, int relationType)
          Create a condition of the given type (using one of the type constants), referring to the logical lines, and pivoted on the given number.
CountCondition(int pivotNumber, int lineType, int relationType)
          Create a condition of the given type (using one of the type constants), referring to either logical or physical lines, and pivoted on the given number.
 
Method Summary
 int getLineType()
          Return the line type used by this condition (one of LOGICAL_LINES or PHYSICAL_LINES).
 int getPivotNumber()
          Return the number to use for comparisons (pivot number).
 int getRelationType()
          Return the relation type used by this condition (one of LOWER, LOWER_OR_EQUAL, EQUAL, GREATER, GREATER_OR_EQUAL, ODD or EVEN).
 boolean holds(int logicalLineCount, int physicalLineCount, FlatFileParser.LineReader reader)
          The condition holds if the physical/logical line count (as defined at construction) has the specified relation type with the pivot number.
 java.lang.String toString()
          Return a human-readable description of the condition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PHYSICAL_LINES

public static final int PHYSICAL_LINES
Constant to indicate that comparisons will occur with physical lines count.

See Also:
Constant Field Values

LOGICAL_LINES

public static final int LOGICAL_LINES
Constant to indicate that comparisons will occur with logical lines count.

See Also:
Constant Field Values

LOWER

public static final int LOWER
Relation constant

See Also:
Constant Field Values

LOWER_OR_EQUAL

public static final int LOWER_OR_EQUAL
Relation constant

See Also:
Constant Field Values

EQUAL

public static final int EQUAL
Relation constant

See Also:
Constant Field Values

GREATER_OR_EQUAL

public static final int GREATER_OR_EQUAL
Relation constant

See Also:
Constant Field Values

GREATER

public static final int GREATER
Relation constant

See Also:
Constant Field Values

ODD

public static final int ODD
Relation constant

See Also:
Constant Field Values

EVEN

public static final int EVEN
Relation constant

See Also:
Constant Field Values
Constructor Detail

CountCondition

public CountCondition(int pivotNumber,
                      int lineType,
                      int relationType)
Create a condition of the given type (using one of the type constants), referring to either logical or physical lines, and pivoted on the given number.

Parameters:
lineType - one of PHYSICAL_LINES or LOGICAL_LINES
relationType - one of LOWER, LOWER_OR_EQUAL, EQUAL, GREATER, GREATER_OR_EQUAL, ODD or EVEN.

CountCondition

public CountCondition(int pivotNumber,
                      int relationType)
Create a condition of the given type (using one of the type constants), referring to the logical lines, and pivoted on the given number.

Parameters:
relationType - one of LOWER, LOWER_OR_EQUAL, EQUAL, GREATER, GREATER_OR_EQUAL, ODD or EVEN.
Method Detail

holds

public boolean holds(int logicalLineCount,
                     int physicalLineCount,
                     FlatFileParser.LineReader reader)
The condition holds if the physical/logical line count (as defined at construction) has the specified relation type with the pivot number.

For example, if the line type is LOGICAL_LINES, the relation type is LOWER and the pivot number is 5, the condition will hold for the first 4 logical lines.

Specified by:
holds in interface FlatFileParser.Condition
Parameters:
logicalLineCount - the logical lines read so far
physicalLineCount - the physical lines read so far
reader - an object allowing to read lines on the file
Returns:
true if the conditions hold, false otherwise.

getLineType

public int getLineType()
Return the line type used by this condition (one of LOGICAL_LINES or PHYSICAL_LINES).

Returns:
the line type used by this condition (one of LOGICAL_LINES or PHYSICAL_LINES).

getRelationType

public int getRelationType()
Return the relation type used by this condition (one of LOWER, LOWER_OR_EQUAL, EQUAL, GREATER, GREATER_OR_EQUAL, ODD or EVEN).

Returns:
the relation type used by this condition (one of LOWER, LOWER_OR_EQUAL, EQUAL, GREATER, GREATER_OR_EQUAL, ODD or EVEN).

getPivotNumber

public int getPivotNumber()
Return the number to use for comparisons (pivot number).

Returns:
the number to use for comparisons (pivot number).

toString

public java.lang.String toString()
Description copied from interface: FlatFileParser.Condition
Return a human-readable description of the condition.

Specified by:
toString in interface FlatFileParser.Condition

Copyright (C) 2003,2004 dr. Cristiano Sadun