Package com.sun.mirror.declaration

Examples of com.sun.mirror.declaration.TypeDeclaration


   * @return The xml type for the specified type mirror.
   * @throws XmlTypeException If the type is invalid or unknown as an xml type.
   */
  public static XmlType getXmlType(Class type) throws XmlTypeException {
    AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
    TypeDeclaration declaration = env.getTypeDeclaration(type.getName());
    return getXmlType(env.getTypeUtils().getDeclaredType(declaration));
  }
View Full Code Here


    if (elementDeclaration instanceof RootElementDeclaration) {
      TypeDefinition typeDef = ((RootElementDeclaration) elementDeclaration).getTypeDefinition();
      addReferencedNamespaces(typeDef, referencedNamespaces);
    }
    else if (elementDeclaration instanceof LocalElementDeclaration) {
      TypeDeclaration typeDecl = ((LocalElementDeclaration) elementDeclaration).getElementTypeDeclaration();
      if (typeDecl instanceof ClassDeclaration) {
        EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
        TypeDefinition typeDefinition = model.findTypeDefinition((ClassDeclaration) typeDecl);
        if (typeDefinition != null) {
          addReferencedNamespaces(typeDefinition, referencedNamespaces);
View Full Code Here

    }
    else if (object instanceof LocalElementDeclaration) {
      LocalElementDeclaration rootEl = (LocalElementDeclaration) object;
      namespace = rootEl.getNamespace();
      name = rootEl.getName();
      TypeDeclaration elementTypeDeclaration = rootEl.getElementTypeDeclaration();
      if (elementTypeDeclaration instanceof ClassDeclaration) {
        type = model.findTypeDefinition((ClassDeclaration) elementTypeDeclaration);
      }
      else {
        type = null;
View Full Code Here

    BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
    HashMap<String, String> conversions = new HashMap<String, String>();
    conversions.put("org.codehaus.enunciate.samples", "red.herring");
    conversions.put("org.codehaus.enunciate.samples.xfire_client.with.a.nested", "org.codehaus.enunciate.other.pckg.and.nested");
    ClientPackageForMethod packageForMethod = new ClientPackageForMethod(conversions);
    TypeDeclaration typeDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageClass");
    assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(typeDeclaration))));
    assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(typeDeclaration.getPackage()))));
    assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.plus.extra", packageForMethod.exec(Arrays.asList(wrapper.wrap("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.plus.extra"))));
    assertEquals("red.herring.xfire_client", packageForMethod.exec(Arrays.asList(wrapper.wrap("org.codehaus.enunciate.samples.xfire_client"))));
    for (FieldDeclaration fieldDeclaration : typeDeclaration.getFields()) {
      if ("items".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("java.util", packageForMethod.exec(Arrays.asList(wrapper.wrap(fieldDeclaration.getType()))));
      }
      else if ("type".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(fieldDeclaration.getType()))));
View Full Code Here

    conversions.put("org.codehaus.enunciate.samples", "red.herring");
    conversions.put("org.codehaus.enunciate.samples.xfire_client.with.a.nested", "org.codehaus.enunciate.other.pckg.and.nested");
    ClientClassnameForMethod classnameFor14Method = new ClientClassnameForMethod(conversions);
    ClientClassnameForMethod classnameFor15Method = new ClientClassnameForMethod(conversions);
    classnameFor15Method.setJdk15(true);
    TypeDeclaration classDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageClass");
    assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageClass", classnameFor14Method.convert(classDeclaration));
    assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageClass", classnameFor15Method.convert(classDeclaration));
    for (FieldDeclaration fieldDeclaration : classDeclaration.getFields()) {
      if ("items".equals(fieldDeclaration.getSimpleName())) {
        assertEquals(Collection.class.getName(), classnameFor14Method.convert(fieldDeclaration.getType()));
        assertEquals("java.util.Collection<org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageItem>", classnameFor15Method.convert(fieldDeclaration.getType()));
      }
      else if ("type".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageEnum", classnameFor14Method.convert(fieldDeclaration.getType()));
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageEnum", classnameFor15Method.convert(fieldDeclaration.getType()));
      }
    }

    classDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageItem");
    for (FieldDeclaration fieldDeclaration : classDeclaration.getFields()) {
      if ("property1".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("boolean", classnameFor14Method.convert(fieldDeclaration.getType()));
        assertEquals("boolean", classnameFor15Method.convert(fieldDeclaration.getType()));
      }
      else if ("property2".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("int[]", classnameFor14Method.convert(fieldDeclaration.getType()));
        assertEquals("int[]", classnameFor15Method.convert(fieldDeclaration.getType()));
      }
    }

    try {
      classnameFor14Method.convert(classDeclaration.getPackage());
      fail("Converting a package to a classname shouldn't be suppored.");
    }
    catch (UnsupportedOperationException e) {
      //fall through.
    }
