import javax.xml.transform.dom.DOMSource;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceTransformer;
+import org.opendaylight.yangtools.yang.model.spi.source.YinDomSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YinTextSource;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/**
- * A {@link SchemaSourceTransformer} which handles translation of models from
- * {@link YinTextSchemaSource} representation into {@link YinDomSchemaSource}.
- *
- * @author Robert Varga
+ * A {@link SchemaSourceTransformer} which handles translation of models from {@link YinTextSource} representation into
+ * {@link YinDomSource}.
*/
@Beta
-public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTextSchemaSource, YinDomSchemaSource> {
+public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTextSource, YinDomSource> {
private YinTextToDomTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
- super(provider, YinTextSchemaSource.class, consumer, YinDomSchemaSource.class,
+ super(provider, YinTextSource.class, consumer, YinDomSource.class,
input -> Futures.immediateFuture(transformSource(input)));
}
return new YinTextToDomTransformer(provider, consumer);
}
- public static YinDomSchemaSource transformSource(final YinTextSchemaSource source) throws SAXException,
- IOException {
+ public static YinDomSource transformSource(final YinTextSource source) throws SAXException, IOException {
final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
final SAXParser parser = UntrustedXML.newSAXParser();
final DefaultHandler handler = new StatementSourceReferenceHandler(doc, null);
parser.parse(source.openStream(), handler);
- return YinDomSchemaSource.create(source.getIdentifier(), new DOMSource(doc),
- source.getSymbolicName().orElse(null));
+ return YinDomSource.create(source.sourceId(), new DOMSource(doc), source.symbolicName());
}
}