public class DefaultYangCodecHandler extends Object implements YangCodecHandler
| Constructor and Description |
|---|
DefaultYangCodecHandler(YangSchemaRegistry registry)
Creates a new YANG codec handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeviceSchema(Class<?> yangModule)
Provider / driver needs to register the device schema with code handler.
|
List<Object> |
decode(String inputString,
YangProtocolEncodingFormat dataFormat,
YmsOperationType opType)
When the driver or provider receive the data from the SBI protocol, It
will be in the protocol specific data representation.
|
Object |
decode(YangCompositeEncoding protoData,
YangProtocolEncodingFormat dataFormat,
YmsOperationType opType)
When the driver or provider receive the composite data from the SBI
protocol, It will be in the protocol specific data representation.
|
YangCompositeEncoding |
encodeCompositeOperation(String rootName,
String rootNamespace,
Object moduleObject,
YangProtocolEncodingFormat dataFormat,
YmsOperationType opType)
When the drivers / providers need to encode protocol composite
operation requests, which is split in a composite blocks, this encode
composite operation API is used.
|
String |
encodeOperation(String rootName,
String rootNamespace,
Map<String,String> tagAttrMap,
List<Object> moduleList,
YangProtocolEncodingFormat dataFormat,
YmsOperationType opType)
When the drivers / providers need to encode a protocol operation
requests, which is in a single block, this encode API is used.
|
YangModuleLibrary |
getLibrary()
Returns module library for YSR.
|
void |
registerOverriddenCodec(YangDataTreeCodec overrideCodec,
YangProtocolEncodingFormat dataFormat)
Register the provider / driver specific overridden codec.
|
void |
setLibrary(YangModuleLibrary library)
Sets module library for YSR.
|
public DefaultYangCodecHandler(YangSchemaRegistry registry)
registry - YANG schema registrypublic void addDeviceSchema(Class<?> yangModule)
YangCodecHandleraddDeviceSchema in interface YangCodecHandleryangModule - YANG utils generated class corresponding to SBI
device schema modulepublic String encodeOperation(String rootName, String rootNamespace, Map<String,String> tagAttrMap, List<Object> moduleList, YangProtocolEncodingFormat dataFormat, YmsOperationType opType)
YangCodecHandlerThe protocols can have a logical root node which acts as a container of applications module node. For example in NETCONF, it could be data/filter/config, etc. Protocols needs to pass this parameter in the encode request, so that it is part of the encoded protocol packet. There is no validation done on the value of this parameter. It is up to the protocol to use it. It is a mandatory parameter and protocols must pass this parameter. In protocols like NETCONF, these logical root node may be in a specific name space, in such cases, it needs to be passed to encode it as part of the request. There could be additional tags that can be attached to the root node, for example in NETCONF, the tag type="subtree" can be specified. In such scenarios the required tags should be sent as a parameter.
The provider / driver would require to operate on multiple schema nodes in a single request, for example it may be require to configure a tunnel and associate a QOS to this tunnel, in this scenario, it needs to have the tunnel related information in the tunnel module's Java object and and QOS related information in QOS modules Java object. So in a single request, it can send the list of Java objects corresponding to the modules which need to participate in the operation. If the request to be generated needs to be a wild card for no application(s), then this parameter needs to be null. For example a "empty filter" request in NETCONF get request.
If the request to be generated needs to be a wild card for all application(s), then the driver / provider should not invoke this API, as there is no encoding of application related information for the operation, it is only limited to the protocol operation. For example a "no filter" request in NETCONF get request.
encodeOperation in interface YangCodecHandlerrootName - name of logical root node as required by
the protocolrootNamespace - namespace of logical root node as
required by the protocol encoding. It is
an optional parameter.tagAttrMap - Specifies the list of attributes that
needs to be tagged with the logical root
node. It is an optional parameter
if not required for the protocol.moduleList - list of YANG module's object(s)
participating in the operation.dataFormat - data format to which encoding to be done.opType - protocol operation being performedpublic YangCompositeEncoding encodeCompositeOperation(String rootName, String rootNamespace, Object moduleObject, YangProtocolEncodingFormat dataFormat, YmsOperationType opType)
YangCodecHandlerThe protocols can have a logical root node which acts as a container of applications module node. For example in RESTCONF, it could be RootResource/data, etc. There is no validation done on the value of this parameter. It is upto the protocol to use it. It is a mandatory parameter and protocols must pass this parameter.
The resource to be operated upon in the device is identified in a module's schema object. This modules object should contain the information about the resource on which the operation needs to be performed. The resource is identified by initial chain of objects for which operation type is none. Once the resource is reached using none operations, the actual information about the operation on the device is encoded.
encodeCompositeOperation in interface YangCodecHandlerrootName - name of logical root node as required by the
protocolrootNamespace - namespace of logical root node as required by
the
protocol encoding. It is optional, and there
is no
namespace set to the logical root nodemoduleObject - object containing the information about the
resource on which the operation is being
performeddataFormat - data format to which request needs to
be encodedopType - protocol operation being performedpublic List<Object> decode(String inputString, YangProtocolEncodingFormat dataFormat, YmsOperationType opType)
YangCodecHandlerdecode in interface YangCodecHandlerinputString - input string containing the resource information
in protocol formatdataFormat - data format from which decoding has to be doneopType - protocol operation being performedpublic Object decode(YangCompositeEncoding protoData, YangProtocolEncodingFormat dataFormat, YmsOperationType opType)
YangCodecHandlerIf the response received is not in line with the schema, for example, there is some error info, etc, then the decode operation will throw an exception and decode operation will fail.
decode in interface YangCodecHandlerprotoData - composite protocol data containing the resource
informationdataFormat - data format from which decoding has to be doneopType - protocol operation being performedpublic void registerOverriddenCodec(YangDataTreeCodec overrideCodec, YangProtocolEncodingFormat dataFormat)
YangCodecHandlerregisterOverriddenCodec in interface YangCodecHandleroverrideCodec - provider / driver specific overridden instance
of the codecdataFormat - data format to which encoding to be done.public YangModuleLibrary getLibrary()
public void setLibrary(YangModuleLibrary library)
library - module library for YSR