|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.beans.BXMLSerializer
public class BXMLSerializer
Loads an object hierarchy from an XML document.
Field Summary | |
---|---|
static String |
BIND_MAPPING_DELIMITER
|
static String |
BXML_EXTENSION
|
static String |
BXML_PREFIX
|
static String |
DEFAULT_LANGUAGE
|
static String |
DEFINE_TAG
|
static String |
ID_ATTRIBUTE
|
static String |
INCLUDE_INLINE_ATTRIBUTE
|
static String |
INCLUDE_MIME_TYPE_ATTRIBUTE
|
static String |
INCLUDE_RESOURCES_ATTRIBUTE
|
static String |
INCLUDE_SRC_ATTRIBUTE
|
static String |
INCLUDE_TAG
|
static String |
INTERNAL_ID_PREFIX
|
static String |
LANGUAGE_PROCESSING_INSTRUCTION
|
static String |
MIME_TYPE
|
static String |
NAMESPACE_BINDING_PREFIX
|
static String |
NAMESPACE_BINDING_SUFFIX
|
static String |
NASHORN_COMPAT_SCRIPT
|
static String |
NASHORN_GLOBAL
|
static char |
OBJECT_REFERENCE_PREFIX
|
static String |
REFERENCE_ID_ATTRIBUTE
|
static String |
REFERENCE_TAG
|
static char |
RESOURCE_KEY_PREFIX
|
static String |
SCRIPT_SRC_ATTRIBUTE
|
static String |
SCRIPT_TAG
|
static char |
SLASH_PREFIX
|
static char |
URL_PREFIX
|
Constructor Summary | |
---|---|
BXMLSerializer()
|
|
BXMLSerializer(ClassLoader classLoader)
Deprecated. |
Method Summary | |
---|---|
void |
bind(Object object)
Applies BXML binding annotations to an object. |
void |
bind(Object object,
Class<?> type)
Applies BXML binding annotations to an object. |
Location |
getCurrentLocation()
Return the current location of the XML parser. |
protected String |
getDefaultLanguage()
|
static Map<String,String> |
getFileExtensions()
Returns the file extension/MIME type map. |
URL |
getLocation()
Returns the serializer's location. |
String |
getMIMEType(Object object)
Returns the MIME type of the data read and written by this serializer. |
static Map<String,Class<? extends Serializer<?>>> |
getMimeTypes()
Returns the MIME type/serializer class map. |
Map<String,Object> |
getNamespace()
Returns's the serializer's namespace. |
Resources |
getResources()
Returns the serializer's resource bundle. |
Object |
getRoot()
Retrieves the root of the object hierarchy most recently processed by this serializer. |
protected XMLStreamReader |
getXMLStreamReader()
Gets a read-only version of the XML stream reader that's being used by this serializer. |
protected Serializer<?> |
newIncludeSerializer(Class<? extends Serializer<?>> type)
Creates a new serializer to be used on a nested include. |
protected Object |
newTypedObject(Class<?> type)
Creates a new typed object as part of the deserialization process. |
Object |
readObject(Class<?> baseType,
String resourceName)
Deserializes an object hierarchy from a BXML resource. |
Object |
readObject(Class<?> baseType,
String resourceName,
boolean localize)
Deserializes an object hierarchy from a BXML resource. |
Object |
readObject(InputStream inputStream)
Deserializes an object hierarchy from a BXML resource. |
Object |
readObject(URL locationArgument)
Deserializes an object hierarchy from a BXML resource. |
Object |
readObject(URL locationArgument,
Resources resourcesArgument)
Deserializes an object hierarchy from a BXML resource. |
protected void |
reportException(Throwable exception)
Hook used for standardized reporting of exceptions during this process. |
protected void |
setDefaultLanguage(String defaultLanguage)
Set the default script language to use for all scripts. |
void |
setLocation(URL location)
Sets the serializer's location. |
void |
setNamespace(Map<String,Object> namespace)
Sets the serializer's namespace. |
void |
setResources(Resources resources)
Sets the serializer's resource bundle. |
void |
writeObject(Object object,
OutputStream outputStream)
Writes an object to an output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char URL_PREFIX
public static final char RESOURCE_KEY_PREFIX
public static final char OBJECT_REFERENCE_PREFIX
public static final char SLASH_PREFIX
public static final String NAMESPACE_BINDING_PREFIX
public static final String NAMESPACE_BINDING_SUFFIX
public static final String BIND_MAPPING_DELIMITER
public static final String INTERNAL_ID_PREFIX
public static final String LANGUAGE_PROCESSING_INSTRUCTION
public static final String NASHORN_GLOBAL
public static final String NASHORN_COMPAT_SCRIPT
public static final String BXML_PREFIX
public static final String BXML_EXTENSION
public static final String ID_ATTRIBUTE
public static final String INCLUDE_TAG
public static final String INCLUDE_SRC_ATTRIBUTE
public static final String INCLUDE_RESOURCES_ATTRIBUTE
public static final String INCLUDE_MIME_TYPE_ATTRIBUTE
public static final String INCLUDE_INLINE_ATTRIBUTE
public static final String SCRIPT_TAG
public static final String SCRIPT_SRC_ATTRIBUTE
public static final String DEFINE_TAG
public static final String REFERENCE_TAG
public static final String REFERENCE_ID_ATTRIBUTE
public static final String DEFAULT_LANGUAGE
public static final String MIME_TYPE
Constructor Detail |
---|
public BXMLSerializer()
@Deprecated public BXMLSerializer(ClassLoader classLoader)
Method Detail |
---|
public Object readObject(InputStream inputStream) throws IOException, SerializationException
This is the base version of the method. It does not set the "location" or "resources"
properties. Callers that wish to use this version of the method to load BXML that uses
location or resource resolution must manually set these properties via a call to
setLocation(URL)
or setResources(Resources)
, respectively, before calling
this method.
readObject
in interface Serializer<Object>
inputStream
- The data stream from which the object will be read.
IOException
SerializationException
public final Object readObject(Class<?> baseType, String resourceName) throws IOException, SerializationException
IOException
SerializationException
readObject(Class, String, boolean)
public final Object readObject(Class<?> baseType, String resourceName, boolean localize) throws IOException, SerializationException
The location of the resource is determined by a call to
Class.getResource(String)
on the given base type, passing the given
resource name as an argument. If the resources is localized, the base type
is also used as the base name of the resource bundle.
baseType
- The base type.resourceName
- The name of the BXML resource.localize
- If true, the deserialized resource will be localized using the resource
bundle specified by the base type. Otherwise, it will not be localized, and any
use of the resource resolution operator will result in a serialization exception.
IOException
SerializationException
readObject(URL, Resources)
public final Object readObject(URL locationArgument) throws IOException, SerializationException
This version of the method does not set the "resources" property. Callers
that wish to use this version of the method to load BXML that uses resource
resolution must manually set this property via a call to
setResources(Resources)
before calling this method.
locationArgument
- The location of the BXML resource.
IOException
SerializationException
readObject(URL, Resources)
public final Object readObject(URL locationArgument, Resources resourcesArgument) throws IOException, SerializationException
locationArgument
- The location of the BXML resource.resourcesArgument
- The resources that will be used to localize the deserialized resource.
#see readObject(InputStream)
IOException
SerializationException
public Location getCurrentLocation()
XMLStreamException.getLocation()
method).
protected void reportException(Throwable exception)
Subclasses should override this method in order to do something besides print to System.err.
public void writeObject(Object object, OutputStream outputStream) throws IOException, SerializationException
Serializer
writeObject
in interface Serializer<Object>
object
- The object to serialize.outputStream
- The data stream to which the object will be written.
IOException
SerializationException
public String getMIMEType(Object object)
Serializer
getMIMEType
in interface Serializer<Object>
object
- If provided, allows the serializer to attach parameters to the returned
MIME type containing more detailed information about the data. If
null, the base MIME type is returned.public Object getRoot()
public Map<String,Object> getNamespace()
Resolvable
getNamespace
in interface Resolvable
public void setNamespace(Map<String,Object> namespace)
Resolvable
setNamespace
in interface Resolvable
public URL getLocation()
Resolvable
getLocation
in interface Resolvable
public void setLocation(URL location)
Resolvable
setLocation
in interface Resolvable
public Resources getResources()
Resolvable
getResources
in interface Resolvable
public void setResources(Resources resources)
Resolvable
setResources
in interface Resolvable
public void bind(Object object)
object
- bind(Object, Class)
public void bind(Object object, Class<?> type) throws BindException
NOTE This method uses reflection to set internal member variables. As a result, it may only be called from trusted code.
object
- type
-
BindException
- If an error occurs during bindingprotected Serializer<?> newIncludeSerializer(Class<? extends Serializer<?>> type) throws InstantiationException, IllegalAccessException
Class.newInstance()
. Subclasses may
override this method to provide an alternate instantiation mechanism,
such as dependency-injected construction.
type
- The type of serializer being requested.
InstantiationException
IllegalAccessException
protected Object newTypedObject(Class<?> type) throws InstantiationException, IllegalAccessException
Class.newInstance()
.
Subclasses may override this method to provide an alternate instantiation
mechanism, such as dependency-injected construction.
type
- The type of object being requested.
InstantiationException
IllegalAccessException
protected final XMLStreamReader getXMLStreamReader()
public static Map<String,String> getFileExtensions()
getMimeTypes()
public static Map<String,Class<? extends Serializer<?>>> getMimeTypes()
protected void setDefaultLanguage(String defaultLanguage)
defaultLanguage
- Name of the new default script language,
or null
to set the default, default value.DEFAULT_LANGUAGE
protected String getDefaultLanguage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |