/** * Build a map of all method, representation, fault and resource elements that have an ID. These * are used to dereference href values when building the ast. * * @param desc the URI of the WADL file being processed * @param a the root element of an unmarshalled WADL document * @throws javax.xml.bind.JAXBException if the WADL file is invalid or if the code generator * encounters a problem. * @throws java.io.IOException if the specified WADL file cannot be read. */ @SuppressWarnings("unchecked") protected void buildIDMap(Application a, URI desc) throws JAXBException, IOException { // process globally declared items for (Object child : a.getResourceTypeOrMethodOrRepresentation()) { if (child instanceof Method) extractMethodIds((Method) child, desc); else if (child instanceof ResourceType) extractResourceTypeIds((ResourceType) child, desc); else { JAXBElement<RepresentationType> repOrFault = (JAXBElement<RepresentationType>) child; extractRepresentationId(repOrFault.getValue(), desc); } } // process resource hierarchy if (a.getResources() != null) for (Resource r : a.getResources().getResource()) extractResourceIds(r, desc); }
/** * Build an abstract tree from an unmarshalled WADL file * * @param a the application element of the root WADL file * @param rootFile the URI of the root WADL file. Other WADL files might be included by reference. * @return the resource element that corresponds to the root of the resource tree */ protected ResourceNode buildAst(Application a, URI rootFile) { for (String ifaceId : ifaceMap.keySet()) { buildResourceTypes(ifaceId, a); } Resources r = a.getResources(); ResourceNode n = new ResourceNode(a, r); if (r != null) { for (Resource child : r.getResource()) { buildResourceTree(n, child, rootFile); } } return n; }