Java Doc for CompositeName.java in  » 6.0-JDK-Core » naming » javax » naming » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » naming » javax.naming 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.naming.CompositeName

CompositeName
public class CompositeName implements Name(Code)
This class represents a composite name -- a sequence of component names spanning multiple namespaces. Each component is a string name from the namespace of a naming system. If the component comes from a hierarchical namespace, that component can be further parsed into its atomic parts by using the CompoundName class.

The components of a composite name are numbered. The indexes of a composite name with N components range from 0 up to, but not including, N. This range may be written as [0,N). The most significant component is at index 0. An empty composite name has no components.

JNDI Composite Name Syntax

JNDI defines a standard string representation for composite names. This representation is the concatenation of the components of a composite name from left to right using the component separator (a forward slash character (/)) to separate each component. The JNDI syntax defines the following meta characters:
  • escape (backward slash \),
  • quote characters (single (') and double quotes (")), and
  • component separator (forward slash character (/)).
Any occurrence of a leading quote, an escape preceding any meta character, an escape at the end of a component, or a component separator character in an unquoted component must be preceded by an escape character when that component is being composed into a composite name string. Alternatively, to avoid adding escape characters as described, the entire component can be quoted using matching single quotes or matching double quotes. A single quote occurring within a double-quoted component is not considered a meta character (and need not be escaped), and vice versa.

When two composite names are compared, the case of the characters is significant.

A leading component separator (the composite name string begins with a separator) denotes a leading empty component (a component consisting of an empty string). A trailing component separator (the composite name string ends with a separator) denotes a trailing empty component. Adjacent component separators denote an empty component.

Composite Name Examples

This table shows examples of some composite names. Each row shows the string form of a composite name and its corresponding structural form (CompositeName).

String Name CompositeName
"" {} (the empty name == new CompositeName("") == new CompositeName())
"x" {"x"}
"x/y" {"x", "y"}
"x/" {"x", ""}
"/x" {"", "x"}
"/" {""}
"//" {"", ""}
"/x/" {"", "x", ""}
"x//y" {"x", "", "y"}

Composition Examples

Here are some composition examples. The right column shows composing string composite names while the left column shows composing the corresponding CompositeNames. Notice that composing the string forms of two composite names simply involves concatenating their string forms together.

String Names CompositeNames
"x/y" + "/" = x/y/ {"x", "y"} + {""} = {"x", "y", ""}
"" + "x" = "x" {} + {"x"} = {"x"}
"/" + "x" = "/x" {""} + {"x"} = {"", "x"}
"x" + "" + "" = "x" {"x"} + {} + {} = {"x"}

Multithreaded Access

A CompositeName instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a CompositeName should lock the object.
author:
   Rosanna Lee
author:
   Scott Seligman
version:
   1.21 07/05/05
since:
   1.3



Constructor Summary
protected  CompositeName(Enumeration<String> comps)
     Constructs a new composite name instance using the components specified by 'comps'.
public  CompositeName(String n)
     Constructs a new composite name instance by parsing the string n using the composite name syntax (left-to-right, slash separated).
public  CompositeName()
     Constructs a new empty composite name.

Method Summary
public  Nameadd(String comp)
     Adds a single component to the end of this composite name.
Parameters:
  comp - The non-null component to add.
public  Nameadd(int posn, String comp)
     Adds a single component at a specified position within this composite name. Components of this composite name at or after the index of the new component are shifted up by one (away from index 0) to accommodate the new component.
Parameters:
  comp - The non-null component to add.
Parameters:
  posn - The index at which to add the new component.Must be in the range [0,size()].
public  NameaddAll(Name suffix)
     Adds the components of a composite name -- in order -- to the end of this composite name.
Parameters:
  suffix - The non-null components to add.
public  NameaddAll(int posn, Name n)
     Adds the components of a composite name -- in order -- at a specified position within this composite name. Components of this composite name at or after the index of the first new component are shifted up (away from index 0) to accommodate the new components.
Parameters:
  n - The non-null components to add.
Parameters:
  posn - The index in this name at which to add the newcomponents.
public  Objectclone()
     Generates a copy of this composite name.
public  intcompareTo(Object obj)
     Compares this CompositeName with the specified Object for order.
public  booleanendsWith(Name n)
     Determines whether a composite name is a suffix of this composite name.
public  booleanequals(Object obj)
     Determines whether two composite names are equal. If obj is null or not a composite name, false is returned. Two composite names are equal if each component in one is equal to the corresponding component in the other.
public  Stringget(int posn)
     Retrieves a component of this composite name.
Parameters:
  posn - The 0-based index of the component to retrieve.Must be in the range [0,size()).
public  Enumeration<String>getAll()
     Retrieves the components of this composite name as an enumeration of strings. The effects of updates to this composite name on this enumeration is undefined. A non-null enumeration of the components ofthis composite name.
public  NamegetPrefix(int posn)
     Creates a composite name whose components consist of a prefix of the components in this composite name.
public  NamegetSuffix(int posn)
     Creates a composite name whose components consist of a suffix of the components in this composite name.
public  inthashCode()
     Computes the hash code of this composite name.
public  booleanisEmpty()
     Determines whether this composite name is empty.
public  Objectremove(int posn)
     Deletes a component from this composite name. The component of this composite name at position 'posn' is removed, and components at indices greater than 'posn' are shifted down (towards index 0) by one.
Parameters:
  posn - The index of the component to delete.Must be in the range [0,size()).
public  intsize()
     Retrieves the number of components in this composite name.
public  booleanstartsWith(Name n)
     Determines whether a composite name is a prefix of this composite name. A composite name 'n' is a prefix if it is equal to getPrefix(n.size())--in other words, this composite name starts with 'n'.
public  StringtoString()
     Generates the string representation of this composite name. The string representation consists of enumerating in order each component of the composite name and separating each component by a forward slash character.


Constructor Detail
CompositeName
protected CompositeName(Enumeration<String> comps)(Code)
Constructs a new composite name instance using the components specified by 'comps'. This protected method is intended to be to be used by subclasses of CompositeName when they override methods such as clone(), getPrefix(), getSuffix().
Parameters:
  comps - A non-null enumeration containing the components for the newcomposite name. Each element is of class String.The enumeration will be consumed to extract itselements.



CompositeName
public CompositeName(String n) throws InvalidNameException(Code)
Constructs a new composite name instance by parsing the string n using the composite name syntax (left-to-right, slash separated). The composite name syntax is described in detail in the class description.
Parameters:
  n - The non-null string to parse.
exception:
  InvalidNameException - If n has invalid composite name syntax.



CompositeName
public CompositeName()(Code)
Constructs a new empty composite name. Such a name returns true when isEmpty() is invoked on it.




Method Detail
add
public Name add(String comp) throws InvalidNameException(Code)
Adds a single component to the end of this composite name.
Parameters:
  comp - The non-null component to add. The updated CompositeName, not a new one. Cannot be null.
exception:
  InvalidNameException - If adding comp at end of the namewould violate the name's syntax.



add
public Name add(int posn, String comp) throws InvalidNameException(Code)
Adds a single component at a specified position within this composite name. Components of this composite name at or after the index of the new component are shifted up by one (away from index 0) to accommodate the new component.
Parameters:
  comp - The non-null component to add.
Parameters:
  posn - The index at which to add the new component.Must be in the range [0,size()]. The updated CompositeName, not a new one. Cannot be null.
exception:
  ArrayIndexOutOfBoundsException - If posn is outside the specified range.
exception:
  InvalidNameException - If adding comp at the specified positionwould violate the name's syntax.



addAll
public Name addAll(Name suffix) throws InvalidNameException(Code)
Adds the components of a composite name -- in order -- to the end of this composite name.
Parameters:
  suffix - The non-null components to add. The updated CompositeName, not a new one. Cannot be null.
exception:
  InvalidNameException - If suffix is not a composite name.



addAll
public Name addAll(int posn, Name n) throws InvalidNameException(Code)
Adds the components of a composite name -- in order -- at a specified position within this composite name. Components of this composite name at or after the index of the first new component are shifted up (away from index 0) to accommodate the new components.
Parameters:
  n - The non-null components to add.
Parameters:
  posn - The index in this name at which to add the newcomponents. Must be in the range [0,size()]. The updated CompositeName, not a new one. Cannot be null.
exception:
  InvalidNameException - If n is not a composite name.
exception:
  ArrayIndexOutOfBoundsException - If posn is outside the specified range.



clone
public Object clone()(Code)
Generates a copy of this composite name. Changes to the components of this composite name won't affect the new copy and vice versa. A non-null copy of this composite name.



compareTo
public int compareTo(Object obj)(Code)
Compares this CompositeName with the specified Object for order. Returns a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object.

If obj is null or not an instance of CompositeName, ClassCastException is thrown.

See equals() for what it means for two composite names to be equal. If two composite names are equal, 0 is returned.

Ordering of composite names follows the lexicographical rules for string comparison, with the extension that this applies to all the components in the composite name. The effect is as if all the components were lined up in their specified ordered and the lexicographical rules applied over the two line-ups. If this composite name is "lexicographically" lesser than obj, a negative number is returned. If this composite name is "lexicographically" greater than obj, a positive number is returned.
Parameters:
  obj - The non-null object to compare against. a negative integer, zero, or a positive integer as this Nameis less than, equal to, or greater than the given Object.
exception:
  ClassCastException - if obj is not a CompositeName.




endsWith
public boolean endsWith(Name n)(Code)
Determines whether a composite name is a suffix of this composite name. A composite name 'n' is a suffix if it it is equal to getSuffix(size()-n.size())--in other words, this composite name ends with 'n'. If n is null or not a composite name, false is returned.
Parameters:
  n - The possibly null name to check. true if n is a CompositeName andis a suffix of this composite name, false otherwise.



equals
public boolean equals(Object obj)(Code)
Determines whether two composite names are equal. If obj is null or not a composite name, false is returned. Two composite names are equal if each component in one is equal to the corresponding component in the other. This implies both have the same number of components, and each component's equals() test against the corresponding component in the other name returns true.
Parameters:
  obj - The possibly null object to compare against. true if obj is equal to this composite name, false otherwise.
See Also:   CompositeName.hashCode



get
public String get(int posn)(Code)
Retrieves a component of this composite name.
Parameters:
  posn - The 0-based index of the component to retrieve.Must be in the range [0,size()). The non-null component at index posn.
exception:
  ArrayIndexOutOfBoundsException - if posn is outside thespecified range.



getAll
public Enumeration<String> getAll()(Code)
Retrieves the components of this composite name as an enumeration of strings. The effects of updates to this composite name on this enumeration is undefined. A non-null enumeration of the components ofthis composite name. Each element of the enumeration is ofclass String.



getPrefix
public Name getPrefix(int posn)(Code)
Creates a composite name whose components consist of a prefix of the components in this composite name. Subsequent changes to this composite name does not affect the name that is returned.
Parameters:
  posn - The 0-based index of the component at which to stop.Must be in the range [0,size()]. A composite name consisting of the components at indexes inthe range [0,posn).
exception:
  ArrayIndexOutOfBoundsException - If posn is outside the specified range.



getSuffix
public Name getSuffix(int posn)(Code)
Creates a composite name whose components consist of a suffix of the components in this composite name. Subsequent changes to this composite name does not affect the name that is returned.
Parameters:
  posn - The 0-based index of the component at which to start.Must be in the range [0,size()]. A composite name consisting of the components at indexes inthe range [posn,size()). If posn is equal to size(), an empty composite name is returned.
exception:
  ArrayIndexOutOfBoundsException - If posn is outside the specified range.



hashCode
public int hashCode()(Code)
Computes the hash code of this composite name. The hash code is the sum of the hash codes of individual components of this composite name. An int representing the hash code of this name.
See Also:   CompositeName.equals



isEmpty
public boolean isEmpty()(Code)
Determines whether this composite name is empty. A composite name is empty if it has zero components. true if this composite name is empty, false otherwise.



remove
public Object remove(int posn) throws InvalidNameException(Code)
Deletes a component from this composite name. The component of this composite name at position 'posn' is removed, and components at indices greater than 'posn' are shifted down (towards index 0) by one.
Parameters:
  posn - The index of the component to delete.Must be in the range [0,size()). The component removed (a String).
exception:
  ArrayIndexOutOfBoundsException - If posn is outside the specified range (includes case wherecomposite name is empty).
exception:
  InvalidNameException - If deleting the componentwould violate the name's syntax.



size
public int size()(Code)
Retrieves the number of components in this composite name. The nonnegative number of components in this composite name.



startsWith
public boolean startsWith(Name n)(Code)
Determines whether a composite name is a prefix of this composite name. A composite name 'n' is a prefix if it is equal to getPrefix(n.size())--in other words, this composite name starts with 'n'. If 'n' is null or not a composite name, false is returned.
Parameters:
  n - The possibly null name to check. true if n is a CompositeName andis a prefix of this composite name, false otherwise.



toString
public String toString()(Code)
Generates the string representation of this composite name. The string representation consists of enumerating in order each component of the composite name and separating each component by a forward slash character. Quoting and escape characters are applied where necessary according to the JNDI syntax, which is described in the class description. An empty component is represented by an empty string. The string representation thus generated can be passed to the CompositeName constructor to create a new equivalent composite name. A non-null string representation of this composite name.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.