org.apache.tapestry
Interface INamespace

All Superinterfaces:
IPropertySource, org.apache.hivemind.Locatable
All Known Implementing Classes:
Namespace

public interface INamespace
extends org.apache.hivemind.Locatable, IPropertySource

Organizes different libraries of Tapestry pages, components and services into "frameworks", used to disambiguate names.

Tapestry release 3.0 includes dynamic discovery of pages and components; an application or library may contain a page or component that won't be "known" until the name is resolved (because it involves searching for a particular named file).

A namespace implements IPropertySource, exposing the properties provided in the namespace's specification.

Since:
2.2
Author:
Howard Lewis Ship
See Also:
PageSpecificationResolver, ComponentSpecificationResolver

Field Summary
static String APPLICATION_NAMESPACE
          Reserved name for the implicit (root) application namespace.
static String FRAMEWORK_NAMESPACE
          Reserved name of a the implicit Framework library.
static char SEPARATOR
          Character used to seperate the namespace prefix from the page name or component type.
 
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 type)
          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.
 String getNamespaceId()
          Returns a version of the extended id appropriate for 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.
 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).
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 
Methods inherited from interface org.apache.tapestry.engine.IPropertySource
getPropertyValue
 

Field Detail

FRAMEWORK_NAMESPACE

static final String FRAMEWORK_NAMESPACE
Reserved name of a the implicit Framework library.

See Also:
Constant Field Values

APPLICATION_NAMESPACE

static final String APPLICATION_NAMESPACE
Reserved name for the implicit (root) application namespace. Use of this prefix allows page or component defined in the application to be referenced from a library. Is this a good thing? In rare cases, yes. Is it subject to severe abuse? Yes.

Since:
4.0
See Also:
Constant Field Values

SEPARATOR

static final char SEPARATOR
Character used to seperate the namespace prefix from the page name or component type.

Since:
2.3
See Also:
Constant Field Values
Method Detail

getId

String getId()
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".


getExtendedId

String getExtendedId()
Returns the extended id for this namespace, which is a dot-seperated sequence of ids.


getNamespaceId

String getNamespaceId()
Returns a version of the extended id appropriate for error messages. This is the based on getExtendedId(), unless this is the application or framework namespace, in which case special strings are returned.

Since:
3.0

getParentNamespace

INamespace getParentNamespace()
Returns the parent namespace; the namespace which contains this namespace.

The application and framework namespaces return null as the parent.


getChildNamespace

INamespace getChildNamespace(String id)
Returns a namespace contained by this namespace.

Parameters:
id - either a simple name (of a directly contained namespace), or a dot-separated name sequence
Returns:
the child namespace
Throws:
org.apache.hivemind.ApplicationRuntimeException - if no such namespace exist.

getChildIds

List getChildIds()
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.


getPageSpecification

IComponentSpecification getPageSpecification(String name)
Returns the page specification of the named page (defined within the namespace).

Parameters:
name - the name of the page
Returns:
the specification
Throws:
org.apache.hivemind.ApplicationRuntimeException - if the page specification doesn't exist or can't be loaded

containsPage

boolean containsPage(String name)
Returns true if this namespace contains the specified page name.


getPageNames

List getPageNames()
Returns a sorted list of page names. May return an empty list, but won't return null. The return list is immutable.


getComponentSpecification

IComponentSpecification getComponentSpecification(String type)
Returns the path for the named component (within the namespace).

Parameters:
type - the component type
Returns:
the specification for the component
Throws:
org.apache.hivemind.ApplicationRuntimeException - if the specification doesn't exist or can't be loaded

containsComponentType

boolean containsComponentType(String type)
Returns true if the namespace contains the indicated component type.

Parameters:
type - a simple component type (no namespace prefix is allowed)

getSpecification

ILibrarySpecification getSpecification()
Returns the LibrarySpecificationfrom which this namespace was created.


constructQualifiedName

String constructQualifiedName(String pageName)
Constructs a qualified name for the given simple page name by applying the correct prefix (if any).

Since:
2.3

getSpecificationLocation

org.apache.hivemind.Resource getSpecificationLocation()
Returns the location of the resource from which the specification for this namespace was read.


isApplicationNamespace

boolean isApplicationNamespace()
Returns true if the namespace is the special application namespace (which has special search rules for handling undeclared pages and components).

Since:
3.0

installPageSpecification

void installPageSpecification(String pageName,
                              IComponentSpecification specification)
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.

Since:
3.0

installComponentSpecification

void installComponentSpecification(String type,
                                   IComponentSpecification specification)
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.

Since:
3.0


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