Package org.codehaus.enunciate.contract.jaxb

Examples of org.codehaus.enunciate.contract.jaxb.TypeDefinition


    EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
    TypeDeclaration declaringType = a.getDeclaringType();
    if (declaringType instanceof ClassDeclaration) {
      declaringType = ((ClassDeclaration) declaringType).getSuperclass().getDeclaration();
      while (declaringType instanceof ClassDeclaration && !Object.class.getName().equals(declaringType.getQualifiedName())) {
        TypeDefinition typeDef = model.findTypeDefinition((ClassDeclaration) declaringType);
        if (typeDef != null) {
          ArrayList<Accessor> accessors = new ArrayList<Accessor>();
          accessors.addAll(typeDef.getAttributes());
          accessors.add(typeDef.getValue());
          accessors.addAll(typeDef.getElements());
          for (Accessor accessor : accessors) {
            if (accessor != null && accessor.getAnnotation(XmlTransient.class) == null && name.equals(accessor.getSimpleName())) {
              return Boolean.TRUE;
            }
          }
View Full Code Here


        }
      }
      else {
        boolean xmlType = isPotentialXmlSchemaType(declaration);
        if (xmlType) {
          TypeDefinition typeDef = createTypeDefinition((ClassDeclaration) declaration, model);
          loadTypeDef(typeDef, model);
        }

        boolean jsonType = isPotentialJsonSchemaType(declaration);
        if (jsonType) {
View Full Code Here

        if (knownType != null) {
          xmlType = knownType;
        }
        else {
          //type not known, not specified.  Last chance: look for the type definition.
          TypeDefinition typeDefinition = model.findTypeDefinition(declaration);
          if (typeDefinition != null) {
            xmlType = new XmlClassType(typeDefinition);
          }
        }
      }
View Full Code Here

          return (((PrimitiveType) typeMirror).getKind()).toString();
      }
    }
    else if (typeMirror instanceof EnumType) {
      EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get();
      TypeDefinition typeDefinition = model.findTypeDefinition(((EnumType) typeMirror).getDeclaration());
      if (typeDefinition != null) {
        return typeDefName.calculateName(typeDefinition);
      }
    }
    else if ((typeMirror instanceof DeclaredType) && (((DeclaredType)typeMirror).getDeclaration() != null)) {
View Full Code Here

    NameForTypeDefinitionMethod nameForTypeDefinition = new NameForTypeDefinitionMethod(getTypeDefinitionNamePattern(), label, getModelInternal().getNamespacesToPrefixes(), this.packageIdentifiers);

    if (exampleResource != null) {
      if (exampleResource.getEntityParameter() != null && exampleResource.getEntityParameter().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getEntityParameter().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
        }

        if (typeDefinition != null) {
          model.put("input_element_name", nameForTypeDefinition.calculateName(typeDefinition));
        }
      }

      if (exampleResource.getRepresentationMetadata() != null && exampleResource.getRepresentationMetadata().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getRepresentationMetadata().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
View Full Code Here

    NameForTypeDefinitionMethod nameForTypeDefinition = new NameForTypeDefinitionMethod(getTypeDefinitionNamePattern(), label, getModelInternal().getNamespacesToPrefixes());

    if (exampleResource != null) {
      if (exampleResource.getEntityParameter() != null && exampleResource.getEntityParameter().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getEntityParameter().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
        }

        if (typeDefinition != null) {
          model.put("input_element_name", nameForTypeDefinition.calculateName(typeDefinition));
        }
      }

      if (exampleResource.getRepresentationMetadata() != null && exampleResource.getRepresentationMetadata().getXmlElement() != null) {
        ElementDeclaration el = exampleResource.getRepresentationMetadata().getXmlElement();
        TypeDefinition typeDefinition = null;
        if (el instanceof RootElementDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((RootElementDeclaration) el);
        }
        else if (el instanceof LocalElementDeclaration && ((LocalElementDeclaration) el).getElementTypeDeclaration() instanceof ClassDeclaration) {
          typeDefinition = getModelInternal().findTypeDefinition((ClassDeclaration) ((LocalElementDeclaration) el).getElementTypeDeclaration());
View Full Code Here

    }

    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    if (unwrapped instanceof ClassType) {
      TypeDefinition typeDefinition = ((EnunciateFreemarkerModel) FreemarkerModel.get()).findTypeDefinition(((ClassType) unwrapped).getDeclaration());
      return new QName(typeDefinition.getNamespace() == null ? "" : typeDefinition.getNamespace(), typeDefinition.getName());
    }

    throw new TemplateModelException("Unable to find qname for " + unwrapped);
  }
View Full Code Here

      }
    };
    FreemarkerModel.set(model);
    int nsCount = model.getNamespacesToPrefixes().size();
    ClassDeclaration declaration = (ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanThree");
    TypeDefinition typeDef1 = new ComplexTypeDefinition(declaration);
    RootElementDeclaration element1 = new RootElementDeclaration(declaration, typeDef1);
    String targetNamespace = element1.getNamespace();
    assertNull(model.findRootElementDeclaration(element1));
    model.add(element1);
    SchemaInfo schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
View Full Code Here

   * tests creating an adapetd type definition.
   */
  public void testCreateAdaptedTypeDefinition() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    TypeDefinition typeDef = model.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.RootElementMap"));
    model.add(typeDef);
    typeDef = model.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.RootElementMapAdapted"));
    model.add(typeDef);
    DefaultValidator validator = new DefaultValidator();
    for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
View Full Code Here

   * tests referencing an extended map.
   */
  public void testReferenceMapExtended() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);
    TypeDefinition typeDef = model.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.MapExtendedReference"));
    model.add(typeDef);
    typeDef = model.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.RootElementMapAdapted"));
    model.add(typeDef);
    DefaultValidator validator = new DefaultValidator();
    for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.jaxb.TypeDefinition

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.