org.apache.tapestry.engine
Class Namespace

java.lang.Object
  extended by org.apache.tapestry.engine.Namespace
All Implemented Interfaces:
ILocatable, INamespace

public class Namespace
extends Object
implements INamespace

Implementation of INamespace that works with a ISpecificationSource to obtain page and component specifications as needed.

Since:
2.2
Version:
$Id: Namespace.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Field Summary
 
Fields inherited from interface org.apache.tapestry.INamespace
FRAMEWORK_NAMESPACE, SEPARATOR
 
Constructor Summary
Namespace(String id, INamespace parent, ILibrarySpecification specification, ISpecificationSource specificationSource)
           
 
Method Summary
 String constructQualifiedName(String pageName)
          Constructs a qualified name for the given simple page name by applying the correct prefix (if any).
 boolean containsComponentType(String type)
          Returns true if the namespace contains the indicated component type.
 boolean containsPage(String name)
          Returns true if this namespace contains the specified page name.
 List getChildIds()
          Returns a sorted, immutable list of the ids of the immediate children of this namespace.
 INamespace getChildNamespace(String id)
          Returns a namespace contained by this namespace.
 IComponentSpecification getComponentSpecification(String alias)
          Returns the path for the named component (within the namespace).
 List getComponentTypes()
          Returns a sorted list of component types.
 String getExtendedId()
          Returns the extended id for this namespace, which is a dot-seperated sequence of ids.
 String getId()
          Returns an identifier for the namespace.
 ILocation getLocation()
          Returns the location from which this object orginates, or null if not known.
 String getNamespaceId()
          Returns a string identifying the namespace, for use in error messages.
 List getPageNames()
          Returns a sorted list of page names.
 IComponentSpecification getPageSpecification(String name)
          Returns the page specification of the named page (defined within the namespace).
 INamespace getParentNamespace()
          Returns the parent namespace; the namespace which contains this namespace.
 String getServiceClassName(String name)
          Returns the class name of a service provided by the namespace.
 List getServiceNames()
          Returns the names of all services provided by the namespace, as a sorted, immutable list.
 ILibrarySpecification getSpecification()
          Returns the LibrarySpecification from which this namespace was created.
 IResourceLocation getSpecificationLocation()
          Returns the location of the resource from which the specification for this namespace was read.
 void installComponentSpecification(String type, IComponentSpecification specification)
          Used to specify additional components beyond those that came from the namespace's specification.
 void installPageSpecification(String pageName, IComponentSpecification specification)
          Used to specify additional pages beyond those that came from the namespace's specification.
 boolean isApplicationNamespace()
          Returns true if the namespace is the special application namespace (which has special search rules for handling undeclared pages and components).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Namespace

public Namespace(String id,
                 INamespace parent,
                 ILibrarySpecification specification,
                 ISpecificationSource specificationSource)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getId

public String getId()
Description copied from interface: INamespace
Returns an identifier for the namespace. Identifiers are simple names (they start with a letter, and may contain letters, numbers, underscores and dashes). An identifier must be unique among a namespaces siblings.

The application namespace has a null id; the framework namespace has an id of "framework".

Specified by:
getId in interface INamespace

getExtendedId

public String getExtendedId()
Description copied from interface: INamespace
Returns the extended id for this namespace, which is a dot-seperated sequence of ids.

Specified by:
getExtendedId in interface INamespace

getParentNamespace

public INamespace getParentNamespace()
Description copied from interface: INamespace
Returns the parent namespace; the namespace which contains this namespace.

The application and framework namespaces return null as the parent.

Specified by:
getParentNamespace in interface INamespace

getChildNamespace

public INamespace getChildNamespace(String id)
Description copied from interface: INamespace
Returns a namespace contained by this namespace.

Specified by:
getChildNamespace in interface INamespace
Parameters:
id - either a simple name (of a directly contained namespace), or a dot-seperarated name sequence.
Returns:
the child namespace

getChildIds

public List getChildIds()
Description copied from interface: INamespace
Returns a sorted, immutable list of the ids of the immediate children of this namespace. May return the empty list, but won't return null.

