|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jvnet.ws.wadl.ast.WadlAstBuilder
public class WadlAstBuilder
Encapsulates the act of build an AST from the URI or a WADL. In this AST any "href" references to both to internal and to external WADL elements are resolved making it easier for the user to follow.
| Nested Class Summary | |
|---|---|
static interface |
WadlAstBuilder.SchemaCallback
Allow client to process both internal and external schemas. |
| Constructor Summary | |
|---|---|
WadlAstBuilder(WadlAstBuilder.SchemaCallback schemaCallback,
MessageListener messageListener)
Create a new instance of the AST builder providing a MessageListener
for informational messages and a WadlAstBuilder.SchemaCallback instance to allow
the caller to be provided with schema instances to process. |
|
| Method Summary | |
|---|---|
protected void |
addMethodToResource(ResourceNode resource,
Method method,
URI file)
Add a method to a resource. |
protected void |
addMethodToResourceType(ResourceTypeNode resource,
Method method,
URI file)
Add a method to a resource type. |
protected void |
addRepresentation(List<RepresentationNode> list,
Representation representation,
URI file)
Add a representation to a method's input or output list. |
protected void |
addResourceToResourceType(ResourceTypeNode type,
Resource resource,
URI file)
Add a child resource to a resource type. |
protected void |
addTypeToResource(ResourceNode resourceNode,
Resource resource,
String href,
URI file)
Add a type to a resource. |
protected ApplicationNode |
buildAst(Application a,
URI rootFile)
Build an abstract tree from an unmarshalled WADL file. |
ApplicationNode |
buildAst(URI rootFile)
Build an abstract tree from an unmarshalled WADL file. |
protected void |
buildIDMap(Application a,
URI desc)
Build a map of all method, param, representation, fault and resource_type elements that have an ID. |
protected void |
buildResourceTree(ResourceNode parent,
Resource resource,
URI file)
Add a resource and (recursively) its children to a tree starting at the parent. |
protected void |
buildResourceType(String ifaceId,
Application a)
Build an abstract resource type based on the methods of a resource type in a WADL file. |
protected void |
buildResourceTypeTree(String ifaceId,
Application a)
Build an abstract resource type tree based on the child resources of a resource type in a WADL file. |
protected void |
extractMethodIds(Method m,
URI file)
Extract the id from a method element and add to the method map. |
protected void |
extractParamId(Param p,
URI file)
Extract the id from a param element and add to the representation map. |
protected void |
extractRepresentationId(Representation r,
URI file)
Extract the id from a representation element and add to the representation map. |
protected void |
extractResourceIds(Resource r,
URI file)
Extract the id from a resource element and add to the resource map then recurse into any contained resources. |
protected void |
extractResourceTypeIds(ResourceType r,
URI file)
Extract the id from a resource_type element and add to the resource map. |
Map<String,ResourceTypeNode> |
getInterfaceMap()
|
protected static URI |
getReferencedFile(URI currentFile,
String href)
Get the referenced file, currentFile will be returned if href is a fragment identifier, otherwise href is resolved against currentFile. |
static InvalidWADLException |
messageStringFromObject(String message,
Object obj)
Convert a given message and JAX-B object into a string with location information so that the user can correlate then back to the original file |
protected Application |
processDescription(URI desc)
Unmarshall a WADL file, process any schemas referenced in the WADL file, add any items with an ID to a global ID map, and follow any references to additional WADL files. |
protected Application |
processDescription(URI desc,
InputStream is)
Unmarshall a WADL file, process any schemas referenced in the WADL file, add any items with an ID to a global ID map, and follow any references to additional WADL files. |
protected String |
processIDHref(URI desc,
String id,
String href,
Object o)
Adds the object to the ID map if it is identified and process any file pointed to by href. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WadlAstBuilder(WadlAstBuilder.SchemaCallback schemaCallback,
MessageListener messageListener)
MessageListener
for informational messages and a WadlAstBuilder.SchemaCallback instance to allow
the caller to be provided with schema instances to process.
schemaCallback - used for processing schemas.messageListener - informal messages listener.| Method Detail |
|---|
public Map<String,ResourceTypeNode> getInterfaceMap()
public ApplicationNode buildAst(URI rootFile)
throws InvalidWADLException,
IOException
rootFile - the URI of the root WADL file. Other WADL files might be
included by reference.
InvalidWADLException - when WADL is invalid and cannot be processed.
IOException - if the specified WADL file cannot be read.
protected ApplicationNode buildAst(Application a,
URI rootFile)
throws InvalidWADLException
a - the application element of the root WADL file.rootFile - the URI of the root WADL file. Other WADL files might be
included by reference.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void buildResourceType(String ifaceId,
Application a)
throws InvalidWADLException
ifaceId - the identifier of the resource type.a - the application element of the root WADL file.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void buildResourceTypeTree(String ifaceId,
Application a)
throws InvalidWADLException
ifaceId - the identifier of the resource type.a - the application element of the root WADL file.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void buildResourceTree(ResourceNode parent,
Resource resource,
URI file)
throws InvalidWADLException
parent - the parent resource in the tree being built.resource - the WADL resource to process.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void addTypeToResource(ResourceNode resourceNode,
Resource resource,
String href,
URI file)
throws InvalidWADLException
Follow references to types across WADL file boundaries.
href - the identifier of the resource_type element to process.resourceNode - the resource AST node.resource - the resource object from the model.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void addMethodToResourceType(ResourceTypeNode resource,
Method method,
URI file)
throws InvalidWADLException
Follow references to methods across WADL file boundaries.
method - the WADL method element to process.resource - the resource type.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void addResourceToResourceType(ResourceTypeNode type,
Resource resource,
URI file)
throws InvalidWADLException
Follow references to resources across WADL file boundaries.
resource - the WADL resource element to process.type - the parent resource type.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void addMethodToResource(ResourceNode resource,
Method method,
URI file)
throws InvalidWADLException
Follow references to methods across WADL file boundaries.
method - the WADL method element to process.resource - the resource.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected void addRepresentation(List<RepresentationNode> list,
Representation representation,
URI file)
throws InvalidWADLException
Follow references to representations across WADL file boundaries.
list - the list to add the representation to.representation - the WADL representation element to process.file - the URI of the current WADL file being processed.
InvalidWADLException - when WADL is invalid and cannot be processed.
protected Application processDescription(URI desc)
throws javax.xml.bind.JAXBException,
IOException
desc - the URI of the description file, the description is fetched by
converting the URI into a URL and then using a HTTP GET. Use
processDescription(java.net.URI, java.io.InputStream) to
supply the InputStream directly.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected Application processDescription(URI desc,
InputStream is)
throws javax.xml.bind.JAXBException,
IOException
desc - the URI of the description file.is - an input stream from which the description can be read.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void buildIDMap(Application a,
URI desc)
throws javax.xml.bind.JAXBException,
IOException
desc - the URI of the WADL file being processed.a - the root element of an unmarshalled WADL document.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
public static InvalidWADLException messageStringFromObject(String message,
Object obj)
protected String processIDHref(URI desc,
String id,
String href,
Object o)
throws javax.xml.bind.JAXBException,
IOException
desc - The URI of the current file being processed, used when resolving relative paths in href.id - The identifier of o or null if o isn't identified.href - A link to a another element, the document in which the element resides will
be recursively processed.o - The object that is being identified or from which the link occurs.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void extractRepresentationId(Representation r,
URI file)
throws javax.xml.bind.JAXBException,
IOException
file - the URI of the current WADL file being processed.r - the representation element.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void extractParamId(Param p,
URI file)
throws javax.xml.bind.JAXBException,
IOException
file - the URI of the current WADL file being processed.p - the param element.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void extractMethodIds(Method m,
URI file)
throws javax.xml.bind.JAXBException,
IOException
file - the URI of the current WADL file being processed.m - the method element.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void extractResourceIds(Resource r,
URI file)
throws javax.xml.bind.JAXBException,
IOException
file - the URI of the current WADL file being processed.r - the resource element.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected void extractResourceTypeIds(ResourceType r,
URI file)
throws javax.xml.bind.JAXBException,
IOException
Also extract the ids from any contained method and its param, representation or fault elements.
file - the URI of the current WADL file being processed.r - the resource_type element.
javax.xml.bind.JAXBException - if the WADL file is invalid or if
the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
protected static URI getReferencedFile(URI currentFile,
String href)
currentFile - the uri of the file that contains the reference, used
to provide a base for relative paths.href - the reference.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||