public final class HandleSerializationEventArgs extends Object implements IEventArgs
HandleSerialization
and HandleSerialization
to
let registered serialization code perform the serialization of items.
If the event handler determines that it can serialize the Item
, it should use the Writer
for output and mark the event as Handled
so that other code will not perform serialization, too.
EMPTY
Constructor and Description |
---|
HandleSerializationEventArgs(IWriteContext context,
Object item)
Initializes a new instance of the
HandleSerializationEventArgs class using the provided context to write the item
using the given type for serialization. |
HandleSerializationEventArgs(IWriteContext context,
Object item,
Type serializationType)
Initializes a new instance of the
HandleSerializationEventArgs class using the provided context to write the item
using the given type for serialization. |
Modifier and Type | Method and Description |
---|---|
IWriteContext |
getContext()
Gets the context to be used for writing.
|
Object |
getItem()
Gets the item that should be serialized.
|
Type |
getSourceType()
Declares the type in the inheritance of the
Item that should be used for serialization. |
IXmlWriter |
getWriter()
Gets the writer for writing the xml output.
|
boolean |
isHandled()
Gets a value indicating whether this
HandleSerializationEventArgs is handled. |
void |
replaceItem(Object item,
Class serializationType)
Replaces the
Item using a substitute for serialization. |
void |
setHandled(boolean value)
Sets a value indicating whether this
HandleSerializationEventArgs is handled. |
public HandleSerializationEventArgs(IWriteContext context, Object item)
HandleSerializationEventArgs
class using the provided context to write the item
using the given type for serialization.context
- The context to use for writing.item
- The item to to serialize.public HandleSerializationEventArgs(IWriteContext context, Object item, Type serializationType)
HandleSerializationEventArgs
class using the provided context to write the item
using the given type for serialization.context
- The context to use for writing.item
- The item to to serialize.serializationType
- The type that should be used for serialization, which needs to be a super type or interface of the item
or
null
.public final IWriteContext getContext()
public final Object getItem()
public final Type getSourceType()
Item
that should be used for serialization.null
if the type should be inferred from the Item
.public final IXmlWriter getWriter()
public final boolean isHandled()
HandleSerializationEventArgs
is handled.
Setting this property to true
indicates to the event source that the Item
has been
successfully serialized using the Writer
and no other code needs to handle the serialization
request, anymore.
true
if this event has been handled; false
otherwise.setHandled(boolean)
public final void replaceItem(Object item, Class serializationType)
Item
using a substitute for serialization.
This method can be used to replace the Item
and SourceType
property so that
the serialization chain can be traversed with a substituted item. If this method has been called the Handled
property should not be set to true
.
item
- The substitute to assign to the Item
property.serializationType
- The serialization type to assign to the SourceType
property.public final void setHandled(boolean value)
HandleSerializationEventArgs
is handled.
Setting this property to true
indicates to the event source that the Item
has been
successfully serialized using the Writer
and no other code needs to handle the serialization
request, anymore.
value
- true
if this event has been handled; false
otherwise.isHandled()