Package org.jboss.msc.service
Class ServiceName
- java.lang.Object
-
- org.jboss.msc.service.ServiceName
-
- All Implemented Interfaces:
Serializable,Comparable<ServiceName>
public final class ServiceName extends Object implements Comparable<ServiceName>, Serializable
Service name class.- Author:
- John Bailey, David M. Lloyd
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ServiceNameJBOSSThe root name "jboss".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceNameappend(String... parts)Create a service name by appending name parts using this as a parent to the new ServiceName.ServiceNameappend(ServiceName serviceName)Create a service name by appending name parts of the provided ServiceName using this as a parent.ServiceNamecommonAncestorOf(ServiceName other)Return the service name that is the nearest common ancestor of the this name and the given one.intcompareTo(ServiceName o)Compare two service names lexicographically.booleanequals(Object o)Compare this service name to another service name.booleanequals(ServiceName o)Compare this service name to another service name.StringgetCanonicalName()Get the canonical name of this service name.ServiceNamegetParent()Get the parent (enclosing) service name.StringgetSimpleName()Get the simple (unqualified) name of this service.inthashCode()Return the hash code of this service name.booleanisParentOf(ServiceName other)Determine whether this service name is the same as, or a parent of, the given service name.static booleanisValidNameSegment(String part)Indicates if the name segment is valid.intlength()Get the length (in segments) of this service name.static ServiceNameof(String... parts)Create a ServiceName from a series of String parts.static ServiceNameof(ServiceName parent, String... parts)Create a ServiceName from a series of String parts and a parent service name.static ServiceNameparse(String original)Parse a string-form service name.String[]toArray()Convert this service name into an array of strings containing the segments of the name.StringtoString()Get a string representation of this service name.
-
-
-
Field Detail
-
JBOSS
public static final ServiceName JBOSS
The root name "jboss".
-
-
Method Detail
-
of
public static ServiceName of(String... parts)
Create a ServiceName from a series of String parts.- Parameters:
parts- The string representations of the service name segments- Returns:
- A ServiceName instance
-
of
public static ServiceName of(ServiceName parent, String... parts)
Create a ServiceName from a series of String parts and a parent service name.- Parameters:
parent- The parent ServiceName for this nameparts- The string representations of the service name segments- Returns:
- A ServiceName instance
-
append
public ServiceName append(String... parts)
Create a service name by appending name parts using this as a parent to the new ServiceName.- Parameters:
parts- The parts to append- Returns:
- A new ServiceName
-
append
public ServiceName append(ServiceName serviceName)
Create a service name by appending name parts of the provided ServiceName using this as a parent.- Parameters:
serviceName- The service name to use as the parts to append- Returns:
- A new ServiceName
-
length
public int length()
Get the length (in segments) of this service name.- Returns:
- the length
-
getParent
public ServiceName getParent()
Get the parent (enclosing) service name.- Returns:
- the parent name
-
getSimpleName
public String getSimpleName()
Get the simple (unqualified) name of this service.- Returns:
- the simple name
-
isParentOf
public boolean isParentOf(ServiceName other)
Determine whether this service name is the same as, or a parent of, the given service name.- Parameters:
other- the other name- Returns:
trueif this service name is a parent
-
commonAncestorOf
public ServiceName commonAncestorOf(ServiceName other)
Return the service name that is the nearest common ancestor of the this name and the given one.- Parameters:
other- the other name- Returns:
- the nearest common ancestor, or
nullif they are unrelated
-
equals
public boolean equals(Object o)
Compare this service name to another service name. This is done by comparing the parents and leaf name of each service name.
-
equals
public boolean equals(ServiceName o)
Compare this service name to another service name. This is done by comparing the parents and leaf name of each service name.- Parameters:
o- the other service name- Returns:
trueif they are equal,falseif they are not equal or the argument isnull
-
hashCode
public int hashCode()
Return the hash code of this service name.
-
toString
public String toString()
Get a string representation of this service name.
-
getCanonicalName
public String getCanonicalName()
Get the canonical name of this service name.- Returns:
- the canonical name
-
isValidNameSegment
public static boolean isValidNameSegment(String part)
Indicates if the name segment is valid.- Parameters:
part- a name segment- Returns:
trueifpartis valid
-
parse
public static ServiceName parse(String original) throws IllegalArgumentException
Parse a string-form service name. If the given name contains quoted sections (surrounded by '"' characters), then the section will be parsed as a quoted string with optional escaped characters. The set of valid escapes is similar to what is supported by the JLS (§3.3 and §3.10.6), with one exception: the string\0is always parsed as a NUL character (0) and not as an octal escape sequence. Control characters are not allowed in any part of a name and must be escaped in a quoted section if they are present in the service name string. Whitespace characters are allowed only in a quoted section.- Parameters:
original- the string form of a service name- Returns:
- a
ServiceNameinstance - Throws:
IllegalArgumentException- if the original is not valid
-
compareTo
public int compareTo(ServiceName o)
Compare two service names lexicographically.- Specified by:
compareToin interfaceComparable<ServiceName>- Parameters:
o- the other name- Returns:
- -1 if this name collates before the argument, 1 if it collates after, or 0 if they are equal
-
toArray
public String[] toArray()
Convert this service name into an array of strings containing the segments of the name. If this array is passed intoof(String...)it will yield aServiceNamewhich is equal to this one.- Returns:
- the string array
-
-