1 package org.opendaylight.yangtools.sal.binding.yang.types.stmt.parser.retest;
5 import java.io.InputStream;
6 import java.util.Collection;
7 import java.io.FileNotFoundException;
8 import java.io.FileInputStream;
9 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
11 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
12 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
14 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
16 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
18 public class RetestUtils {
20 private RetestUtils() {
21 throw new UnsupportedOperationException("Utility class");
24 public static SchemaContext parseYangSources(StatementStreamSource... sources)
25 throws SourceException, ReactorException {
27 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
29 reactor.addSources(sources);
31 return reactor.buildEffective();
34 public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException, FileNotFoundException {
36 StatementStreamSource[] sources = new StatementStreamSource[files.length];
38 for(int i = 0; i<files.length; i++) {
39 sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
42 return parseYangSources(sources);
45 public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException, FileNotFoundException {
46 return parseYangSources(files.toArray(new File[files.size()]));
50 public static SchemaContext parseYangStreams(List<InputStream> streams)
51 throws SourceException, ReactorException {
53 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
55 return reactor.buildEffective(streams);