|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IMappingProvider
A mapping provider implements means of mapping IStatefulObject
data to and from a string
representation. It provides "serialisation" functionality for CPC data objects.
The format of the string representation is not specified and is entirely up to the implementation.
However, each mapping provider should add some kind of special "magic" to the header which allows
itself to quickly decide whether a given string is likely to be in a mapping format which it supports.
NOTE: When mapping an external string representation to CPC objects it is recommended to use the
IMappingRegistry
instead of directly accessing the default IMappingProvider
. This
ensures that "legacy" mappings can still be read, even if the default mapping provider is changed.
IMappingRegistry
,
MappingStore
Method Summary | |
---|---|
java.lang.String |
extractCloneObjectUuidFromString(java.lang.String data)
Takes a string representation which matches the ones generated by mapToString(MappingStore, boolean)
and extracts the ICloneObject.getUuid() of the main object, if it exists and is of type ICloneObject . |
boolean |
isSupportedMappingFormat(java.lang.String data)
Does a quick check to see whether the given cpc data mapping is in a format which this mapping provider can understand. |
MappingStore |
mapFromString(java.lang.String data)
Takes a string representation which matches the ones generated by mapToString(MappingStore, boolean)
and builds a MappingStore containing the IStatefulObject which the given mapping represents. |
java.lang.String |
mapToString(MappingStore mappingStore,
boolean addHeaders)
Takes a list of IStatefulObject s and maps them into a string representation. |
Methods inherited from interface org.electrocodeogram.cpc.core.api.provider.IProvider |
---|
getProviderName, toString |
Method Detail |
---|
boolean isSupportedMappingFormat(java.lang.String data)
It is up to the implementation how to handle this method call.
However, this is a potentially very frequently called method and any implementation
should try to optimise the performance of this method as far as possible.
data
- the cpc data mapping to check, never null.
IMappingProvider
is compatible with the given mapping format,
false otherwise. A return value of true does not automatically indicate that the
given mapping data is well formed and valid.java.lang.String mapToString(MappingStore mappingStore, boolean addHeaders) throws MappingException
IStatefulObject
s and maps them into a string representation.
MappingStore
and the contained IStatefulObject
s may not be
modified in any way by this method.
mappingStore
- a MappingStore
which represents the IStatefulObject
s which
should be mapped to a string representation, never null.addHeaders
- whether a full set of headers should be added (true) or not (false).
Some string representations may have special nesting semantics. This parameter can be used
to indicate whether the result is intended to be nested within another string representation
of the same type or whether it is meant to be used standalone.
MappingException
- if the data can not be mappedMappingStore mapFromString(java.lang.String data) throws MappingException
mapToString(MappingStore, boolean)
and builds a MappingStore
containing the IStatefulObject
which the given mapping represents.
data
- a valid string representation which encodes IStatefulObject
data, never null.
MappingStore
with IStatefulObject
s corresponding to the given mapping data, never null.
MappingException
- if the given string representation is not validjava.lang.String extractCloneObjectUuidFromString(java.lang.String data) throws MappingException
mapToString(MappingStore, boolean)
and extracts the ICloneObject.getUuid()
of the main object, if it exists and is of type ICloneObject
.
ICloneFile
file UUID.
Convenience method which is provided for performance reasons in situations where only the UUID of the main entry
is of interest and where parsing of the entire file is therefore not needed.
It is up to the implementation to decide whether to implement this method separately or whether calls to this method
should simply be mapped to mapFromString(String)
.
This API makes no guarantee that using this method does provide any performance gain. Use of this method should be
considered as an optimisation hint for the implementation.
An implementation is not required to do a full validity check of the given data structure. Thus there may be corrupted
data structures for which a call to this method succeeds but a call to mapFromString(String)
fails.
data
- a valid string representation which encodes IStatefulObject
data, never null.
ICloneObject.getUuid()
of the main object of this mapping structure or NULL if the given mapping structure
contains multiple elements and no element was designated as parent element or if the main element is not of type
ICloneObject
.
MappingException
- if the given mapping structure is not valid
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |