Package org.codehaus.enunciate.contract.jaxb.types

Examples of org.codehaus.enunciate.contract.jaxb.types.XmlType


      }
      else if (type instanceof EnumTypeDefinition) {
        parent.addContent(new org.jdom.Text("..."));
      }
      else {
        XmlType baseType = type.getBaseType();
        if (baseType instanceof XmlClassType) {
          TypeDefinition typeDef = ((XmlClassType) baseType).getTypeDefinition();
          if (typeDef != null) {
            generateExampleXml(typeDef, parent, defaultNs, maxDepth);
          }
View Full Code Here


            else {
              jdomNS = Namespace.getNamespace(prefix, namespace);
            }
            org.jdom.Element el = new org.jdom.Element(choice.getName(), jdomNS);
            String exampleValue = exampleInfo == null || "##default".equals(exampleInfo.value()) ? "..." : exampleInfo.value();
            XmlType xmlType = choice.getBaseType();
            if (i == 0) {
              generateExampleXml(xmlType, el, exampleValue, defaultNs, maxDepth);
            }
            else {
              if (xmlType instanceof XmlClassType) {
View Full Code Here

  public void generateExampleXml(XmlType type, org.jdom.Element parent, String example, String defaultNs, int maxDepth) {
    if (type instanceof XmlClassType) {
      generateExampleXml(((XmlClassType) type).getTypeDefinition(), parent, defaultNs, maxDepth);
    }
    else if (type instanceof MapXmlType) {
      XmlType keyType = ((MapXmlType) type).getKeyType();
      XmlType valueType = ((MapXmlType) type).getValueType();
      for (int i = 0; i < 2; i++) {
        org.jdom.Element entry = new org.jdom.Element("entry", parent.getNamespacePrefix(), parent.getNamespaceURI());
        org.jdom.Element key = new org.jdom.Element("key", parent.getNamespacePrefix(), parent.getNamespaceURI());
        org.jdom.Element value = new org.jdom.Element("value", parent.getNamespacePrefix(), parent.getNamespaceURI());
        if (i == 0) {
          generateExampleXml(keyType, key, null, defaultNs, maxDepth);
        }
        else {
          key.addContent(new Comment("(another '" + keyType.getName() + "' type)"));
        }
        entry.addContent(key);
        if (i == 0) {
          generateExampleXml(valueType, value, null, defaultNs, maxDepth);
        }
        else {
          value.addContent(new Comment("(another '" + valueType.getName() + "' type)"));
        }
        entry.addContent(value);
        parent.addContent(entry);
      }
      parent.addContent(new org.jdom.Comment("...more entries..."));
View Full Code Here

    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    QName qname = KnownXmlType.STRING.getQname();
    String name;
    if (unwrapped instanceof XmlType) {
      XmlType xmlType = (XmlType) unwrapped;
      if (xmlType instanceof XmlClassType && ((XmlClassType)xmlType).getTypeDefinition().isEnum()) {
        qname = KnownXmlType.STRING.getQname();
      }
      else {
        qname = xmlType.getQname();
      }
    }
    else if (unwrapped instanceof ResourceEntityParameter || unwrapped instanceof ResourceRepresentationMetadata) {
      ElementDeclaration xmlElement = (unwrapped instanceof ResourceEntityParameter) ? ((ResourceEntityParameter) unwrapped).getXmlElement() : ((ResourceRepresentationMetadata)unwrapped).getXmlElement();
      if (xmlElement instanceof RootElementDeclaration) {
View Full Code Here

    assertEquals("property5", element.getName());
    assertNull(element.getNamespace());
    assertNull(element.getRef());
    DeclaredType enumType = Context.getCurrentEnvironment().getTypeUtils().getDeclaredType((TypeDeclaration) enumDef.getDelegate());
    assertTrue(element.getAccessorType().equals(enumType));
    XmlType baseType = element.getBaseType();
    assertEquals(enumDef.getName(), baseType.getName());
    assertEquals(enumDef.getNamespace(), baseType.getNamespace());
    assertFalse(element.isNillable());
    assertFalse(element.isRequired());
    assertEquals(0, element.getMinOccurs());
    assertEquals("1", element.getMaxOccurs());
    assertFalse(element.isWrapped());
View Full Code Here

  public void testKnownTypes() throws Exception {

    Map<String, XmlType> knownTypes = new EnunciateFreemarkerModel().loadKnownTypes();

    //JAXB 2.0 Spec, section 8.5.1:
    XmlType knownType = knownTypes.get(Boolean.TYPE.getName());
    assertNotNull("The primitive boolean type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("boolean", knownType.getName());
    knownType = knownTypes.get(Byte.TYPE.getName());
    assertNotNull("The primitive byte type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("byte", knownType.getName());
    knownType = knownTypes.get(Short.TYPE.getName());
    assertNotNull("The primitive short type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("short", knownType.getName());
    knownType = knownTypes.get(Integer.TYPE.getName());
    assertNotNull("The primitive int type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("int", knownType.getName());
    knownType = knownTypes.get(Long.TYPE.getName());
    assertNotNull("The primitive long type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("long", knownType.getName());
    knownType = knownTypes.get(Float.TYPE.getName());
    assertNotNull("The primitive float type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("float", knownType.getName());
    knownType = knownTypes.get(Double.TYPE.getName());
    assertNotNull("The primitive double type should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("double", knownType.getName());
    knownType = knownTypes.get(Boolean.class.getName());
    assertNotNull("The boolean wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("boolean", knownType.getName());
    knownType = knownTypes.get(Byte.class.getName());
    assertNotNull("The byte wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("byte", knownType.getName());
    knownType = knownTypes.get(Short.class.getName());
    assertNotNull("The short wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("short", knownType.getName());
    knownType = knownTypes.get(Integer.class.getName());
    assertNotNull("The integer wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("int", knownType.getName());
    knownType = knownTypes.get(Long.class.getName());
    assertNotNull("The long wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("long", knownType.getName());
    knownType = knownTypes.get(Float.class.getName());
    assertNotNull("The float wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("float", knownType.getName());
    knownType = knownTypes.get(Double.class.getName());
    assertNotNull("The double wrapper class should be a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("double", knownType.getName());

    //JAXB 2.0 Spec, section 8.5.2:
    knownType = knownTypes.get(String.class.getName());
    assertNotNull("java.lang.String should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("string", knownType.getName());
    knownType = knownTypes.get(java.math.BigInteger.class.getName());
    assertNotNull("java.math.BigInteger should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("integer", knownType.getName());
    knownType = knownTypes.get(java.math.BigDecimal.class.getName());
    assertNotNull("java.math.BigDecimal should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("decimal", knownType.getName());
    knownType = knownTypes.get(java.util.Calendar.class.getName());
    assertNotNull("java.util.Calendar should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("dateTime", knownType.getName());
    knownType = knownTypes.get(java.util.Date.class.getName());
    assertNotNull("java.util.Date should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("dateTime", knownType.getName());
    knownType = knownTypes.get(javax.xml.namespace.QName.class.getName());
    assertNotNull("javax.xml.namespace.QName should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("QName", knownType.getName());
    knownType = knownTypes.get(java.net.URI.class.getName());
    assertNotNull("java.net.URI should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("string", knownType.getName());
    knownType = knownTypes.get(javax.xml.datatype.XMLGregorianCalendar.class.getName());
    assertNotNull("javax.xml.datatype.XMLGregorianCalendar should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("dateTime", knownType.getName());
    knownType = knownTypes.get(javax.xml.datatype.Duration.class.getName());
    assertNotNull("javax.xml.datatype.Duration should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("duration", knownType.getName());
    knownType = knownTypes.get(java.lang.Object.class.getName());
    assertNotNull("java.lang.Object should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("anyType", knownType.getName());
    knownType = knownTypes.get(java.awt.Image.class.getName());
    assertNotNull("java.awt.Image should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("base64Binary", knownType.getName());
    knownType = knownTypes.get(javax.xml.transform.Source.class.getName());
    assertNotNull("javax.xml.transform.Source should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("base64Binary", knownType.getName());
    knownType = knownTypes.get(java.util.UUID.class.getName());
    assertNotNull("java.util.UUID should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("string", knownType.getName());
    knownType = knownTypes.get("javax.activation.DataHandler");
    assertNotNull("javax.activation.DataHandler should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("base64Binary", knownType.getName());
    knownType = knownTypes.get(byte[].class.getName());
    assertNotNull("byte[] should have a known type.", knownType);
    assertEquals("http://www.w3.org/2001/XMLSchema", knownType.getNamespace());
    assertEquals("base64Binary", knownType.getName());
  }
View Full Code Here

  public void testBaseType() throws Exception {
    EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
    FreemarkerModel.set(model);

    SimpleTypeDefinition simpleType = new SimpleTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.SimpleTypeSimpleContentBean"));
    XmlType baseType = simpleType.getBaseType();
    assertEquals(KnownXmlType.INT.getQname(), baseType.getQname());
  }
View Full Code Here

    ComplexTypeDefinition complexContentType = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne"));
    assertEquals(KnownXmlType.ANY_TYPE, complexContentType.getBaseType());
    model.add(complexContentType);
    ComplexTypeDefinition exComplexContentType = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.ExtendedBeanOne"));
    XmlType baseType = exComplexContentType.getBaseType();
    assertEquals(complexContentType.getName(), baseType.getName());
    assertEquals(complexContentType.getNamespace(), baseType.getNamespace());
  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.jaxb.types.XmlType

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.