org.idoox.wasp.serialization
Interface SchemaContext

All Known Subinterfaces:
DeserializationContext, SerializationContext

public interface SchemaContext

Drives a schema context for serialization and deserialization.

Since:
4.0
Component:
Core

Nested Class Summary
static interface SchemaContext.State
          This interface is used by serialization context to store information about the current position on the serialization stack.
 
Method Summary
 SchemaContext.State enterCurrentMember()
          Enters the current serialization member (if it is structure or array).
 QName getCurrentConstructName()
          Returns the name of the current member.
 Type getCurrentConstructSchemaType()
          Returns the type of the current member.
 SchemaConstruct.ConstructType getCurrentConstructType()
          Returns the type of the current construct.
 Member getCurrentMember()
          Deprecated. Use one of getCurrentSchemaConstruct(), getCurrentConstructName(), getCurrentConstructType().
 SchemaConstruct getCurrentSchemaConstruct()
          Returns the current member.
 Type getOriginalType()
          Returns the original type found in WSDL/XMLSchema.
 Schema getSchema()
          Returns the schema set up in this context.
 boolean isCurrentConstructArray()
          Returns true if the current construct is an array.
 void leave(SchemaContext.State state)
          Leaves the current serialization member (a structure or an array).
 Member nextMember()
          Deprecated. Use nextSchemaConstruct() instead.
 SchemaConstruct nextSchemaConstruct()
          Moves to the next member.
 SchemaConstruct nextSchemaConstruct(java.lang.String namespaceURI, java.lang.String localPart)
          Moves to the next named member.
 SchemaContext.State putMember(Member member)
          Deprecated. use putSchemaConstruct instead
 SchemaContext.State putSchemaConstruct(SchemaConstruct schemaConstruct)
          Sets the schema construct (element, type, attribute) being serialized.
 void replaceTopMember(QName name, Type type)
          Manually replaces top member.
 Type replaceTopMemberType(Type newType)
          Replaces the type of the top-level member, returning the old type.
 boolean typeOfCurrentConstructReplaced()
          Returns true if current type was replaced.
 

Method Detail

getSchema

public Schema getSchema()
Returns the schema set up in this context.

Returns:
the schema set up in this context

putMember

public SchemaContext.State putMember(Member member)
Deprecated. use putSchemaConstruct instead

Sets the member being serialized to the given member.

This call might be used anytime, previous members are preserved. This call must be ended by call to a leave() function.

Parameters:
member - the member that will be serialized using this context
Returns:
the stored previous state of the context

putSchemaConstruct

public SchemaContext.State putSchemaConstruct(SchemaConstruct schemaConstruct)
Sets the schema construct (element, type, attribute) being serialized.

This call might be used anytime, previous constructs are preserved. This call must be ended by call to a leave() function.

Parameters:
schemaConstruct - the schemaConstruct that will be serialized using this context
Returns:
the stored previous state of the context

enterCurrentMember

public SchemaContext.State enterCurrentMember()
Enters the current serialization member (if it is structure or array).

The first member of the structure (the only of the array) will be given as a result of 'nextMember' call. Returns an object that should be passed back into the leave method. After the call to this method, the context is before the first child of the member. So, if this method is used from serializer, this call is typically followed by nextSchemaConstruct. If used from deserialization, the call is followed by a call to SerializationHelper or nextSchemaConstruct(namespaceURI, localPart).

Returns:
the previous state of the context

leave

public void leave(SchemaContext.State state)
Leaves the current serialization member (a structure or an array).

Parameters:
state - the state which should be set up, obtained by a call to the corresponding enterCurrentMember() operation.

getCurrentMember

public Member getCurrentMember()
Deprecated. Use one of getCurrentSchemaConstruct(), getCurrentConstructName(), getCurrentConstructType().

Returns the current member.

In case of no current member (for example, just after call to enterCurrentMember) the call returns null.

Returns:
the current member

getCurrentSchemaConstruct

public SchemaConstruct getCurrentSchemaConstruct()
Returns the current member.

In case of no current member (for example, just after call to enterCurrentMember) the call returns null.

Note: use getCurrentConstructName(), getCurrentConstructType for faster accessing type or name.

Returns:
the current member

getCurrentConstructSchemaType

public Type getCurrentConstructSchemaType()
Returns the type of the current member.

Returns:
type of the current member

getCurrentConstructName

public QName getCurrentConstructName()
Returns the name of the current member.

Returns:
the name of the current member

getCurrentConstructType

public SchemaConstruct.ConstructType getCurrentConstructType()
Returns the type of the current construct.

See SchemaConstruct.ConstructType for symbolic constants.

Returns:
the type of the current construct.

isCurrentConstructArray

public boolean isCurrentConstructArray()
Returns true if the current construct is an array.

Returns:
true if the current construct is an array

nextMember

public Member nextMember()
Deprecated. Use nextSchemaConstruct() instead.

Moves to the next member.

If the member has been the last one, leaves the containing structure.

Returns:
the next member

nextSchemaConstruct

public SchemaConstruct nextSchemaConstruct()
Moves to the next member.

If the member has been the last one, leaves the containing structure.

Returns:
the next member

nextSchemaConstruct

public SchemaConstruct nextSchemaConstruct(java.lang.String namespaceURI,
                                           java.lang.String localPart)
Moves to the next named member.

If there is no such member, returns null and leaves the containing structure.

Parameters:
namespaceURI - the namespaceURI of the element to be moved to.
localPart - the localPart of the element to be moved to.
Returns:
the next member

replaceTopMember

public void replaceTopMember(QName name,
                             Type type)
Manually replaces top member.

Parameters:
name - the name of the context
type - the type of the context

replaceTopMemberType

public Type replaceTopMemberType(Type newType)
Replaces the type of the top-level member, returning the old type.

Parameters:
newType - the new type to be returned.
Returns:
the previous type

typeOfCurrentConstructReplaced

public boolean typeOfCurrentConstructReplaced()
Returns true if current type was replaced. This information is valid only before we move to another location within schema (enter, put or next)

Returns:
true if current type was replaced

getOriginalType

public Type getOriginalType()
Returns the original type found in WSDL/XMLSchema.

Due to, for example, polymorphism, the original type might differ to the type found in topMember. To output the type only when required, just compare (using ==) getOriginalType() with getCurrentConstructSchemaType()

Returns:
the original type found in WSDL/XMLSchema.