Package net.sf.jelly.apt.decorations.declaration

Examples of net.sf.jelly.apt.decorations.declaration.PropertyDeclaration


    if (isXmlTransient(declaration)) {
      return false;
    }

    if (declaration instanceof PropertyDeclaration) {
      PropertyDeclaration property = ((PropertyDeclaration) declaration);

      if ("".equals(property.getPropertyName())) {
        return false;
      }

      for (String annotationName : property.getAnnotations().keySet()) {
        if (annotationName.startsWith("javax.xml.bind.annotation")) {
          //if the property has an explicit annotation, we'll include it.
          return true;
        }
      }

      DecoratedMethodDeclaration getter = property.getGetter();
      if (getter == null) {
        //needs a getter.
        return false;
      }

      DecoratedMethodDeclaration setter = property.getSetter();
      if (setter == null) {
        //needs a setter.
        return false;
      }
View Full Code Here


  public ValidationResult validateAccessor(Accessor accessor) {
    ValidationResult result = new ValidationResult();

    if (accessor.getDelegate() instanceof PropertyDeclaration) {
      PropertyDeclaration property = (PropertyDeclaration) accessor.getDelegate();
      DecoratedMethodDeclaration getter = property.getGetter();
      DecoratedMethodDeclaration setter = property.getSetter();

      if ((getter != null) && (setter != null)) {
        //find all JAXB annotations that are on both the setter and the getter...
        Map<String, AnnotationMirror> getterAnnotations = getter.getAnnotations();
        Map<String, AnnotationMirror> setterAnnotations = setter.getAnnotations();
View Full Code Here

    this.annotation = getAnnotation(javax.xml.ws.WebFault.class);

    ClassType explicitFaultBeanType = null;
    Collection<PropertyDeclaration> properties = getProperties();
    PropertyDeclaration faultInfoProperty = null;
    for (PropertyDeclaration propertyDeclaration : properties) {
      if ("faultInfo".equals(propertyDeclaration.getPropertyName())) {
        faultInfoProperty = propertyDeclaration;
        break;
      }
    }

    if ((faultInfoProperty != null) && (faultInfoProperty.getPropertyType() instanceof ClassType)) {
      ClassType faultInfoType = (ClassType) faultInfoProperty.getPropertyType();
      if (faultInfoType.getDeclaration() == null) {
        throw new ValidationException(getPosition(), getQualifiedName() + ": class not found: " + faultInfoType + ".");
      }

      boolean messageConstructorFound = false;
      boolean messageAndThrowableConstructorFound = false;
      Collection<ConstructorDeclaration> constructors = getConstructors();
      for (ConstructorDeclaration constructor : constructors) {
        if (constructor.getModifiers().contains(Modifier.PUBLIC)) {
          ParameterDeclaration[] parameters = constructor.getParameters().toArray(new ParameterDeclaration[constructor.getParameters().size()]);
          if (parameters.length >= 2) {
            DecoratedTypeMirror param0Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[0].getType());
            DecoratedTypeMirror param1Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[1].getType());
            if (parameters.length == 2) {
              messageConstructorFound |= param0Type.isInstanceOf(String.class.getName()) && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName());
            }
            else if (parameters.length == 3) {
              DecoratedTypeMirror param2Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[2].getType());
              messageAndThrowableConstructorFound |= param0Type.isInstanceOf(String.class.getName())
                && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName())
                && param2Type.isInstanceOf(Throwable.class.getName());
            }
          }
        }
      }

      if (messageConstructorFound && messageAndThrowableConstructorFound) {
        explicitFaultBeanType = faultInfoType;
      }
    }

    if (faultInfoProperty != null && explicitFaultBeanType == null) {
      throw new ValidationException(faultInfoProperty.getPosition(), "The 'getFaultInfo' method is only allowed on a web fault if you're " +
        "declaring an explicit fault bean, and you don't have the right constructor signatures set up in order for '" +
        faultInfoProperty.getPropertyType() + "' to be an explicit fault bean.");
    }

    this.explicitFaultBeanType = explicitFaultBeanType;
    this.facets.addAll(Facet.gatherFacets(delegate));
  }