View Full Code Here

    conversions.put("org.codehaus.enunciate.samples", "red.herring");
    conversions.put("org.codehaus.enunciate.samples.xfire_client.with.a.nested", "org.codehaus.enunciate.other.pckg.and.nested");
    ComponentTypeForMethod component14For = new ComponentTypeForMethod(conversions);
    ComponentTypeForMethod component15For = new ComponentTypeForMethod(conversions);
    component15For.setJdk15(true);
    TypeDeclaration classDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageClass");
    for (FieldDeclaration fieldDeclaration : classDeclaration.getFields()) {
      if ("items".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageItem", component14For.convert(fieldDeclaration.getType()));
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageItem", component15For.convert(fieldDeclaration.getType()));
      }
      else if ("type".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageEnum", component14For.convert(fieldDeclaration.getType()));
        assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.NestedPackageEnum", component15For.convert(fieldDeclaration.getType()));
      }
    }

    classDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageItem");
    for (FieldDeclaration fieldDeclaration : classDeclaration.getFields()) {
      if ("property1".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("boolean", component14For.convert(fieldDeclaration.getType()));
        assertEquals("boolean", component15For.convert(fieldDeclaration.getType()));
      }
      else if ("property2".equals(fieldDeclaration.getSimpleName())) {
        assertEquals("int", component14For.convert(fieldDeclaration.getType()));
        assertEquals("int", component15For.convert(fieldDeclaration.getType()));
      }
    }

    try {
      component14For.convert(classDeclaration.getPackage());
      fail("Converting a package to a classname shouldn't be suppored.");
    }
    catch (UnsupportedOperationException e) {
      //fall through.
    }
View Full Code Here

      RootElementDeclaration rootEl = (RootElementDeclaration) object;
      type = rootEl.getTypeDefinition();
    }
    else if (object instanceof LocalElementDeclaration) {
      LocalElementDeclaration rootEl = (LocalElementDeclaration) object;
      TypeDeclaration elementTypeDeclaration = rootEl.getElementTypeDeclaration();
      if (elementTypeDeclaration instanceof ClassDeclaration) {
        type = model.findTypeDefinition((ClassDeclaration) elementTypeDeclaration);
      }
      else {
        type = null;
View Full Code Here

    assertEquals(3, typeDef.getElements().size());
    assertTrue(typeDef.getElements().contains(typeDef.getXmlID()));

    assertEquals(XmlAccessType.PROPERTY, typeDef.getAccessType());

    TypeDeclaration declaration = getDeclaration("org.codehaus.enunciate.samples.schema.UnsupportedTypeDefBean");
    FieldDeclaration mixed = findField(declaration, "mixedProperty");
    FieldDeclaration anyElement = findField(declaration, "anyElementProperty");
    FieldDeclaration anyAttribute = findField(declaration, "anyAttributeProperty");
    assertTrue(typeDef.isUnsupported(mixed));
    assertFalse(typeDef.isUnsupported(anyElement));
View Full Code Here

        return new ValidationResult();
      }
    };

    //test validation of JSR 181, secion 3.3
    TypeDeclaration declaration = getDeclaration("org.codehaus.enunciate.samples.services.NotAWebService");
    EndpointInterface ei = new EndpointInterface(declaration);
    assertTrue("A class not annotated with @WebService shouldn't be a valid endpoint interface (jsr 181: 3.3).", validator.validateEndpointInterface(ei).hasErrors());

    declaration = getDeclaration("org.codehaus.enunciate.samples.services.InvalidEIReference");
    ei = new EndpointInterface(declaration);
View Full Code Here

        xmlIdCounter.increment();
        return new ValidationResult();
      }
    };

    TypeDeclaration declaration = getDeclaration("org.codehaus.enunciate.samples.schema.ComplexTypeWithValueAndElements");
    ComplexTypeDefinition invalidNestedType = new ComplexTypeDefinition((ClassDeclaration) declaration.getNestedTypes().iterator().next());
    assertTrue("A non-static nested type should not be a valid type definition.", validator.validateTypeDefinition(invalidNestedType).hasErrors());

    declaration = getDeclaration("org.codehaus.enunciate.samples.schema.ExtendedFullTypeDefBeanOne");
    ComplexTypeDefinition validNestedType = new ComplexTypeDefinition((ClassDeclaration) declaration.getNestedTypes().iterator().next());
    resetCounters(packageCounter, attributeCounter, valueCounter, elementCounter, elementRefCounter, xmlIdCounter);
    assertFalse("A public static nested type should be a valid type definition.", validator.validateTypeDefinition(validNestedType).hasErrors());
    assertEquals(1, packageCounter.getCount());
    assertEquals(0, attributeCounter.getCount());
    assertEquals(0, valueCounter.getCount());
View Full Code Here

TOP

Related Classes of com.sun.mirror.declaration.TypeDeclaration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.