com.novell.admin.ns
Class IntegerStrategy

java.lang.Object
  extended bycom.novell.admin.ns.IntegerStrategy
All Implemented Interfaces:
Strategy, ValueStrategy

public abstract class IntegerStrategy
extends java.lang.Object
implements ValueStrategy

Abstract class that may be extended for syntax strategies that use integer as the value type.

Methods in this class and any subclasses are not intended to be used directly by an application. These methods are intended to be use by ValueComponent and syntax classes.


Field Summary
protected static int WITHIN_BOUNDS
          Internal Error
 
Constructor Summary
IntegerStrategy()
           
 
Method Summary
 boolean canCreateValue(java.lang.Object obj)
          Tests to see if a LongValue can be created.
 long compare(ValueComponent component1, ValueComponent component2)
          Compares two value objects.
 ValueComponent createValueComponent()
          Creates a new LongValue using zero as the default initial data.
 ValueComponent createValueComponent(java.lang.Object obj)
          Creates a new LongValue using specified initial data.
 boolean equals(ValueComponent component1, ValueComponent component2)
          Tests to see if two LongValue objects are equal.
 boolean isWithinBounds(ValueComponent comp, long lowerBound, long upperBound)
          Algorithm to test if a LongValue is within bounds.
 java.lang.String toString(ValueComponent obj)
          Converts a LongValue object to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.novell.admin.ns.ValueStrategy
getSyntax
 

Field Detail

WITHIN_BOUNDS

protected static final int WITHIN_BOUNDS
Internal Error

See Also:
Constant Field Values
Constructor Detail

IntegerStrategy

public IntegerStrategy()
Method Detail

canCreateValue

public boolean canCreateValue(java.lang.Object obj)
Tests to see if a LongValue can be created.

Specified by:
canCreateValue in interface ValueStrategy
Parameters:
obj - An Object to create the value from.
Returns:
True if 'obj' is instance of Number or String, false otherwise.

compare

public long compare(ValueComponent component1,
                    ValueComponent component2)
Compares two value objects. This function is intended to be used by the LongValue class. It not intended for finding the difference between two ValueComponents but for sorting the ValueComponents.

Specified by:
compare in interface Strategy
Parameters:
component1 - First value used in comparison, which must be a LongValue.
component2 - Second value used in comparison, which must be a LongValue.
Returns:
0 if equal, greater than 1 for component1>component2 or less than 1 for component1See Also:
ValueComponent.compareTo(ValueComponent)

createValueComponent

public ValueComponent createValueComponent()
Creates a new LongValue using zero as the default initial data.

Specified by:
createValueComponent in interface Strategy
Returns:
new LongValue

createValueComponent

public ValueComponent createValueComponent(java.lang.Object obj)
                                    throws ComponentCreationException
Creates a new LongValue using specified initial data.

Specified by:
createValueComponent in interface Strategy
Parameters:
obj - Must be either a Number or String instance.
Returns:
new LongValue
Throws:
ComponentCreationException - if 'obj' is not a Number nor a String that can be parsed to a long.

equals

public boolean equals(ValueComponent component1,
                      ValueComponent component2)
Tests to see if two LongValue objects are equal. This function is intended to be used by the LongValue class.

Specified by:
equals in interface Strategy
Parameters:
component1 - First Value used in the test, which must be LongValue.
component2 - Second Value used in test.
Returns:
True if both objects are LongValue, the syntaxes are identical and thier values are equal; false otherwise.
See Also:
ValueComponent.equals(Object)

isWithinBounds

public boolean isWithinBounds(ValueComponent comp,
                              long lowerBound,
                              long upperBound)
Algorithm to test if a LongValue is within bounds.

Specified by:
isWithinBounds in interface Strategy
Parameters:
comp - The ValueComponent to check.
lowerBound - The lower limit to check.
upperBound - The upper limit to check.
Returns:
True if within limits (inclusively), false otherwise.

toString

public java.lang.String toString(ValueComponent obj)
Converts a LongValue object to a String.

Specified by:
toString in interface Strategy
Parameters:
obj - Component to convert. Should be a LongValue instance.
Returns:
If component is a LongValue the Value converted to a string.
See Also:
ValueComponent.toString()


API Documentation Copyright © 1998-2004 Novell, Inc. All rights reserved.
NDS is a registered trademark of Novell, Inc. in the United States and other countries.
Generated September 2 2004 0111.