Package org.apache.torque.generator.qname

# Class Namespace

java.lang.Object
org.apache.torque.generator.qname.Namespace

public final class Namespace extends Object
An instance of this class represents a hierarchical namespace. The hierarchy parts are separated by dots. A namespace is in another namespace if it starts with all the components of the the other namespace (it may contain other components afterwards). For example, the namespace "org.apache.torque" is in the namespace "org.apache". Note that the components and their order need to be equal, it does not suffice if a namespace starts with another namespace. For example, the namespace "org.apache.torque" is not in the namespace "org.ap". Instances of this class are immutable. To guard against mutable subclasses, this class is final.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Namespace`
  `ROOT_NAMESPACE`
  The root namespace.
  `static final char`
  `SEPARATOR`
  The separator between the hierachical parts of a namespace.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Namespace(String namespace)`
  Constructs a namespace from its string representation.
  `Namespace(List<String> namespaceParts)`
  Creates a namespace from a hierarchical List of namespace parts.
  `Namespace(Namespace toCopy)`
  Copy-Contructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  Returns if this object is equal to another object.
  `Namespace`
  `getParent()`
  Returns the parent of the given namespace.
  `List<String>`
  `getParts()`
  Returns the parts of the namespace in hierachical order.
  `int`
  `hashCode()`
  Returns a hash code for this namespace.
  `boolean`
  `isRoot()`
  Returns whether this namespace is the root namespace.
  `boolean`
  `isVisibleFrom(Namespace otherNamespace)`
  Returns if this namespace is visible from another namespace.
  `boolean`
  `isVisibleTo(Namespace otherNamespace)`
  Returns if this namespace is visible to another namespace.
  `String`
  `toString()`
  Returns a String representation of this namespace.

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

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

- ## Field Details

  - ### SEPARATOR

    public static final char SEPARATOR
    The separator between the hierachical parts of a namespace.
    See Also:
      - Constant Field Values

  - ### ROOT_NAMESPACE

    public static final Namespace ROOT_NAMESPACE
    The root namespace.

- ## Constructor Details

  - ### Namespace

    public Namespace(String namespace)
    Constructs a namespace from its string representation.
    Parameters:
      `namespace` - teh string representation of the namespace. May not be null, and may not contain colons(:).
    Throws:
      `NullPointerException` - if namespace is null.
      `IllegalArgumentException` - if namespace contains colons.

  - ### Namespace

    public Namespace(Namespace toCopy)
    Copy-Contructor.
    Parameters:
      `toCopy` - the namespace to copy, not null.
    Throws:
      `NullPointerException` - if toCopy is null.

  - ### Namespace

    public Namespace(List<String> namespaceParts)
    Creates a namespace from a hierarchical List of namespace parts.
    Parameters:
      `namespaceParts` - the parts of the namespace.

- ## Method Details

  - ### getParts

    public List<String> getParts()
    Returns the parts of the namespace in hierachical order. The most significant part, i.e the leftmost side, is returned first.
    Returns:
      the parts of the namespace, never null. An empty list is returned for the root namespace.

  - ### getParent

    public Namespace getParent()
    Returns the parent of the given namespace. If this namespace's parent namespace is the root namespace, or this namespace is the root namespace, the root namespace is returned.
    Returns:
      the parent namespace of the namespace, never null

  - ### isVisibleTo

    public boolean isVisibleTo(Namespace otherNamespace)
    Returns if this namespace is visible to another namespace. This is true if this namespace is a "child" of the other namespace or equal to the other 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" is visible to the namespace quot;org.apache" and "org" but not to "org.ap", as the second parts, "apache" and "ap" are not equal.
    Parameters:
      `otherNamespace` - the namespace against this namespace should be checked, not null.
    Returns:
      true if this namespace is visible to the given namespace, false otherwise.
    Throws:
      `NullPointerException` - if otherNamespace is null.

  - ### isVisibleFrom

    public boolean isVisibleFrom(Namespace otherNamespace)
    Returns if this namespace is visible from another namespace. This is true if the other namespace is a "child" of this 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" is visible from the namespace "org.apache.torque.generator", but not from "org.apache"
    Parameters:
      `otherNamespace` - the namespace against this namespace should be checked, not null.
    Returns:
      true if this namespace is visible from the other namespace, false otherwise.
    Throws:
      `NullPointerException` - if otherNamespace is null.

  - ### isRoot

    public boolean isRoot()
    Returns whether this namespace is the root namespace.
    Returns:
      true if this namespace is the root namespace, false otherwise.

  - ### equals

    public boolean equals(Object o)
    Returns if this object is equal to another object. This is true if and only if the other object is a namespace, and their string representations are equal.
    Overrides:
      `equals` in class `Object`
    Parameters:
      `o` - the object to check equality.
    Returns:
      true if the object is equal to this namespace, false otherwise.
    See Also:
      - `Object.equals(Object)`

  - ### hashCode

    public int hashCode()
    Returns a hash code for this namespace. The hash code is consistent with `equals()`.
    Overrides:
      `hashCode` in class `Object`
    Returns:
      a hach code for this object.
    See Also:
      - `Object.hashCode()`

  - ### toString

    public String toString()
    Returns a String representation of this namespace.
    Overrides:
      `toString` in class `Object`
    Returns:
      a String representation of this namespace.
    See Also:
      - `Object.toString()`