com.limegroup.gnutella
Class UrnType

java.lang.Object
  extended bycom.limegroup.gnutella.UrnType
All Implemented Interfaces:
java.io.Serializable

public class UrnType
extends java.lang.Object
implements java.io.Serializable

This class defines the types of URNs supported in the application and provides utility functions for handling urn types.

See Also:
URN, UrnCache, Serialized Form

Field Summary
static UrnType ANY_TYPE
          The UrnType for specifying any URN type.
static java.util.Set ANY_TYPE_SET
          Constant for specifying any type of URN for replies.
static UrnType INVALID
          The UrnType for an invalid UrnType.
static UrnType SHA1
          The UrnType for SHA1 hashes.
static java.util.Set SHA1_SET
          Constant for specifying SHA1 URNs in replies.
static java.lang.String SHA1_STRING
          Identifier string for the SHA1 type.
static java.lang.String URN_NAMESPACE_ID
          Constant for the leading URN string identifier, as specified in RFC 2141.
 
Method Summary
static UrnType createUrnType(java.lang.String type)
          Factory method for obtaining UrnType instances from strings.
 boolean equals(java.lang.Object o)
          It is necessary for this class to override equals because the readResolve method was not added to the serialization API until Java 1.2, which means that we cannot use it to ensure that the UrnType enum constants are actually the same instances upon deserialization.
 int hashCode()
          Overridden to meet the contract of Object.hashCode.
 boolean isSHA1()
          Returns whether or not this URN type is SHA1.
static boolean isSupportedUrnType(java.lang.String urnString)
          Returns whether or not the string argument is a urn type that we know about.
 java.lang.String toString()
          Returns the string representation of this URN type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SHA1_STRING

public static final java.lang.String SHA1_STRING
Identifier string for the SHA1 type.

See Also:
Constant Field Values

INVALID

public static final UrnType INVALID
The UrnType for an invalid UrnType.


SHA1

public static final UrnType SHA1
The UrnType for SHA1 hashes.


ANY_TYPE

public static final UrnType ANY_TYPE
The UrnType for specifying any URN type.


SHA1_SET

public static final transient java.util.Set SHA1_SET
Constant for specifying SHA1 URNs in replies.


ANY_TYPE_SET

public static final transient java.util.Set ANY_TYPE_SET
Constant for specifying any type of URN for replies.


URN_NAMESPACE_ID

public static final java.lang.String URN_NAMESPACE_ID
Constant for the leading URN string identifier, as specified in RFC 2141. This is equal to "urn:", although note that this should be used in a case-insensitive manner in compliance with the URN specification (RFC 2141).

See Also:
Constant Field Values
Method Detail

isSHA1

public boolean isSHA1()
Returns whether or not this URN type is SHA1.

Returns:
true if this is a SHA1 URN type, false otherwise

toString

public java.lang.String toString()
Returns the string representation of this URN type.

Returns:
the string representation of this URN type

equals

public boolean equals(java.lang.Object o)
It is necessary for this class to override equals because the readResolve method was not added to the serialization API until Java 1.2, which means that we cannot use it to ensure that the UrnType enum constants are actually the same instances upon deserialization. Therefore, we must rely on Object.equals instead of upon "==".

Parameters:
o - the Object to compare for equality
Returns:
true if these represent the same UrnType, false otherwise
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Overridden to meet the contract of Object.hashCode.

Returns:
the unique hashcode for this UrnType, in accordance with Object.equals
See Also:
Object.hashCode()

createUrnType

public static UrnType createUrnType(java.lang.String type)
Factory method for obtaining UrnType instances from strings. If the isSupportedUrnType method returns true this is guaranteed to return a non-null UrnType.

Parameters:
type - the string representation of the urn type
Returns:
the UrnType instance corresponding with the specified string, or null if the type is not supported

isSupportedUrnType

public static boolean isSupportedUrnType(java.lang.String urnString)
Returns whether or not the string argument is a urn type that we know about.

Parameters:
urnString - to string to check
Returns:
true if it is a valid URN type, false otherwise