com.metamatrix.core.id
Class IntegerIDFactory

java.lang.Object
  extended by com.metamatrix.core.id.IntegerIDFactory
All Implemented Interfaces:
ObjectIDFactory, java.io.Serializable

public class IntegerIDFactory
extends java.lang.Object
implements ObjectIDFactory, java.io.Serializable

See Also:
Serialized Form

Constructor Summary
IntegerIDFactory()
           
 
Method Summary
 ObjectID create()
          Create a new ObjectID instance using this protocol.
 java.lang.String getDescription()
          Return the description for the type of ObjectID described by this object.
protected  int getNextValue()
           
 java.lang.String getProtocol()
          Return the name of the protocol that this factory uses.
 ObjectID stringToObject(java.lang.String value)
          Attempt to convert the specified string to the appropriate ObjectID instance.
 ObjectID stringWithoutProtocolToObject(java.lang.String value)
          Attempt to convert the specified string to the appropriate ObjectID instance.
 boolean validate(ObjectID id)
          Return whether the specified ObjectID instance is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerIDFactory

public IntegerIDFactory()
Method Detail

getDescription

public java.lang.String getDescription()
Return the description for the type of ObjectID described by this object.

Specified by:
getDescription in interface ObjectIDFactory
Returns:
the description

getNextValue

protected int getNextValue()

create

public ObjectID create()
Create a new ObjectID instance using this protocol.

Specified by:
create in interface ObjectIDFactory
Returns:
the new instance

validate

public boolean validate(ObjectID id)
Return whether the specified ObjectID instance is valid. Only ObjectID instances that are for this protocol will be passed in.

This implementation only checks whether the ObjectID is an instance of a LongID.

Parameters:
id - the ID that is to be validated, and which is never null
Returns:
true if the instance is valid for this protocol, or false if it is not valid.

stringToObject

public ObjectID stringToObject(java.lang.String value)
                        throws InvalidIDException
Attempt to convert the specified string to the appropriate ObjectID instance.

Specified by:
stringToObject in interface ObjectIDFactory
Parameters:
value - the stringified id (the result of ObjectID.toString()), and should never null or zero length
Returns:
the ObjectID instance for the stringified ID if this factory is able to parse the string, or null if the factory is unaware of the specified format.
Throws:
InvalidIDException - if the parser is aware of this protocol, but it is of the wrong format for this type of ObjectID.

stringWithoutProtocolToObject

public ObjectID stringWithoutProtocolToObject(java.lang.String value)
                                       throws InvalidIDException
Attempt to convert the specified string to the appropriate ObjectID instance. This method is called by the IDGenerator.stringToObject(String) method, which must process the protocol to determine the correct parser to use. As such, it guarantees that the parser that receives this call can assume that the protocol was equal to the protocol returned by the parser's ObjectIDDescriptor#getProtocol().

Specified by:
stringWithoutProtocolToObject in interface ObjectIDFactory
Parameters:
value - the stringified id with the protocol and ObjectID.DELIMITER already removed, and should never null or zero length
Returns:
the ObjectID instance for the stringified ID if this factory is able to parse the string, or null if the factory is unaware of the specified format.
Throws:
InvalidIDException - if the parser is aware of this protocol, but it is of the wrong format for this type of ObjectID.

getProtocol

public java.lang.String getProtocol()
Return the name of the protocol that this factory uses.

Specified by:
getProtocol in interface ObjectIDFactory
Returns:
the protocol name


Copyright © 2009. All Rights Reserved.