Class AbstractStringInstanceIdentifierCodec

java.lang.Object
org.opendaylight.yangtools.yang.data.api.codec.AbstractIllegalArgumentCodec<String,T>
org.opendaylight.yangtools.yang.data.util.AbstractStringInstanceIdentifierCodec
All Implemented Interfaces:
IllegalArgumentCodec<String,YangInstanceIdentifier>, InstanceIdentifierCodec<String>

public abstract class AbstractStringInstanceIdentifierCodec extends AbstractIllegalArgumentCodec<String,T> implements InstanceIdentifierCodec<String>
Abstract utility class for representations which encode YangInstanceIdentifier as a prefix:name tuple. Typical uses are RESTCONF/JSON (module:name) and XML (prefix:name).
  • Constructor Details

    • AbstractStringInstanceIdentifierCodec

      public AbstractStringInstanceIdentifierCodec()
  • Method Details

    • serializeImpl

      protected final String serializeImpl(YangInstanceIdentifier data)
      Specified by:
      serializeImpl in class AbstractIllegalArgumentCodec<String,YangInstanceIdentifier>
    • getDataContextTree

      protected abstract @NonNull DataSchemaContextTree getDataContextTree()
      Returns DataSchemaContextTree associated with SchemaContext for which serialization / deserialization occurs.

      Implementations MUST provide non-null Data Tree context, in order for correct serialization / deserialization of PathArguments, since XML representation does not have Augmentation arguments and does not provide path arguments for cases.

      This effectively means same input XPath representation of Path Argument may result in different YangInstanceIdentifiers if models are different in uses of choices and cases.

      Returns:
      DataSchemaContextTree associated with SchemaContext for which serialization / deserialization occurs.
    • deserializeKeyValue

      protected abstract @NonNull Object deserializeKeyValue(@NonNull DataSchemaNode schemaNode, @NonNull LeafrefResolver resolver, String value)
    • deserializeImpl

      protected final YangInstanceIdentifier deserializeImpl(String data)
      Specified by:
      deserializeImpl in class AbstractIllegalArgumentCodec<String,YangInstanceIdentifier>
    • createQName

      protected @NonNull QName createQName(@Nullable QNameModule lastModule, String localName)
      Create QName from unprefixed name, potentially taking last QNameModule encountered into account.
      Parameters:
      lastModule - last QNameModule encountered, potentially null
      localName - Local name string
      Returns:
      A newly-created QName
    • createQName

      protected final QName createQName(String prefix, String localName)
      Create a QName for a prefix and local name.
      Parameters:
      prefix - Prefix for namespace
      localName - local name
      Returns:
      QName
    • moduleForPrefix

      protected abstract @Nullable QNameModule moduleForPrefix(@NonNull String prefix)
      Resolve a string prefix into the corresponding module.
      Parameters:
      prefix - Prefix
      Returns:
      module mapped to prefix, or null if the module cannot be resolved
    • prefixForNamespace

      protected abstract @Nullable String prefixForNamespace(@NonNull XMLNamespace namespace)
      Return string prefix for a particular namespace, allocating a new one if necessary.
      Parameters:
      namespace - Namespace to map
      Returns:
      Allocated unique prefix, or null if the prefix cannot be mapped.
    • appendQName

      protected final @NonNull StringBuilder appendQName(StringBuilder sb, QName qname)
    • appendQName

      protected StringBuilder appendQName(StringBuilder sb, QName qname, @Nullable QNameModule lastModule)
      Append a QName, potentially taking into account last QNameModule encountered in the serialized path.
      Parameters:
      sb - target StringBuilder
      qname - QName to append
      lastModule - last QNameModule encountered, may be null
      Returns:
      target StringBuilder
    • parseQName

      protected final QName parseQName(String str)