org.idoox.wasp.serialization
Interface ReferenceSerializationContext

All Known Subinterfaces:
SerializationContext

public interface ReferenceSerializationContext

A context for serialization of multi-references for SOAP encoded style.

Since:
4.0
Component:
Core

Nested Class Summary
static interface ReferenceSerializationContext.AttachmentWithType
           
 
Method Summary
 void clearMultirefs()
          Clears table of multirefs.
 java.util.Iterator getAttachments()
          Returns an iterator of all attachments.
 java.util.List getAttachmentsWithType()
          List of registered attachments.
 java.lang.String getMultirefId(java.lang.Object reference)
          Returns id of a multiref.
 java.lang.String getMultirefRef(java.lang.Object reference)
          Returns the value of the href parameter.
 Type getMultirefType(java.lang.Object reference)
          Returns schema type for a given reference.
 java.util.Map getReferences()
          Returns map of reference => id.
 boolean isMultirefsInline()
          Returns true if multirefs should be serialized inline (at the first ocurrence), false if multirefs are serialized externally.
 boolean isReferenceSerialized(java.lang.Object reference)
          Returns whether a reference is already serialized so it referenced only.
 boolean isSerializingMultirefs()
          Returns true if mutirefs are serialized as data, false if they are serialized as references.
 void registerAttachment(MessageAttachment attachment)
          Adds an attachment, leading to placing it at the end of the message.
 void registerAttachment(MessageAttachment attachment, AttachmentType attType)
          Adds an attachment to the end of attachment list.
 java.lang.String registerReference(java.lang.Object reference, Type type)
          Registers a reference to an object.
 java.lang.String registerReference(java.lang.Object reference, Type type, java.lang.String id, java.lang.String ref)
          Registers a reference to an object.
 void setMultirefsInline(boolean flag)
          Sets whether multirefs should be serialized inline (at the first ocurrence), false if multirefs are serialized externally.
 void setReferenceSerialized(java.lang.Object reference)
          Sets the flag that a given reference is being serialized.
 void setSerializingMultirefs(boolean doSerializeMultirefs)
          If set up, multirefs will be serialized as a normal data, otherwise will be serialized as references.
 

Method Detail

registerReference

public java.lang.String registerReference(java.lang.Object reference,
                                          Type type)
                                   throws MessageCreatingException
Registers a reference to an object. Returns an id of the reference.

Parameters:
reference - the reference to be registered
type - the type of the reference
Returns:
the number of references to the object
Throws:
MessageCreatingException - if some serialization exception occurs

registerReference

public java.lang.String registerReference(java.lang.Object reference,
                                          Type type,
                                          java.lang.String id,
                                          java.lang.String ref)
                                   throws MessageCreatingException
Registers a reference to an object. Returns an id of the reference.

Mostly used with references to other mime parts of the message

Parameters:
reference - the reference to be registered
type - the type of the reference
id - the id of the reference
ref - the value of the 'ref' attribute of the reference
Returns:
the id of the reference
Throws:
MessageCreatingException - if some serialization exception occurs

getReferences

public java.util.Map getReferences()
                            throws MessageCreatingException
Returns map of reference => id.

If the returned id is >= 0, the reference is a multiref.

Returns:
the map of references
Throws:
MessageCreatingException - if some serialization exception occurs

getMultirefId

public java.lang.String getMultirefId(java.lang.Object reference)
Returns id of a multiref.

If an object is not a multiref, null is returned

Parameters:
reference - the reference for which id is to be returned
Returns:
id of the reference or null if the reference does not have an id

getMultirefRef

public java.lang.String getMultirefRef(java.lang.Object reference)
Returns the value of the href parameter.

If the object is not a multiref, null is returned.

Parameters:
reference - the reference for which id is to be returned
Returns:
id of the reference or null if the reference does not have an id

getMultirefType

public Type getMultirefType(java.lang.Object reference)
Returns schema type for a given reference.

Returns:
schema the type for the given reference

setSerializingMultirefs

public void setSerializingMultirefs(boolean doSerializeMultirefs)
If set up, multirefs will be serialized as a normal data, otherwise will be serialized as references.

Parameters:
doSerializeMultirefs - if true, multirefs are to be serialized just as normal data, if false, they are to be serialized as references

isSerializingMultirefs

public boolean isSerializingMultirefs()
Returns true if mutirefs are serialized as data, false if they are serialized as references.

Returns:
if true, serializing multirefs as normal data, if false, serializing them as references

clearMultirefs

public void clearMultirefs()
Clears table of multirefs.


registerAttachment

public void registerAttachment(MessageAttachment attachment)
Adds an attachment, leading to placing it at the end of the message.

Parameters:
attachment - the attachment being registered
See Also:
getAttachments()

getAttachments

public java.util.Iterator getAttachments()
Returns an iterator of all attachments. The order of attachments is the order of their registration.

Returns:
the iterator of all registered attachments
See Also:
registerAttachment(org.idoox.wasp.types.MessageAttachment)

registerAttachment

public void registerAttachment(MessageAttachment attachment,
                               AttachmentType attType)
Adds an attachment to the end of attachment list. Enhances registerAttachment(org.idoox.wasp.types.MessageAttachment).

Parameters:
attachment - an attachment to register
attType - type of the attachment; can be null

getAttachmentsWithType

public java.util.List getAttachmentsWithType()
List of registered attachments.

Returns:
unmodifable list of registered attachments; list contains ReferenceSerializationContext.AttachmentWithType

isMultirefsInline

public boolean isMultirefsInline()
Returns true if multirefs should be serialized inline (at the first ocurrence), false if multirefs are serialized externally.

Returns:
whether multirefs are serialized inline

setMultirefsInline

public void setMultirefsInline(boolean flag)
Sets whether multirefs should be serialized inline (at the first ocurrence), false if multirefs are serialized externally.

Parameters:
flag - true if multirefs should be serialized inline

setReferenceSerialized

public void setReferenceSerialized(java.lang.Object reference)
Sets the flag that a given reference is being serialized.

Parameters:
reference - the object that is to be serialized
See Also:
isReferenceSerialized(java.lang.Object)

isReferenceSerialized

public boolean isReferenceSerialized(java.lang.Object reference)
Returns whether a reference is already serialized so it referenced only.

Parameters:
reference - the referenced object
Returns:
true if the reference value was already serialized; false if the reference was not serialized yet