JBoss Remoting 3.0.0.Beta2

org.jboss.remoting.spi
Class QualifiedName

java.lang.Object
  extended by org.jboss.remoting.spi.QualifiedName
All Implemented Interfaces:
Comparable<QualifiedName>, Iterable<String>

public final class QualifiedName
extends Object
implements Comparable<QualifiedName>, Iterable<String>

A qualified name for service registration. A qualified name is a path-like structure comprised of a series of zero or more name segments. The string representation of a qualified name is a sequence of a forward slash (/) followed by a non-empty URL-encoded name segment.


Field Summary
static QualifiedName ROOT_NAME
          The root name.
 
Constructor Summary
QualifiedName(String[] nameSegments)
          Create a new qualified name from the given name segments.
 
Method Summary
 int compareTo(QualifiedName o)
          Compare this qualified name to another.
 boolean equals(Object o)
          Compare this qualified name to another for equality.
 int hashCode()
          Get the hash code of this qualified name.
 Iterator<String> iterator()
          Get an iterator over the sequence of strings.
 int length()
          Get the number of segments in this name.
static QualifiedName parse(String path)
          Parse a qualified name.
 String toString()
          Get the string representation of this qualified name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT_NAME

public static final QualifiedName ROOT_NAME
The root name.

Constructor Detail

QualifiedName

public QualifiedName(String[] nameSegments)
              throws NullPointerException,
                     IllegalArgumentException
Create a new qualified name from the given name segments.

Parameters:
nameSegments - the name segments
Throws:
NullPointerException - if nameSegments is null or if any element of that array is null
IllegalArgumentException - if an element of nameSegments is an empty string
Method Detail

equals

public boolean equals(Object o)
Compare this qualified name to another for equality. Returns true if both names have the same number of segments with the same content.

Overrides:
equals in class Object
Parameters:
o - the object to compare to
Returns:
true if the given object is a qualified name which is equal to this name

hashCode

public int hashCode()
Get the hash code of this qualified name. Equal to the return value of Arrays.hashCode(segments) where segments is the array of decoded segment strings.

Overrides:
hashCode in class Object
Returns:
the hash code

compareTo

public int compareTo(QualifiedName o)
Compare this qualified name to another. Each segment is compared in turn; if they are equal then the comparison carries on to the next segment. If all leading segments are equal but one qualified name has more segments, then the longer name is said to come after the shorter name.

Specified by:
compareTo in interface Comparable<QualifiedName>
Parameters:
o - the other name
Returns:
0 if the elements are equal, -1 if this name comes before the given name, or 1 if this name comes after the given name

toString

public String toString()
Get the string representation of this qualified name. The root name is "/"; all other names are comprised of one or more consecutive character sequences of a forward slash followed by one or more URL-encoded characters.

Overrides:
toString in class Object
Returns:
the string representation of this name

parse

public static QualifiedName parse(String path)
Parse a qualified name. A qualified name must consist of either a single forward slash ("/") or else a series of path components, each comprised of a single forward slash followed by a URL-encoded series of non-forward-slash characters.

Parameters:
path - the path
Returns:
the qualified name

iterator

public Iterator<String> iterator()
Get an iterator over the sequence of strings.

Specified by:
iterator in interface Iterable<String>
Returns:
an iterator

length

public int length()
Get the number of segments in this name.

Returns:
the number of segments

JBoss Remoting 3.0.0.Beta2

Copyright © 2008 JBoss, a division of Red Hat, Inc.