Specified by:
getChildIds in interface INamespace

getPageSpecification

public IComponentSpecification getPageSpecification(String name)
Description copied from interface: INamespace
Returns the page specification of the named page (defined within the namespace).

Specified by:
getPageSpecification in interface INamespace
Parameters:
name - the name of the page
Returns:
the specification

getPageNames

public List getPageNames()
Description copied from interface: INamespace
Returns a sorted list of page names. May return an empty list, but won't return null. The return list is immutable.

Specified by:
getPageNames in interface INamespace

getComponentSpecification

public IComponentSpecification getComponentSpecification(String alias)
Description copied from interface: INamespace
Returns the path for the named component (within the namespace).

Specified by:
getComponentSpecification in interface INamespace
Parameters:
alias - the component alias
Returns:
the specification path of the component

getServiceClassName

public String getServiceClassName(String name)
Description copied from interface: INamespace
Returns the class name of a service provided by the namespace.

Specified by:
getServiceClassName in interface INamespace
Parameters:
name - the name of the service.
Returns:
the complete class name of the service, or null if the namespace does not contain the named service.

getServiceNames

public List getServiceNames()
Description copied from interface: INamespace
Returns the names of all services provided by the namespace, as a sorted, immutable list. May return the empty list, but won't return null.

Specified by:
getServiceNames in interface INamespace

getSpecification

public ILibrarySpecification getSpecification()
Description copied from interface: INamespace
Returns the LibrarySpecification from which this namespace was created.

Specified by:
getSpecification in interface INamespace

getNamespaceId

public String getNamespaceId()
Returns a string identifying the namespace, for use in error messages. I.e., "Application namespace" or "namespace 'foo'".

Specified by:
getNamespaceId in interface INamespace

containsPage

public boolean containsPage(String name)
Description copied from interface: INamespace
Returns true if this namespace contains the specified page name.

Specified by:
containsPage in interface INamespace

constructQualifiedName

public String constructQualifiedName(String pageName)
Description copied from interface: INamespace
Constructs a qualified name for the given simple page name by applying the correct prefix (if any).

Specified by:
constructQualifiedName in interface INamespace
Since:
2.3

getSpecificationLocation

public IResourceLocation getSpecificationLocation()
Description copied from interface: INamespace
Returns the location of the resource from which the specification for this namespace was read.

Specified by:
getSpecificationLocation in interface INamespace
Since:
3.0

isApplicationNamespace

public boolean isApplicationNamespace()
Description copied from interface: INamespace
Returns true if the namespace is the special application namespace (which has special search rules for handling undeclared pages and components).

Specified by:
isApplicationNamespace in interface INamespace
Since:
3.0

installPageSpecification

public void installPageSpecification(String pageName,
                                     IComponentSpecification specification)
Description copied from interface: INamespace
Used to specify additional pages beyond those that came from the namespace's specification. This is used when pages in the application namespace are dynamically discovered.

Specified by:
installPageSpecification in interface INamespace
Since:
3.0

installComponentSpecification

public void installComponentSpecification(String type,
                                          IComponentSpecification specification)
Description copied from interface: INamespace
Used to specify additional components beyond those that came from the namespace's specification. This is used when components in the application namespace are dynamically discovered.

Specified by:
installComponentSpecification in interface INamespace
Since:
3.0

containsComponentType

public boolean containsComponentType(String type)
Description copied from interface: INamespace
Returns true if the namespace contains the indicated component type.

Specified by:
containsComponentType in interface INamespace
Parameters:
type - a simple component type (no namespace prefix is allowed)
Since:
3.0

getComponentTypes

public List getComponentTypes()
Description copied from interface: INamespace
Returns a sorted list of component types. May return an empty list, but won't return null. The return list is immutable. Represents just the known component types (additional types may be discoverred dynamically).

Is this method even needed?

Specified by:
getComponentTypes in interface INamespace
Since:
3.0

getLocation

public ILocation getLocation()
Description copied from interface: ILocatable
Returns the location from which this object orginates, or null if not known.

Specified by:
getLocation in interface ILocatable
Since:
3.0