/** * @param in stream to read PMML from * @return {@link PMML} model file from stream * @throws IOException if an error occurs while reading the model from the stream */ public static PMML read(InputStream in) throws IOException { try { return PMMLUtil.unmarshal(in); } catch (JAXBException | SAXException e) { throw new IOException(e); } }
static public PMML readPMML(File file) throws Exception { try(InputStream is = new FileInputStream(file)){ return PMMLUtil.unmarshal(is); } }
/** * @param in stream to read PMML from * @return {@link PMML} model file from stream * @throws IOException if an error occurs while reading the model from the stream */ public static PMML read(InputStream in) throws IOException { try { return PMMLUtil.unmarshal(in); } catch (JAXBException | SAXException e) { throw new IOException(e); } }
protected PMML loadPMML(String path) throws Exception { try(InputStream is = open(path)){ return PMMLUtil.unmarshal(is); } }
protected PMML loadPMML(String path) throws Exception { try(InputStream is = open(path)){ return PMMLUtil.unmarshal(is); } }
private void transform(File pmmlFile, File serFile, VisitorBattery visitorBattery) throws Exception { PMML pmml; try(InputStream is = new FileInputStream(pmmlFile)){ pmml = PMMLUtil.unmarshal(is); } visitorBattery.applyTo(pmml); try(OutputStream os = new FileOutputStream(serFile)){ SerializationUtil.serializePMML(pmml, os); } }
static public byte[] upgradeToLatest(byte[] bytes) throws IOException, JAXBException, SAXException { ByteArrayOutputStream result = new ByteArrayOutputStream(); try(InputStream is = new ByteArrayInputStream(bytes)){ PMML pmml = PMMLUtil.unmarshal(is); PMMLUtil.marshal(pmml, result); } return result.toByteArray(); }
@Test public void unmarshal() throws Exception { Version[] versions = Version.values(); for(Version version : versions){ PMML pmml; try(InputStream is = ResourceUtil.getStream(version)){ pmml = PMMLUtil.unmarshal(is); } assertEquals(pmml.getVersion(), Version.PMML_4_3.getVersion()); assertEquals(pmml.getBaseVersion(), version.getVersion()); } } }