Class ConnectorOutputTypeAdapter<T>
- java.lang.Object
-
- de.iip_ecosphere.platform.connectors.types.ConnectorOutputTypeAdapter<T>
-
- Type Parameters:
T- the target type (seeOutputTypeTranslator)
- All Implemented Interfaces:
ModelAccessProvider,ConnectorOutputTypeTranslator<byte[],T>,de.iip_ecosphere.platform.transport.serialization.OutputTypeTranslator<byte[],T>
- Direct Known Subclasses:
ChanneledConnectorOutputTypeAdapter
public class ConnectorOutputTypeAdapter<T> extends java.lang.Object implements ConnectorOutputTypeTranslator<byte[],T>
Adapts a basic output translator/serializer for reuse.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.connectors.model.ModelAccessProvider
ModelAccessProvider.IOModelAccessFunction, ModelAccessProvider.IOVoidFunction
-
-
Field Summary
Fields Modifier and Type Field Description private ModelAccessmodelAccessprivate de.iip_ecosphere.platform.transport.serialization.Serializer<T>serializer
-
Constructor Summary
Constructors Constructor Description ConnectorOutputTypeAdapter(de.iip_ecosphere.platform.transport.serialization.Serializer<T> serializer)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelAccessgetModelAccess()Returns the model access instance to be used during type translations.java.lang.Class<? extends byte[]>getSourceType()Returns the source type.java.lang.Class<? extends T>getTargetType()Returns the target type.voidinitializeModelAccess()Called to initialize the model access, e.g., to setup notifications.voidsetModelAccess(ModelAccess modelAccess)Defines the model access.Tto(byte[] source)
-
-
-
Field Detail
-
serializer
private de.iip_ecosphere.platform.transport.serialization.Serializer<T> serializer
-
modelAccess
private ModelAccess modelAccess
-
-
Constructor Detail
-
ConnectorOutputTypeAdapter
public ConnectorOutputTypeAdapter(de.iip_ecosphere.platform.transport.serialization.Serializer<T> serializer)
Creates an instance.- Parameters:
serializer- the serializer to adapt
-
-
Method Detail
-
to
public T to(byte[] source) throws java.io.IOException
- Specified by:
toin interfacede.iip_ecosphere.platform.transport.serialization.OutputTypeTranslator<byte[],T>- Throws:
java.io.IOException
-
getModelAccess
public ModelAccess getModelAccess()
Description copied from interface:ModelAccessProviderReturns the model access instance to be used during type translations.- Specified by:
getModelAccessin interfaceModelAccessProvider- Returns:
- the model access instance, may be null (see
MachineConnector.hasModel())
-
setModelAccess
public void setModelAccess(ModelAccess modelAccess)
Description copied from interface:ModelAccessProviderDefines the model access. Handle with care, shall be called (indirectly) by the connector only.- Specified by:
setModelAccessin interfaceModelAccessProvider- Parameters:
modelAccess- the model access
-
initializeModelAccess
public void initializeModelAccess() throws java.io.IOExceptionDescription copied from interface:ConnectorOutputTypeTranslatorCalled to initialize the model access, e.g., to setup notifications. Called only, when the connector is connected.- Specified by:
initializeModelAccessin interfaceConnectorOutputTypeTranslator<byte[],T>- Throws:
java.io.IOException- in case the initialization fails, e.g., monitors cannot be set up
-
getSourceType
public java.lang.Class<? extends byte[]> getSourceType()
Description copied from interface:ConnectorOutputTypeTranslatorReturns the source type.- Specified by:
getSourceTypein interfaceConnectorOutputTypeTranslator<byte[],T>- Returns:
- the source type
-
getTargetType
public java.lang.Class<? extends T> getTargetType()
Description copied from interface:ConnectorOutputTypeTranslatorReturns the target type.- Specified by:
getTargetTypein interfaceConnectorOutputTypeTranslator<byte[],T>- Returns:
- the target type
-
-