1 package org.opendaylight.yangtools.binding.generator.util.stmt.parser.retest;
3 import java.util.Collection;
5 import java.io.FileNotFoundException;
6 import java.io.FileInputStream;
7 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
9 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
10 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
11 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
12 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
13 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
14 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
16 public class RetestUtils {
18 private RetestUtils() {
19 throw new UnsupportedOperationException("Utility class");
22 public static SchemaContext parseYangSources(StatementStreamSource... sources)
23 throws SourceException, ReactorException {
25 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
27 reactor.addSources(sources);
29 return reactor.buildEffective();
32 public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException, FileNotFoundException {
34 StatementStreamSource[] sources = new StatementStreamSource[files.length];
36 for(int i = 0; i<files.length; i++) {
37 sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
40 return parseYangSources(sources);
43 public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException, FileNotFoundException {
44 return parseYangSources(files.toArray(new File[files.size()]));