List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:com.splicemachine.derby.stream.function.TableScanQualifierFunction.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); if (in.readBoolean()) optionalProbeValue = (DataValueDescriptor) in.readObject(); }
From source file:com.conwet.silbops.msg.UnsubscribeMsgTest.java
@Test public void shouldExternalizeAndDesexternalize() throws Exception { UnsubscribeMsg unSubMsg = new UnsubscribeMsg(); Subscription subscription = new Subscription().constrain("attr1", Type.DOUBLE).ge(20.5D) .constrain("attr2", Type.LONG).eq(2L).constrain("attr3", Type.STRING).contains("TEST") .subscription();//from w w w .j av a 2 s. com unSubMsg.setSubscription(subscription); Subscription uncovered1 = new Subscription().constrain("attr1", Type.DOUBLE).ge(20.5D) .constrain("attr2", Type.LONG).eq(2L).constrain("attr3", Type.STRING).contains("TEST") .constrain("attr4", Type.DOUBLE).le(7D).subscription(); Subscription uncovered2 = new Subscription().constrain("attr1", Type.DOUBLE).ge(20.5D) .constrain("attr2", Type.LONG).eq(2L).constrain("attr3", Type.STRING).contains("TEST") .constrain("attr4", Type.LONG).gt(7L).subscription(); Set<Subscription> uncovered = new HashSet<>(); uncovered.add(uncovered1); uncovered.add(uncovered2); unSubMsg.setUncovered(uncovered); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutput output = new ObjectOutputStream(baos); output.writeObject(unSubMsg); output.close(); ObjectInput input = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); assertThat((UnsubscribeMsg) input.readObject()).isEqualTo(unSubMsg); }
From source file:org.rhq.enterprise.server.plugins.alertMicroblog.MicroblogSender.java
private AccessToken restoreAccessToken(String tokenFilePath) throws IOException { //use buffering InputStream file = new FileInputStream(tokenFilePath); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream(buffer); AccessToken token = null;/*from w ww .j av a2 s. c o m*/ try { token = (AccessToken) input.readObject(); } catch (ClassNotFoundException e) { log.error("Erro reading token from disk: ", e); } finally { input.close(); } return token; }
From source file:com.adaptris.core.interceptor.MetadataStatistic.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { setEndMillis(in.readLong());//www.j a v a 2s . co m setMetadataStatistics((Properties) in.readObject()); setStartMillis(in.readLong()); }
From source file:com.delphix.session.util.AbstractExternalCodec.java
/** * Decode the service exception from the input stream. *///from ww w. j a va2 s . c o m @Override public ServiceException decodeException(InputStream in) throws IOException, ClassNotFoundException { @SuppressWarnings("resource") ObjectInput oin = new ExternalObjectInput(in); return (ServiceException) oin.readObject(); }
From source file:com.conwet.silbops.model.AdvertiseTest.java
@Test public void shouldExternalize() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutput output = new ObjectOutputStream(baos); output.writeObject(advertise);/*from ww w . j av a 2s. c om*/ output.close(); ObjectInput input = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); assertThat((Advertise) input.readObject()).isEqualTo(advertise); }
From source file:org.nuxeo.ecm.platform.ui.web.binding.MetaValueExpression.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { originalValueExpression = (ValueExpression) in.readObject(); }
From source file:com.act.reachables.ActData.java
public void deserialize(String fromFile) { try {/* w w w . ja v a 2 s . com*/ InputStream file = new FileInputStream(fromFile); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream(buffer); try { ActData._instance = (ActData) input.readObject(); } finally { input.close(); } } catch (ClassNotFoundException ex) { throw new RuntimeException("ActData deserialize failed: Class not found: " + ex); } catch (IOException ex) { throw new RuntimeException("ActData deserialize failed: IO problem: " + ex); } }
From source file:org.wso2.carbon.ml.core.spark.models.MLMatrixFactorizationModel.java
@SuppressWarnings("unchecked") @Override//from w ww . ja va 2s . c o m public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int rank = in.readInt(); List<Tuple2<Object, double[]>> userFeaturesList = (List<Tuple2<Object, double[]>>) in.readObject(); List<Tuple2<Object, double[]>> productFeaturesList = (List<Tuple2<Object, double[]>>) in.readObject(); MLCoreServiceValueHolder valueHolder = MLCoreServiceValueHolder.getInstance(); RDD<Tuple2<Object, double[]>> userFeatures = valueHolder.getSparkContext().parallelize(userFeaturesList) .rdd(); RDD<Tuple2<Object, double[]>> productFeatures = valueHolder.getSparkContext() .parallelize(productFeaturesList).rdd(); model = new MatrixFactorizationModel(rank, userFeatures, productFeatures); if (log.isDebugEnabled()) { log.debug("Rank, user features and product features were de-serialized successfully and loaded " + "MatrixFactorizationModel."); } }
From source file:org.jfree.experimental.chart.annotations.junit.XYTitleAnnotationTests.java
/** * Serialize an instance, restore it, and check for equality. *//*from w w w . j a v a 2 s .c om*/ public void testSerialization() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); a2 = (XYTitleAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); }