* @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());
}