org.jboss.xb.binding
Class AbstractMarshaller
java.lang.Object
org.jboss.xb.binding.AbstractMarshaller
- All Implemented Interfaces:
- Marshaller
- Direct Known Subclasses:
- DtdMarshaller, MarshallerImpl, XercesXsMarshaller
public abstract class AbstractMarshaller
- extends Object
- implements Marshaller
- Version:
- $Revision: 2913 $
- Author:
- Alexey Loubyansky
Method Summary |
abstract void |
addAttribute(String prefix,
String localName,
String type,
String value)
|
void |
addRootElement(QName qName)
|
void |
addRootElement(String namespaceUri,
String prefix,
String name)
|
void |
declareNamespace(String prefix,
String uri)
Defines a namespace. |
protected void |
declareNs(AttributesImpl attrs)
|
protected static void |
declareNs(AttributesImpl attrs,
String prefix,
String ns)
|
protected String |
declareXsiType(QName typeQName,
AttributesImpl attrs)
Adds xsi:type attribute and optionally declares namespaces for xsi and type's namespace. |
protected AbstractMarshaller.ClassMapping |
getClassMapping(Class<?> cls)
|
String |
getPrefix(String ns)
|
String |
getProperty(String name)
|
void |
mapClassToGlobalElement(Class<?> cls,
String localName,
String namespaceUri,
String schemaUrl,
ObjectModelProvider provider)
|
void |
mapClassToGlobalType(Class<?> cls,
String localName,
String nsUri,
String schemaUrl,
ObjectModelProvider provider)
|
void |
mapClassToXsiType(Class<?> cls,
String typeNs,
String typeLocalPart)
|
void |
mapFieldToWildcard(Class<?> cls,
String field,
ObjectLocalMarshaller marshaller)
|
void |
mapPublicIdToSystemId(String publicId,
String systemId)
|
protected static String |
prefixLocalName(String prefix,
String local)
|
protected boolean |
propertyIsTrueOrNotSet(String name)
|
void |
removePrefixMapping(String prefix)
|
void |
setEncoding(String encoding)
|
void |
setProperty(String name,
String value)
|
void |
setVersion(String version)
|
protected void |
writeXmlVersion(Writer writer)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final org.jboss.logging.Logger log
version
protected String version
encoding
protected String encoding
rootQNames
protected List<QName> rootQNames
nsRegistry
protected NamespaceRegistry nsRegistry
field2WildcardMap
protected Map<Class<?>,AbstractMarshaller.FieldToWildcardMapping> field2WildcardMap
cls2TypeMap
protected Map<Class<?>,QName> cls2TypeMap
content
protected Content content
- Content the result is written to
AbstractMarshaller
public AbstractMarshaller()
mapClassToGlobalElement
public void mapClassToGlobalElement(Class<?> cls,
String localName,
String namespaceUri,
String schemaUrl,
ObjectModelProvider provider)
- Specified by:
mapClassToGlobalElement
in interface Marshaller
mapClassToGlobalType
public void mapClassToGlobalType(Class<?> cls,
String localName,
String nsUri,
String schemaUrl,
ObjectModelProvider provider)
- Specified by:
mapClassToGlobalType
in interface Marshaller
mapFieldToWildcard
public void mapFieldToWildcard(Class<?> cls,
String field,
ObjectLocalMarshaller marshaller)
mapClassToXsiType
public void mapClassToXsiType(Class<?> cls,
String typeNs,
String typeLocalPart)
setVersion
public void setVersion(String version)
- Specified by:
setVersion
in interface Marshaller
setEncoding
public void setEncoding(String encoding)
- Specified by:
setEncoding
in interface Marshaller
mapPublicIdToSystemId
public void mapPublicIdToSystemId(String publicId,
String systemId)
- Specified by:
mapPublicIdToSystemId
in interface Marshaller
addRootElement
public void addRootElement(String namespaceUri,
String prefix,
String name)
- Specified by:
addRootElement
in interface Marshaller
addRootElement
public void addRootElement(QName qName)
setProperty
public void setProperty(String name,
String value)
- Specified by:
setProperty
in interface Marshaller
getProperty
public String getProperty(String name)
- Specified by:
getProperty
in interface Marshaller
declareNamespace
public void declareNamespace(String prefix,
String uri)
- Defines a namespace. The namespace declaration will appear in the root element.
If prefix
argument is null
or is an empty string then
the passed in URI will be used for the default namespace, i.e. xmlns
.
Otherwise, the declaration will follow the format xmlns:prefix=uri
.
If the namespace with the given prefix was already declared, its value is overwritten.
- Parameters:
prefix
- the prefix for the namespace to declare (can be null or empty string)uri
- the URI of the namespace.
removePrefixMapping
public void removePrefixMapping(String prefix)
getPrefix
public String getPrefix(String ns)
declareNs
protected void declareNs(AttributesImpl attrs)
declareNs
protected static void declareNs(AttributesImpl attrs,
String prefix,
String ns)
declareXsiType
protected String declareXsiType(QName typeQName,
AttributesImpl attrs)
- Adds xsi:type attribute and optionally declares namespaces for xsi and type's namespace.
- Parameters:
typeQName
- the type to declare xsi:type attribute forattrs
- the attributes to add xsi:type attribute to
- Returns:
- prefix for the type's ns if it was generated
prefixLocalName
protected static String prefixLocalName(String prefix,
String local)
addAttribute
public abstract void addAttribute(String prefix,
String localName,
String type,
String value)
propertyIsTrueOrNotSet
protected boolean propertyIsTrueOrNotSet(String name)
writeXmlVersion
protected void writeXmlVersion(Writer writer)
throws IOException
- Throws:
IOException
getClassMapping
protected AbstractMarshaller.ClassMapping getClassMapping(Class<?> cls)
Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.