Here's an example that gets the name parser for a context in a naming system and uses the parser to parse a name from that naming system. This interface is implemented by both the CompositeName and CompoundName classes. This means that you can access and update the components of a compound name in a way similar to how you would a composite name. Following is example code that replaces the second component of a compound name and adds components to the head and tail of the name. East Running this program produces the following output.
East Note that the notions of head and tail are independent of the name's syntax.
For example, the LDAP syntax specifies that components are ordered right to left. This means that the rightmost component is the head and the leftmost component the tail. Following is the output produced by a modified version of the previous example. This example uses UNIX filename syntax instead of the LDAP syntax. A Name instance that is not a CompositeName passed to methods in the Context and DirContext interfaces is treated as a compound name.