import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
-import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
* nodes. This process goes in recursive manner, where each NodeTypes object signifies the start of the object, except
* END_NODE. If a node can have children, then that node's end is calculated based on appearance of END_NODE.
*/
-abstract class AbstractLithiumDataInput extends ForwardingDataInput implements NormalizedNodeDataInput {
+abstract class AbstractLithiumDataInput extends AbstractNormalizedNodeDataInput {
private static final Logger LOG = LoggerFactory.getLogger(AbstractLithiumDataInput.class);
- private final @NonNull DataInput input;
-
private final List<String> codedStringMap = new ArrayList<>();
private QName lastLeafSetQName;
AbstractLithiumDataInput(final DataInput input) {
- this.input = requireNonNull(input);
- }
-
- @Override
- final DataInput delegate() {
- return input;
+ super(input);
}
@Override
private void streamNormalizedNode(final NormalizedNodeStreamWriter writer, final byte nodeType) throws IOException {
switch (nodeType) {
- case NodeTypes.ANY_XML_NODE:
+ case LithiumNode.ANY_XML_NODE:
streamAnyxml(writer);
break;
- case NodeTypes.AUGMENTATION_NODE:
+ case LithiumNode.AUGMENTATION_NODE:
streamAugmentation(writer);
break;
- case NodeTypes.CHOICE_NODE:
+ case LithiumNode.CHOICE_NODE:
streamChoice(writer);
break;
- case NodeTypes.CONTAINER_NODE:
+ case LithiumNode.CONTAINER_NODE:
streamContainer(writer);
break;
- case NodeTypes.LEAF_NODE:
+ case LithiumNode.LEAF_NODE:
streamLeaf(writer);
break;
- case NodeTypes.LEAF_SET:
+ case LithiumNode.LEAF_SET:
streamLeafSet(writer);
break;
- case NodeTypes.ORDERED_LEAF_SET:
+ case LithiumNode.ORDERED_LEAF_SET:
streamOrderedLeafSet(writer);
break;
- case NodeTypes.LEAF_SET_ENTRY_NODE:
+ case LithiumNode.LEAF_SET_ENTRY_NODE:
streamLeafSetEntry(writer);
break;
- case NodeTypes.MAP_ENTRY_NODE:
+ case LithiumNode.MAP_ENTRY_NODE:
streamMapEntry(writer);
break;
- case NodeTypes.MAP_NODE:
+ case LithiumNode.MAP_NODE:
streamMap(writer);
break;
- case NodeTypes.ORDERED_MAP_NODE:
+ case LithiumNode.ORDERED_MAP_NODE:
streamOrderedMap(writer);
break;
- case NodeTypes.UNKEYED_LIST:
+ case LithiumNode.UNKEYED_LIST:
streamUnkeyedList(writer);
break;
- case NodeTypes.UNKEYED_LIST_ITEM:
+ case LithiumNode.UNKEYED_LIST_ITEM:
streamUnkeyedListItem(writer);
break;
default:
writer.startMapEntryNode(entryIdentifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
// Same loop as commonStreamContainer(), but ...
- for (byte nodeType = input.readByte(); nodeType != NodeTypes.END_NODE; nodeType = input.readByte()) {
- if (nodeType == NodeTypes.LEAF_NODE) {
+ for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
+ if (nodeType == LithiumNode.LEAF_NODE) {
// ... leaf nodes may need de-duplication
streamLeaf(writer, entryIdentifier);
} else {
}
private void commonStreamContainer(final NormalizedNodeStreamWriter writer) throws IOException {
- for (byte nodeType = input.readByte(); nodeType != NodeTypes.END_NODE; nodeType = input.readByte()) {
+ for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
streamNormalizedNode(writer, nodeType);
}
writer.endNode();
final String readCodedString() throws IOException {
final byte valueType = input.readByte();
switch (valueType) {
- case TokenTypes.IS_NULL_VALUE:
+ case LithiumTokens.IS_NULL_VALUE:
return null;
- case TokenTypes.IS_CODE_VALUE:
+ case LithiumTokens.IS_CODE_VALUE:
final int code = input.readInt();
try {
return codedStringMap.get(code);
} catch (IndexOutOfBoundsException e) {
throw new IOException("String code " + code + " was not found", e);
}
- case TokenTypes.IS_STRING_VALUE:
+ case LithiumTokens.IS_STRING_VALUE:
final String value = input.readUTF().intern();
codedStringMap.add(value);
return value;
return new String(bytes, StandardCharsets.UTF_8);
}
- @Override
- public final SchemaPath readSchemaPath() throws IOException {
- final boolean absolute = input.readBoolean();
- final int size = input.readInt();
-
- final Builder<QName> qnames = ImmutableList.builderWithExpectedSize(size);
- for (int i = 0; i < size; ++i) {
- qnames.add(readQName());
- }
- return SchemaPath.create(qnames.build(), absolute);
- }
-
@Override
public final YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
return readYangInstanceIdentifierInternal();
int type = input.readByte();
switch (type) {
- case PathArgumentTypes.AUGMENTATION_IDENTIFIER:
+ case LithiumPathArgument.AUGMENTATION_IDENTIFIER:
return readAugmentationIdentifier();
- case PathArgumentTypes.NODE_IDENTIFIER:
+ case LithiumPathArgument.NODE_IDENTIFIER:
return readNodeIdentifier();
- case PathArgumentTypes.NODE_IDENTIFIER_WITH_PREDICATES:
+ case LithiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES:
return readNormalizedNodeWithPredicates();
- case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE:
+ case LithiumPathArgument.NODE_IDENTIFIER_WITH_VALUE:
return new NodeWithValue<>(readQName(), readObject());
default:
// FIXME: throw hard error