View Full Code Here

      }
    };

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.InvalidElementBean"));
    Iterator<PropertyDeclaration> propIt = typeDef.getProperties().iterator();
    PropertyDeclaration property1 = propIt.next();
    Element element = new Element(property1, typeDef);
    assertTrue("An typed collection element shouldn't have multiple XmlElements.", validator.validateElement(element).hasErrors());
    assertEquals(1, accessorCounter.getCount());

    //todo: test that elements of a different namespace then their type defs aren't allowed if the form is qualified.
View Full Code Here

      }
    };

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.InvalidElementRefBean"));
    Iterator<PropertyDeclaration> propIt = typeDef.getProperties().iterator();
    PropertyDeclaration property1 = propIt.next();
    ElementRef ref = new ElementRef(property1, typeDef);
    assertTrue(validator.validateElementRef(ref).hasErrors());
    assertEquals(1, accessorCounter.getCount());
  }
View Full Code Here

    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());
    model.add(elementBeanOneType);
    model.add(elementBeanOne);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ElementRefBeanOne"));
    PropertyDeclaration property = findProperty(typeDef, "property1");
    ElementRef element = new ElementRef(property, typeDef);
    assertEquals(1, element.getChoices().size());
    assertSame(element, element.getChoices().iterator().next());
    assertEquals("element-bean-one", element.getName());
    assertEquals("urn:element-bean-one", element.getNamespace());
    assertNotNull(element.getRef());
    assertEquals(property.getPropertyType(), element.getAccessorType());

    assertFalse(element.isNillable());
    assertFalse(element.isRequired());
    assertEquals(0, element.getMinOccurs());
    assertEquals("1", element.getMaxOccurs());
View Full Code Here

    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());
    model.add(elementBeanOneType);
    model.add(elementBeanOne);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ElementRefBeanOne"));
    PropertyDeclaration property = findProperty(typeDef, "property2");
    ElementRef element = new ElementRef(property, typeDef);
    assertEquals(1, element.getChoices().size());
    assertSame(element, element.getChoices().iterator().next());
    assertEquals("beanThree", element.getName());
    assertNull(element.getNamespace());
View Full Code Here

    EnunciateFreemarkerModel model = ((EnunciateFreemarkerModel) FreemarkerModel.get());
    model.add(elementBeanOneType);
    model.add(elementBeanOne);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ElementRefBeanOne"));
    PropertyDeclaration property = findProperty(typeDef, "property3");
    ElementRef element = new ElementRef(property, typeDef);
    assertEquals(1, element.getChoices().size());
    assertSame(element, element.getChoices().iterator().next());
    assertEquals("beanone", element.getName());
    assertEquals("urn:beanone", element.getNamespace());
    assertNotNull(element.getRef());
    assertEquals(property.getPropertyType(), element.getAccessorType());

    assertFalse(element.isNillable());
    assertFalse(element.isRequired());
    assertEquals(0, element.getMinOccurs());
    assertEquals("1", element.getMaxOccurs());
View Full Code Here

    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.ElementRefsBean"));
    PropertyDeclaration property = findProperty(typeDef, "beanThrees");
    ElementRef element = new ElementRef(property, typeDef);
    assertEquals(1, element.getChoices().size());
    ElementRef firstChoice = element.getChoices().iterator().next();
    assertEquals("beanThree", firstChoice.getName());
    assertEquals("http://org.codehaus.enunciate/core/samples/another", firstChoice.getNamespace());
View Full Code Here

    rootElementDeclaration = new RootElementDeclaration(decl, type);
    model.add(type);
    model.add(rootElementDeclaration);

    ComplexTypeDefinition typeDef = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.ElementRefsBean"));
    PropertyDeclaration property = findProperty(typeDef, "beanOnes");
    ElementRef element = new ElementRef(property, typeDef);
    Collection<ElementRef> choices = element.getChoices();
    assertEquals(3, choices.size());
    Iterator<ElementRef> iterator = choices.iterator();
//    ElementRef firstChoice = iterator.next();
View Full Code Here

TOP

Related Classes of net.sf.jelly.apt.decorations.declaration.PropertyDeclaration

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.