* An escaped escape string is not treated as an escape string.
*<li>
* An escape string that does not precede a meta string (quotes or separator)
* and is not at the end of a component is treated as an ordinary string.
*<li>
* A leading separator (the compound name string begins with
* a separator) denotes a leading empty atomic component (consisting
* of an empty string).
* A trailing separator (the compound name string ends with
* a separator) denotes a trailing empty atomic component.
* Adjacent separators denote an empty atomic component.
*</ol>
* <p>
* The string form of the compound name follows the syntax described above.
* When the components of the compound name are turned into their
* string representation, the reserved syntax rules described above are
* applied (e.g. embedded separators are escaped or quoted)
* so that when the same string is parsed, it will yield the same components
* of the original compound name.
*<p>
*<h4>Multithreaded Access</h4>
* A <tt>CompoundName</tt> instance is not synchronized against concurrent
* multithreaded access. Multiple threads trying to access and modify a
* <tt>CompoundName</tt> should lock the object.
*
* @author Rosanna Lee
* @author Scott Seligman
* @version 1.12 05/11/17
* @since 1.3
*/
public class CompoundName implements Name {
/**
* Implementation of this compound name.
* This field is initialized by the constructors and cannot be null.
* It should be treated as a read-only variable by subclasses.
*/
protected transient NameImpl impl;
/**
* Syntax properties for this compound name.
* This field is initialized by the constructors and cannot be null.
* It should be treated as a read-only variable by subclasses.
* Any necessary changes to mySyntax should be made within constructors
* and not after the compound name has been instantiated.
*/
protected transient Properties mySyntax;
/**
* Constructs a new compound name instance using the components
* specified in comps and syntax. This protected method is intended to be
* to be used by subclasses of CompoundName when they override
* methods such as clone(), getPrefix(), getSuffix().
*
* @param comps A non-null enumeration of the components to add.
* Each element of the enumeration is of class String.
* The enumeration will be consumed to extract its
* elements.
* @param syntax A non-null properties that specify the syntax of
* this compound name. See class description for
* contents of properties.
*/
protected CompoundName(Enumeration<String> comps, Properties syntax) {
if (syntax == null) {
throw new NullPointerException();
}
mySyntax = syntax;
impl = new NameImpl(syntax, comps);
}
/**
* Constructs a new compound name instance by parsing the string n
* using the syntax specified by the syntax properties supplied.
*
* @param n The non-null string to parse.
* @param syntax A non-null list of properties that specify the syntax of
* this compound name. See class description for
* contents of properties.
* @exception InvalidNameException If 'n' violates the syntax specified
* by <code>syntax</code>.
*/
public CompoundName(String n, Properties syntax) throws InvalidNameException {
if (syntax == null) {
throw new NullPointerException();
}
mySyntax = syntax;
impl = new NameImpl(syntax, n);
}
/**
* Generates the string representation of this compound name, using
* the syntax rules of the compound name. The syntax rules
* are described in the class description.
* An empty component is represented by an empty string.
*
* The string representation thus generated can be passed to
* the CompoundName constructor with the same syntax properties
* to create a new equivalent compound name.
*
* @return A non-null string representation of this compound name.
=2= |