import static com.google.common.base.Preconditions.checkNotNull;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
this.schemaContext = schemaContext;
}
- LeafRefContext buildLeafRefContextTree() throws IOException, LeafRefYangSyntaxErrorException {
+ LeafRefContext buildLeafRefContextTree() throws LeafRefYangSyntaxErrorException {
final LeafRefContextBuilder rootBuilder = new LeafRefContextBuilder(schemaContext.getQName(),
schemaContext.getPath(), schemaContext);
}
private LeafRefContext buildLeafRefContextReferencingTree(final DataSchemaNode node, final Module currentModule)
- throws IOException, LeafRefYangSyntaxErrorException {
+ throws LeafRefYangSyntaxErrorException {
final LeafRefContextBuilder currentLeafRefContextBuilder = new LeafRefContextBuilder(node.getQName(),
node.getPath(), schemaContext);
if (type instanceof LeafrefTypeDefinition) {
final LeafrefTypeDefinition leafrefType = (LeafrefTypeDefinition) type;
final String leafRefPathString = leafrefType.getPathStatement().toString();
-
- currentLeafRefContextBuilder.setLeafRefTargetPathString(leafRefPathString);
- currentLeafRefContextBuilder.setReferencing(true);
-
final LeafRefPathParserImpl leafRefPathParser = new LeafRefPathParserImpl(schemaContext,
checkNotNull(getBaseTypeModule(leafrefType), "Unable to find base module for leafref %s", node),
node);
+ final LeafRefPath leafRefPath = leafRefPathParser.parseLeafRefPath(leafRefPathString);
- final LeafRefPath leafRefPath = leafRefPathParser.parseLeafRefPathSourceToSchemaPath(
- new ByteArrayInputStream(leafRefPathString.getBytes(StandardCharsets.UTF_8)));
-
+ currentLeafRefContextBuilder.setLeafRefTargetPathString(leafRefPathString);
+ currentLeafRefContextBuilder.setReferencing(true);
currentLeafRefContextBuilder.setLeafRefTargetPath(leafRefPath);
final LeafRefContext currentLeafRefContext = currentLeafRefContextBuilder.build();
}
private LeafRefContext buildLeafRefContextReferencedByTree(final DataSchemaNode node, final Module currentModule)
- throws IOException,LeafRefYangSyntaxErrorException {
+ throws LeafRefYangSyntaxErrorException {
final LeafRefContextBuilder currentLeafRefContextBuilder = new LeafRefContextBuilder(node.getQName(),
node.getPath(), schemaContext);
if (node instanceof DataNodeContainer) {
*/
package org.opendaylight.yangtools.yang.data.impl.leafref;
-import java.io.IOException;
-import java.io.InputStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
this.node = currentNode;
}
- public LeafRefPath parseLeafRefPathSourceToSchemaPath(final InputStream stream) throws IOException,
- LeafRefYangSyntaxErrorException {
- final Path_argContext pathCtx = parseLeafRefPathSource(stream);
+ LeafRefPath parseLeafRefPath(final String path) throws LeafRefYangSyntaxErrorException {
+ final Path_argContext pathCtx = parseLeafRefPathSource(path);
final ParseTreeWalker walker = new ParseTreeWalker();
final LeafRefPathParserListenerImpl leafRefPathParserListenerImpl = new LeafRefPathParserListenerImpl(
return leafRefPathParserListenerImpl.getLeafRefPath();
}
- private Path_argContext parseLeafRefPathSource(final InputStream stream) throws IOException,
- LeafRefYangSyntaxErrorException {
- final LeafRefPathLexer lexer = new LeafRefPathLexer(CharStreams.fromStream(stream));
+ private Path_argContext parseLeafRefPathSource(final String path) throws LeafRefYangSyntaxErrorException {
+ final LeafRefPathLexer lexer = new LeafRefPathLexer(CharStreams.fromString(path));
final CommonTokenStream tokens = new CommonTokenStream(lexer);
final LeafRefPathParser parser = new LeafRefPathParser(tokens);
parser.removeErrorListeners();