Class AbstractStringInstanceIdentifierCodec
- java.lang.Object
-
- org.opendaylight.yangtools.concepts.AbstractCodec<P,I,X>
-
- org.opendaylight.yangtools.concepts.AbstractUncheckedCodec<P,I,IllegalArgumentException>
-
- org.opendaylight.yangtools.concepts.AbstractIllegalArgumentCodec<String,T>
-
- org.opendaylight.yangtools.yang.data.util.AbstractStringInstanceIdentifierCodec
-
- All Implemented Interfaces:
Codec<String,YangInstanceIdentifier,IllegalArgumentException>
,Deserializer<YangInstanceIdentifier,String,IllegalArgumentException>
,IllegalArgumentCodec<String,YangInstanceIdentifier>
,Serializer<String,YangInstanceIdentifier,IllegalArgumentException>
,UncheckedCodec<String,YangInstanceIdentifier,IllegalArgumentException>
,UncheckedDeserializer<String,YangInstanceIdentifier,IllegalArgumentException>
,UncheckedSerializer<YangInstanceIdentifier,String,IllegalArgumentException>
,InstanceIdentifierCodec<String>
- Direct Known Subclasses:
AbstractModuleStringInstanceIdentifierCodec
@Beta public abstract class AbstractStringInstanceIdentifierCodec extends AbstractIllegalArgumentCodec<String,T> implements InstanceIdentifierCodec<String>
Abstract utility class for representations which encodeYangInstanceIdentifier
as a prefix:name tuple. Typical uses are RESTCONF/JSON (module:name) and XML (prefix:name).
-
-
Constructor Summary
Constructors Constructor Description AbstractStringInstanceIdentifierCodec()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected @NonNull StringBuilder
appendQName(StringBuilder sb, QName qname)
protected StringBuilder
appendQName(StringBuilder sb, QName qname, @Nullable QNameModule lastModule)
Append a QName, potentially taking into account last QNameModule encountered in the serialized path.protected abstract @Nullable QName
createQName(@NonNull String prefix, @NonNull String localName)
Create a QName for a prefix and local name.protected QName
createQName(@Nullable QNameModule lastModule, String localName)
Create QName from unprefixed name, potentially taking last QNameModule encountered into account.protected YangInstanceIdentifier
deserializeImpl(String data)
protected Object
deserializeKeyValue(DataSchemaNode schemaNode, String value)
protected abstract @NonNull DataSchemaContextTree
getDataContextTree()
Returns DataSchemaContextTree associated with SchemaContext for which serialization / deserialization occurs.protected QName
parseQName(String str)
protected abstract @Nullable String
prefixForNamespace(@NonNull URI namespace)
Return string prefix for a particular namespace, allocating a new one if necessary.protected String
serializeImpl(YangInstanceIdentifier data)
-
Methods inherited from class org.opendaylight.yangtools.concepts.AbstractCodec
deserialize, serialize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opendaylight.yangtools.concepts.Codec
deserialize, serialize
-
Methods inherited from interface org.opendaylight.yangtools.concepts.UncheckedDeserializer
serialize
-
Methods inherited from interface org.opendaylight.yangtools.concepts.UncheckedSerializer
deserialize
-
-
-
-
Method Detail
-
serializeImpl
protected final String serializeImpl(YangInstanceIdentifier data)
- Specified by:
serializeImpl
in classAbstractUncheckedCodec<String,YangInstanceIdentifier,IllegalArgumentException>
-
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 Object deserializeKeyValue(DataSchemaNode schemaNode, String value)
-
deserializeImpl
protected final YangInstanceIdentifier deserializeImpl(String data)
- Specified by:
deserializeImpl
in classAbstractUncheckedCodec<String,YangInstanceIdentifier,IllegalArgumentException>
-
createQName
protected 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 nulllocalName
- Local name string- Returns:
- A newly-created QName
-
prefixForNamespace
protected abstract @Nullable String prefixForNamespace(@NonNull URI 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.
-
createQName
protected abstract @Nullable QName createQName(@NonNull String prefix, @NonNull String localName)
Create a QName for a prefix and local name.- Parameters:
prefix
- Prefix for namespacelocalName
- local name- Returns:
- QName
- Throws:
IllegalArgumentException
- if the prefix cannot be resolved
-
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 StringBuilderqname
- QName to appendlastModule
- last QNameModule encountered, may be null- Returns:
- target StringBuilder
-
-