tp
Class RID

java.lang.Object
  extended by tp.RID
All Implemented Interfaces:
Serializable, Comparable<RID>, Lockable

public class RID
extends Object
implements Serializable, Comparable<RID>, Lockable

The class represents a resource identifier. There are three types of resource.

The external string representation (toString()) of this identifier is following.

prefix ':' identifier

Valid prefix is 'F', 'R', 'C', which correspond to Flight, Room, and Car. getName() returns the identifier part.

See Also:
Serialized Form

Nested Class Summary
static class RID.Type
          resource type
 
Field Summary
static int MAX_NAME_LENGTH
           
protected  String name
           
protected  RID.Type type
           
 
Constructor Summary
RID()
           
RID(int flight)
          create identifier with flight number
RID(RID.Type type, String name)
           
 
Method Summary
 int compareTo(RID o)
           
 boolean equals(Object o)
           
static RID forCar(String loc)
          convenient method to create car resource identifier
static RID forFlight(int flight)
          convenient method to create flight resource identifier
static RID forFlight(String flight)
          convenient method to create flight resource identifier
static RID forRoom(String loc)
          convenient method to create room resource identifier
 String getName()
           
 RID.Type getType()
          get type of resource id
 int hashCode()
           
static RID parse(String s)
          parse external string representation
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
See Also:
Constant Field Values

type

protected RID.Type type

name

protected String name
Constructor Detail

RID

public RID()

RID

public RID(RID.Type type,
           String name)

RID

public RID(int flight)
create identifier with flight number

Parameters:
flight - the flight number
Method Detail

getType

public RID.Type getType()
get type of resource id

Returns:
type value of current identifier

getName

public String getName()
Returns:
name of resource

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public int compareTo(RID o)
Specified by:
compareTo in interface Comparable<RID>

toString

public String toString()
Overrides:
toString in class Object

forFlight

public static RID forFlight(int flight)
convenient method to create flight resource identifier

Parameters:
flight - flight number
Returns:
flight resource identifier

forFlight

public static RID forFlight(String flight)
convenient method to create flight resource identifier

Parameters:
flight - flight number in string
Returns:
flight resource identifier

forCar

public static RID forCar(String loc)
convenient method to create car resource identifier

Parameters:
loc - location
Returns:
car resource identifier

forRoom

public static RID forRoom(String loc)
convenient method to create room resource identifier

Parameters:
loc - location
Returns:
room resource identifier

parse

public static RID parse(String s)
parse external string representation

Parameters:
s - result of toString()
Returns:
newly created resource identifier