X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Ftools%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fcli%2Freader%2Fcustom%2FEditContentReader.java;fp=netconf%2Ftools%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fcli%2Freader%2Fcustom%2FEditContentReader.java;h=92a33fb4e8181d4171c493cd4dd9b15c58c4b388;hb=4c0c091813aea131d32dc70c5121a450eb9b7291;hp=0000000000000000000000000000000000000000;hpb=a63cd90c78847178c8ab9a970b2189bdab572a80;p=netconf.git diff --git a/netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/EditContentReader.java b/netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/EditContentReader.java new file mode 100644 index 0000000000..92a33fb4e8 --- /dev/null +++ b/netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/EditContentReader.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.netconf.cli.reader.custom; + +import com.google.common.base.Preconditions; +import java.io.IOException; +import java.util.List; +import org.opendaylight.netconf.cli.CommandArgHandlerRegistry; +import org.opendaylight.netconf.cli.commands.CommandConstants; +import org.opendaylight.netconf.cli.io.ConsoleIO; +import org.opendaylight.netconf.cli.reader.ReadingException; +import org.opendaylight.netconf.cli.reader.impl.ChoiceReader; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +public class EditContentReader extends ChoiceReader { + + public static final QName EDIT_CONTENT_QNAME = QName.create(CommandConstants.NETCONF_BASE_QNAME, "edit-content"); + public static final QName CONFIG_QNAME = QName.create(EDIT_CONTENT_QNAME, "config"); + + // FIXME this could be removed if feature/if-feature are supported + + public EditContentReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry, final SchemaContext schemaContext) { + super(console, argumentHandlerRegistry, schemaContext); + } + + @Override + public List> readWithContext(final ChoiceSchemaNode choiceNode) throws IOException, ReadingException { + Preconditions.checkState(choiceNode.getQName().equals(EDIT_CONTENT_QNAME), "Unexpected choice %s, expected %s", choiceNode, EDIT_CONTENT_QNAME); + final ChoiceCaseNode selectedCase = choiceNode.getCaseNodeByName(CONFIG_QNAME); + Preconditions.checkNotNull(selectedCase, "Unexpected choice %s, expected %s that contains %s", choiceNode, EDIT_CONTENT_QNAME, CONFIG_QNAME); + return readSelectedCase(selectedCase); + } + +}