/**
  * Dereference a href and return the object if it is of the expected type.
  *
  * @return the resolved object
  * @param file the URI of the file in which the referenced element is located, used to absolutize
  *     references
  * @param href the reference to resolve
  * @param clazz the class of object expected
  */
 @SuppressWarnings("unchecked")
 protected <T> T dereferenceLocalHref(URI file, String href, Class<T> clazz) {
   Object o = null;
   String id = file.toString() + href.substring(href.indexOf('#'));
   o = idMap.get(id);
   if (o == null) {
     System.err.println(Wadl2JavaMessages.SKIPPING_REFERENCE(href, file.toString()));
     return null;
   } else if (!clazz.isInstance(o)) {
     System.err.println(Wadl2JavaMessages.SKIPPING_REFERENCE_TYPE(href, file.toString()));
     return null;
   }
   return (T) o;
 }
  /**
   * Add a type to a resource. Follow references to types across WADL file boundaries
   *
   * @param href the identifier of the resource_type element to process
   * @param resource the resource
   * @param file the URI of the current WADL file being processed
   */
  protected void addTypeToResource(ResourceNode resource, String href, URI file) {
    // dereference resource
    if (!href.startsWith("#")) {
      // referecnce to element in another document
      file = getReferencedFile(file, href);
    }
    ResourceTypeNode n = ifaceMap.get(file.toString() + href.substring(href.indexOf('#')));

    if (n != null) {
      resource.addResourceType(n);
    } else {
      System.err.println(Wadl2JavaMessages.SKIPPING_REFERENCE(href, file.toString()));
    }
  }