org.apache.tapestry.engine
Class Namespace

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

public class Namespace
extends Object
implements INamespace

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

Since:
2.2
Author:
Howard Lewis Ship

Field Summary
 
Fields inherited from interface org.apache.tapestry.INamespace
APPLICATION_NAMESPACE, FRAMEWORK_NAMESPACE, SEPARATOR
 
Constructor Summary
Namespace(String id, INamespace parent, ILibrarySpecification specification, NamespaceResources resources)
           
 
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).
 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.
 org.apache.hivemind.Location getLocation()
           
 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 getPropertyValue(String propertyName)
          Returns property values defined in the namespace's library specification.
 ILibrarySpecification getSpecification()
          Returns the LibrarySpecificationfrom which this namespace was created.
 org.apache.hivemind.Resource 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,
                 NamespaceResources resources)
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-separated 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 type
Returns:
the specification for the component

getSpecification

public ILibrarySpecification getSpecification()
Description copied from interface: INamespace
Returns the LibrarySpecificationfrom 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 org.apache.hivemind.Resource 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 *

getLocation

public org.apache.hivemind.Location getLocation()
Specified by:
getLocation in interface org.apache.hivemind.Locatable
Since:
3.0 *

getPropertyValue

public String getPropertyValue(String propertyName)
Returns property values defined in the namespace's library specification.

Specified by:
getPropertyValue in interface IPropertySource
Parameters:
propertyName - Name of the property to get.
Returns:
the property, or null if not provided in the specification.
Since:
4.0


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.