Package org.jboss.xb.annotations

Examples of org.jboss.xb.annotations.JBossXmlSchema


      if (defaultNamespace == null)
      {
         defaultNamespace = (String) schemaBinding.getNamespaces().iterator().next();
      }

      JBossXmlSchema jbossXmlSchema = root.getUnderlyingAnnotation(JBossXmlSchema.class);
      if (jbossXmlSchema != null)
      {
         attributeForm = jbossXmlSchema.attributeFormDefault();
         elementForm = jbossXmlSchema.elementFormDefault();
      }

      // Look for an annotation
      PackageInfo packageInfo = root.getPackage();
      if (packageInfo != null)
      {
         jbossXmlSchema = root.getUnderlyingAnnotation(JBossXmlSchema.class);
         if (jbossXmlSchema != null)
         {
            if (attributeForm == XmlNsForm.UNSET)
               attributeForm = jbossXmlSchema.attributeFormDefault();
            if (elementForm == XmlNsForm.UNSET)
               elementForm = jbossXmlSchema.elementFormDefault();
         }

         XmlSchema xmlSchema = packageInfo.getUnderlyingAnnotation(XmlSchema.class);
         if (xmlSchema != null)
         {
View Full Code Here


    * @param classInfo the classInfo
    */
   protected static void initSchema(SchemaBinding schemaBinding, ClassInfo classInfo)
   {
      // Look for a schema attribute on either the root or the root's package
      JBossXmlSchema schema = classInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      PackageInfo packageInfo = classInfo.getPackage();
      if (schema == null && packageInfo != null)
      {
         schema = packageInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      }
     
      // Use the root's package name
      String packageName = null;
      if (packageInfo != null)
         packageName = packageInfo.getName();
      // Look for annotation override
      if (schema != null)
      {
         String schemaPackageName = schema.packageName();
         if (JBossXmlConstants.DEFAULT.equals(schemaPackageName) == false)
            packageName = schemaPackageName;
        
         if(schema.xmlns().length > 0)
         {
            for(int i = 0; i < schema.xmlns().length; ++i)
            {
               schemaBinding.addPrefixMapping(schema.xmlns()[i].prefix(), schema.xmlns()[i].namespaceURI());
            }
         }
      }

      // Set the default namespace, if there are none already
      if (schemaBinding.getNamespaces().isEmpty())
      {
         String namespace = XMLConstants.NULL_NS_URI;
         if (schema != null)
         {
            String schemaNamespace = schema.namespace();
            if (JBossXmlConstants.DEFAULT.equals(schemaNamespace) == false)
               namespace = schemaNamespace;
         }
         schemaBinding.setNamespaces(new HashSet<String>(Collections.singleton(namespace)));
      }
     
      // Apply the package name
      if (packageName != null)
      {
         PackageMetaData packageMetaData = new PackageMetaData();
         packageMetaData.setName(packageName);
         schemaBinding.setPackageMetaData(packageMetaData);
      }

      // Nothing more to do if no annotation
      if (schema == null)
         return;
     
      // Apply the annotation values
      schemaBinding.setIgnoreUnresolvedFieldOrClass(schema.ignoreUnresolvedFieldOrClass());
      schemaBinding.setIgnoreLowLine(schema.ignoreLowLine());
      schemaBinding.setReplacePropertyRefs(schema.replacePropertyRefs());
      schemaBinding.setStrictSchema(schema.strict());
   }
View Full Code Here

/*  200 */     if (this.defaultNamespace == null)
/*      */     {
/*  202 */       this.defaultNamespace = ((String)this.schemaBinding.getNamespaces().iterator().next());
/*      */     }
/*      */
/*  205 */     JBossXmlSchema jbossXmlSchema = (JBossXmlSchema)this.root.getUnderlyingAnnotation(JBossXmlSchema.class);
/*  206 */     if (jbossXmlSchema != null)
/*      */     {
/*  208 */       this.attributeForm = jbossXmlSchema.attributeFormDefault();
/*  209 */       this.elementForm = jbossXmlSchema.elementFormDefault();
/*      */     }
/*      */
/*  213 */     PackageInfo packageInfo = this.root.getPackage();
/*  214 */     if (packageInfo != null)
/*      */     {
/*  216 */       jbossXmlSchema = (JBossXmlSchema)this.root.getUnderlyingAnnotation(JBossXmlSchema.class);
/*  217 */       if (jbossXmlSchema != null)
/*      */       {
/*  219 */         if (this.attributeForm == XmlNsForm.UNSET)
/*  220 */           this.attributeForm = jbossXmlSchema.attributeFormDefault();
/*  221 */         if (this.elementForm == XmlNsForm.UNSET) {
/*  222 */           this.elementForm = jbossXmlSchema.elementFormDefault();
/*      */         }
/*      */       }
/*  225 */       XmlSchema xmlSchema = (XmlSchema)packageInfo.getUnderlyingAnnotation(XmlSchema.class);
/*  226 */       if (xmlSchema != null)
/*      */       {
View Full Code Here

/* 105 */     return binding;
/*     */   }
/*     */
/*     */   protected static void initSchema(SchemaBinding schemaBinding, ClassInfo classInfo)
/*     */   {
/* 117 */     JBossXmlSchema schema = (JBossXmlSchema)classInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
/* 118 */     PackageInfo packageInfo = classInfo.getPackage();
/* 119 */     if ((schema == null) && (packageInfo != null))
/*     */     {
/* 121 */       schema = (JBossXmlSchema)packageInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
/*     */     }
/*     */
/* 125 */     String packageName = null;
/* 126 */     if (packageInfo != null) {
/* 127 */       packageName = packageInfo.getName();
/*     */     }
/* 129 */     if (schema != null)
/*     */     {
/* 131 */       String schemaPackageName = schema.packageName();
/* 132 */       if (!"##default".equals(schemaPackageName)) {
/* 133 */         packageName = schemaPackageName;
/*     */       }
/* 135 */       if (schema.xmlns().length > 0)
/*     */       {
/* 137 */         for (int i = 0; i < schema.xmlns().length; i++)
/*     */         {
/* 139 */           schemaBinding.addPrefixMapping(schema.xmlns()[i].prefix(), schema.xmlns()[i].namespaceURI());
/*     */         }
/*     */       }
/*     */
/*     */     }
/*     */
/* 145 */     if (schemaBinding.getNamespaces().isEmpty())
/*     */     {
/* 147 */       String namespace = "";
/* 148 */       if (schema != null)
/*     */       {
/* 150 */         String schemaNamespace = schema.namespace();
/* 151 */         if (!"##default".equals(schemaNamespace))
/* 152 */           namespace = schemaNamespace;
/*     */       }
/* 154 */       schemaBinding.setNamespaces(new HashSet(Collections.singleton(namespace)));
/*     */     }
/*     */
/* 158 */     if (packageName != null)
/*     */     {
/* 160 */       PackageMetaData packageMetaData = new PackageMetaData();
/* 161 */       packageMetaData.setName(packageName);
/* 162 */       schemaBinding.setPackageMetaData(packageMetaData);
/*     */     }
/*     */
/* 166 */     if (schema == null) {
/* 167 */       return;
/*     */     }
/*     */
/* 170 */     schemaBinding.setIgnoreUnresolvedFieldOrClass(schema.ignoreUnresolvedFieldOrClass());
/* 171 */     schemaBinding.setIgnoreLowLine(schema.ignoreLowLine());
/* 172 */     schemaBinding.setReplacePropertyRefs(schema.replacePropertyRefs());
/* 173 */     schemaBinding.setStrictSchema(schema.strict());
/*     */   }
View Full Code Here

      if (defaultNamespace == null)
      {
         defaultNamespace = (String) schemaBinding.getNamespaces().iterator().next();
      }

      JBossXmlSchema jbossXmlSchema = root.getUnderlyingAnnotation(JBossXmlSchema.class);
      if (jbossXmlSchema != null)
      {
         attributeForm = jbossXmlSchema.attributeFormDefault();
         elementForm = jbossXmlSchema.elementFormDefault();
      }

      // Look for an annotation
      PackageInfo packageInfo = root.getPackage();
      if (packageInfo != null)
      {
         jbossXmlSchema = root.getUnderlyingAnnotation(JBossXmlSchema.class);
         if (jbossXmlSchema != null)
         {
            if (attributeForm == XmlNsForm.UNSET)
               attributeForm = jbossXmlSchema.attributeFormDefault();
            if (elementForm == XmlNsForm.UNSET)
               elementForm = jbossXmlSchema.elementFormDefault();
         }

         XmlSchema xmlSchema = packageInfo.getUnderlyingAnnotation(XmlSchema.class);
         if (xmlSchema != null)
         {
View Full Code Here

    * @param metadata the metadata class
    * @return jboss xml schema namespace
    */
   public static String findNamespace(Class<?> metadata)
   {
      JBossXmlSchema jBossXmlSchema = metadata.getAnnotation(JBossXmlSchema.class);
      if (jBossXmlSchema == null)
      {
         Package pckg = metadata.getPackage();
         if (pckg != null)
            jBossXmlSchema = pckg.getAnnotation(JBossXmlSchema.class);
      }
      return jBossXmlSchema != null ? jBossXmlSchema.namespace() : null;
   }
View Full Code Here

         throw new IllegalArgumentException("Null root");

      ClassInfo classInfo = JBossXBBuilder.configuration.getClassInfo(root);

      // add prefix mappings
      JBossXmlSchema schema = classInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      PackageInfo packageInfo = classInfo.getPackage();
      if (schema == null && packageInfo != null)
      {
         schema = packageInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      }

      String classNamespace = XMLConstants.NULL_NS_URI;
      Set<String> schemaNamespaces = schemaBinding.getNamespaces();
      String schemaNamespace = schemaNamespaces.iterator().next();
      if(schema != null)
      {
         // check the default namespaces are equal
         if(!JBossXmlConstants.DEFAULT.equals(schema.namespace()))
            classNamespace = schema.namespace();

         // add prefix mappings
         if (schema.xmlns().length > 0)
         {
            for(int i = 0; i < schema.xmlns().length; ++i)
            {
               String prefix = schema.xmlns()[i].prefix();
               String existingMapping = schemaBinding.getNamespace(prefix);
               if(existingMapping != null)
               {
                  String newMapping = schema.xmlns()[i].namespaceURI();
                  if(!existingMapping.equals(newMapping))
                     throw new IllegalStateException("Class " + root.getName() + " maps prefix '" + prefix +
                           "' to namespace '" + newMapping + "' while in the schema binding it is mapped to '" + existingMapping + "'");
               }
               else
                  schemaBinding.addPrefixMapping(prefix, schema.xmlns()[i].namespaceURI());
            }
         }
      }

      if(!classNamespace.equals(schemaNamespace))
View Full Code Here

    * @param classInfo the classInfo
    */
   protected static void initSchema(SchemaBinding schemaBinding, ClassInfo classInfo)
   {
      // Look for a schema attribute on either the root or the root's package
      JBossXmlSchema schema = classInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      PackageInfo packageInfo = classInfo.getPackage();
      if (schema == null && packageInfo != null)
      {
         schema = packageInfo.getUnderlyingAnnotation(JBossXmlSchema.class);
      }
     
      // Use the root's package name
      String packageName = null;
      if (packageInfo != null)
         packageName = packageInfo.getName();
      // Look for annotation override
      if (schema != null)
      {
         String schemaPackageName = schema.packageName();
         if (JBossXmlConstants.DEFAULT.equals(schemaPackageName) == false)
            packageName = schemaPackageName;
        
         if(schema.xmlns().length > 0)
         {
            for(int i = 0; i < schema.xmlns().length; ++i)
            {
               schemaBinding.addPrefixMapping(schema.xmlns()[i].prefix(), schema.xmlns()[i].namespaceURI());
            }
         }
      }

      // Set the default namespace, if there are none already
      if (schemaBinding.getNamespaces().isEmpty())
      {
         String namespace = XMLConstants.NULL_NS_URI;
         if (schema != null)
         {
            String schemaNamespace = schema.namespace();
            if (JBossXmlConstants.DEFAULT.equals(schemaNamespace) == false)
               namespace = schemaNamespace;
         }
         schemaBinding.setNamespaces(new HashSet<String>(Collections.singleton(namespace)));
      }
     
      // Apply the package name
      if (packageName != null)
      {
         PackageMetaData packageMetaData = new PackageMetaData();
         packageMetaData.setName(packageName);
         schemaBinding.setPackageMetaData(packageMetaData);
      }

      // Nothing more to do if no annotation
      if (schema == null)
         return;
     
      // Apply the annotation values
      schemaBinding.setIgnoreUnresolvedFieldOrClass(schema.ignoreUnresolvedFieldOrClass());
      schemaBinding.setIgnoreLowLine(schema.ignoreLowLine());
      schemaBinding.setReplacePropertyRefs(schema.replacePropertyRefs());
      schemaBinding.setStrictSchema(schema.strict());
      schemaBinding.setNormalizeSpace(schema.normalizeSpace());
   }
View Full Code Here

    * @return jboss xml schema namespace
    */
   protected String findNamespace()
   {
      Class<T> metadata = getOutput();
      JBossXmlSchema jBossXmlSchema = metadata.getAnnotation(JBossXmlSchema.class);
      if (jBossXmlSchema == null)
      {
         Package pckg = metadata.getPackage();
         if (pckg != null)
            jBossXmlSchema = pckg.getAnnotation(JBossXmlSchema.class);
      }
      return jBossXmlSchema != null ? jBossXmlSchema.namespace() : null;
   }
View Full Code Here

TOP

Related Classes of org.jboss.xb.annotations.JBossXmlSchema

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.