org.jvnet.ws.wadl.ast
Class ResourceNode

java.lang.Object
  extended by org.jvnet.ws.wadl.ast.AbstractNode
      extended by org.jvnet.ws.wadl.ast.ResourceNode

public class ResourceNode
extends AbstractNode

Represents a WADL resource.

Author:
mh124079

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jvnet.ws.wadl.ast.AbstractNode
AbstractNode.NodeVisitor
 
Constructor Summary
ResourceNode(Resource resource, ResourceNode parent, URI file, ElementResolver idMap)
          Create a new instance of ResourceNode and attach it as a child of an existing resource.
ResourceNode(Resource resource, ResourceTypeNode parent, URI file, ElementResolver idMap)
          Create a new instance of ResourceNode and attach it as a child of an existing resource type.
ResourceNode(URI baseURI, Application app, Resources resources)
          Creates a new instance of ResourceNode.
 
Method Summary
 ResourceNode addChild(Resource r, URI file, ElementResolver idMap)
          Create a new resource and add it as a child.
 void addResourceType(ResourceTypeNode n)
          Add a new base type for this resource - adds any methods, query or matrix parameters specified on the type to those specified for this resource.
static String createClassNameFromBase(String base)
           
 String getAllResourceUriTemplate()
           
 List<ResourceNode> getChildResources()
          Get the child resources.
 String getClassName()
          Convenience function for generating a suitable Java class name for this WADL resource.
 List<Doc> getDoc()
          List of child documentation elements.
 List<Param> getHeaderParams()
          Get a list of header parameters for this resource and its types.
 Locator getLocation()
           
 List<Param> getMatrixParams()
          Get a list of header parameters for this resource and its types.
 List<MethodNode> getMethods()
          Get the method for this resource.
 ResourceNode getParentResource()
          Get the parent resource.
 PathSegment getPathSegment()
          Get the path segment for this resource.
 List<PathSegment> getPathSegments()
          Get a list of path segments for this resource and its ancestors.
 List<Param> getQueryParams()
          Get a list of query parameters for this resource and its types.
 List<ResourceTypeNode> getResourceTypes()
          Get the types for this resource.
 String getUriTemplate()
           
 void setClassName(String className)
          Override the default generated class name.
 void visit(AbstractNode.NodeVisitor visitor)
          Allow the provided parameter to visit the current node and any child nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceNode

public ResourceNode(URI baseURI,
                    Application app,
                    Resources resources)
Creates a new instance of ResourceNode.

Parameters:
app - the unmarshalled JAXB-generated application object.
resources - the unmarshalled JAXB-generated resources object.

ResourceNode

public ResourceNode(Resource resource,
                    ResourceNode parent,
                    URI file,
                    ElementResolver idMap)
             throws InvalidWADLException
Create a new instance of ResourceNode and attach it as a child of an existing resource.

Parameters:
resource - the unmarshalled JAXB-generated resource object.
parent - the parent resource to attach the new resource to.
file - the URI of the WADL file that contains the resource element.
idMap - a map of URI reference to WADL definition element.
Throws:
InvalidWADLException - when WADL is invalid and cannot be processed.

ResourceNode

public ResourceNode(Resource resource,
                    ResourceTypeNode parent,
                    URI file,
                    ElementResolver idMap)
             throws InvalidWADLException
Create a new instance of ResourceNode and attach it as a child of an existing resource type.

Parameters:
resource - the unmarshalled JAXB-generated resource object.
parent - the parent resource to attach the new resource to.
file - the URI of the WADL file that contains the resource element.
idMap - a map of URI reference to WADL definition element.
Throws:
InvalidWADLException - when WADL is invalid and cannot be processed.
Method Detail

createClassNameFromBase

public static String createClassNameFromBase(String base)
Returns:
A simplified name with both the protocol and the port removed.

addChild

public ResourceNode addChild(Resource r,
                             URI file,
                             ElementResolver idMap)
                      throws InvalidWADLException
Create a new resource and add it as a child.

Parameters:
r - the unmarshalled JAXB resource element.
file - the URI of the WADL file that contains the resource element.
idMap - a map of URI reference to WADL definition element.
Returns:
the new resource element.
Throws:
InvalidWADLException - when WADL is invalid and cannot be processed.

getClassName

public String getClassName()
Convenience function for generating a suitable Java class name for this WADL resource.

Returns:
a suitable name.

getUriTemplate

public String getUriTemplate()
Returns:
The template for this resource.

getAllResourceUriTemplate

public String getAllResourceUriTemplate()
Returns:
A template that contains all parent resources; but not the base URI. This path will start with a '/' in order to make the code we generate less complicated

setClassName

public void setClassName(String className)
Override the default generated class name.

Parameters:
className - class name.

getChildResources

public List<ResourceNode> getChildResources()
Get the child resources.

Returns:
a list of child resources.

getPathSegment

public PathSegment getPathSegment()
Get the path segment for this resource.

Returns:
the path segment.

getMethods

public List<MethodNode> getMethods()
Get the method for this resource.

Returns:
a list of methods.

addResourceType

public void addResourceType(ResourceTypeNode n)
Add a new base type for this resource - adds any methods, query or matrix parameters specified on the type to those specified for this resource.

Parameters:
n - the abstract resource type node to add.

getResourceTypes

public List<ResourceTypeNode> getResourceTypes()
Get the types for this resource.

Returns:
a list of resource types.

getParentResource

public ResourceNode getParentResource()
Get the parent resource.

Returns:
the parent resource or null if there isn't one.

getPathSegments

public List<PathSegment> getPathSegments()
Get a list of path segments for this resource and its ancestors. The order of segments is the reverse of the ancestor list. I.e. root resource, child of root, ..., parent of resource, resource.

Returns:
list of path segments.

getQueryParams

public List<Param> getQueryParams()
Get a list of query parameters for this resource and its types.

Returns:
list of query parameters

getHeaderParams

public List<Param> getHeaderParams()
Get a list of header parameters for this resource and its types.

Returns:
list of header parameters

getMatrixParams

public List<Param> getMatrixParams()
Get a list of header parameters for this resource and its types.

Returns:
list of header parameters

getDoc

public List<Doc> getDoc()
List of child documentation elements.

Returns:
documentation list, one item per language.

getLocation

public Locator getLocation()
Specified by:
getLocation in class AbstractNode
Returns:
The location of the node.

visit

public void visit(AbstractNode.NodeVisitor visitor)
Allow the provided parameter to visit the current node and any child nodes.

Overrides:
visit in class AbstractNode
Parameters:
visitor - NodeVisitor instance.


Copyright © 2014. All Rights Reserved.