Package org.apache.torque.generator.qname

## Class QualifiedName

- java.lang.Object
- - org.apache.torque.generator.qname.QualifiedName

-     public final class QualifiedName
      extends Object

  This class contains a name which has a namespace. The namespace defines the scope where the name is valid, and is made up of hierarchical bits separated by a dot (`SEPARATOR`). A qualified name is in the scope of its own namespace and all children namespaces of its own namespace (i.e. the namespaces "deeper down" the hierarchy). For example, the namespace org.apache.torque is in the scope of org.apache but not in the scope of org.apache.torque.generator. As a special case, if the namespace is the empty String, the name is valid in all namespaces. The namespace and the name are also separated by a dot (`SEPARATOR`). Instances of this class are immutable. To prevent mutable subclasses, this class is final.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static char` | `SEPARATOR` | The separator between namespace parts and between namespacee and local name in the string representation of a QualifiedName.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `QualifiedName​(String qualifiedName)` | Creates a QualifiedName from its string representation, which is namespace:name.
    `QualifiedName​(String nameOrQualifiedName, String defaultNamespace)` | Creates a QualifiedName from a fully qualified name or the name and the namespace parts of a QualifiedName.
    `QualifiedName​(String nameOrQualifiedName, Namespace defaultNamespace)` | Creates a QualifiedName from a fully qualified name or the name and the namespace parts of a QualifiedName.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `equals​(Object o)` | Returns if this object equals another object.
    `String` | `getName()` | Returns the name part of the QualifiedName.
    `Namespace` | `getNamespace()` | Returns the namespace of the QualifiedName.
    `Namespace` | `getParentNamespace()` | Returns the parent of the Qualified name's namespace.
    `int` | `hashCode()` | Returns a hashcode for the QualifiedName.
    `boolean` | `isInRootNamespace()` | Returns if the namespace of this qualified name is the root namespace.
    `boolean` | `isVisibleFrom​(Namespace otherNamespace)` | Returns if this qualified name is visible from another namespace.
    `String` | `toString()` | Returns the String representation of the QualifiedName, which is namespace.name if namespace is not empty, or name if namespace is empty.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### SEPARATOR

          public static final char SEPARATOR

      The separator between namespace parts and between namespacee and local name in the string representation of a QualifiedName.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### QualifiedName

          public QualifiedName​(String qualifiedName)

      Creates a QualifiedName from its string representation, which is namespace:name. The namespace part may be empty (in which case the default namespace is used), but not the name part.
      Parameters:
        `qualifiedName` - the string representation of the QualifiedName, must contain a non-empty name part.
      Throws:
        `NullPointerException` - if qualifiedName is null

    - #### QualifiedName

          public QualifiedName​(String nameOrQualifiedName,
                               String defaultNamespace)

      Creates a QualifiedName from a fully qualified name or the name and the namespace parts of a QualifiedName.
      Parameters:
        `nameOrQualifiedName` - either the name part of the QualifiedName, or a fully qualified name. May not be null and must contain an non-empty name part.
        `defaultNamespace` - the namespace of the QualifiedName, may be null if nameOrQualifiedName has a namespace part.
      Throws:
        `IllegalArgumentException` - if name has an empty name part, or if no namespace is found (nameOrQualifiedName has no namespace part and defaultNamespace is null)
        `NullPointerException` - if name is null.

    - #### QualifiedName

          public QualifiedName​(String nameOrQualifiedName,
                               Namespace defaultNamespace)

      Creates a QualifiedName from a fully qualified name or the name and the namespace parts of a QualifiedName.
      Parameters:
        `nameOrQualifiedName` - either the name part of the QualifiedName, or a fully qualified name. May not be null and must contain an non-empty name part.
        `defaultNamespace` - the namespace of the QualifiedName, may be null if nameOrQualifiedName has a namespace part.
      Throws:
        `IllegalArgumentException` - if name has an empty name part, or if no namespace is found (nameOrQualifiedName has no namespace part and defaultNamespace is null)
        `NullPointerException` - if name is null.

  - ### Method Detail

    - #### getName

          public String getName()

      Returns the name part of the QualifiedName.
      Returns:
        the name part of the QualifiedName, never null.

    - #### getNamespace

          public Namespace getNamespace()

      Returns the namespace of the QualifiedName.
      Returns:
        the namespace of the QualifiedName, may be null.

    - #### isVisibleFrom

          public boolean isVisibleFrom​(Namespace otherNamespace)

      Returns if this qualified name is visible from another namespace. This is true if the namespace is a "child" of this qualified name's namespace. Note that for being a child, all the parts of the namespace separated by a dot must be equal. For example, "org.apache.torque:name" is visible from the namespaces "org.apache.torque.generator" and "org.apache.torque", but not from "org.apache"
      Parameters:
        `otherNamespace` - the namespace against this QualifiedName should be checked, not null.
      Returns:
        true if this QualifiedName is visible from the given namespace, false otherwise.
      Throws:
        `NullPointerException` - if otherNamespace is null.

    - #### getParentNamespace

          public Namespace getParentNamespace()

      Returns the parent of the Qualified name's namespace. If this qualified name is in the root namespace, the root namespace is returned.
      Returns:
        the parent namespace of the qualified name's namespace, never null.
      See Also:
        `Namespace.getParent()`

    - #### isInRootNamespace

          public boolean isInRootNamespace()

      Returns if the namespace of this qualified name is the root namespace.
      Returns:
        true if the namespace is the root namespace, false otherwise.

    - #### toString

          public String toString()

      Returns the String representation of the QualifiedName, which is namespace.name if namespace is not empty, or name if namespace is empty.
      Overrides:
        `toString` in class `Object`
      Returns:
        a String representation of the QualifiedName.

    - #### equals

          public boolean equals​(Object o)

      Returns if this object equals another object. This is the case if the other object is also a QualifiedName and its name and namespace are the same as this object's name and namespace.
      Overrides:
        `equals` in class `Object`
      Parameters:
        `o` - the other object to compare this object to.
      Returns:
        true if this object equals the other object, false otherwise.
      See Also:
        `Object.equals(Object)`

    - #### hashCode

          public int hashCode()

      Returns a hashcode for the QualifiedName. The hashcode is consistent with equals.
      Overrides:
        `hashCode` in class `Object`
      Returns:
        a hashcode for the qualified name.
      See Also:
        `Object.hashCode()`