List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:com.github.naoghuman.abclist.model.LinkMapping.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.setId(in.readLong()); this.setParentId(in.readLong()); final Optional<LinkMappingType> primaryType = LinkMappingType.getType(String.valueOf(in.readObject())); this.setParentType(primaryType.isPresent() ? primaryType.get() : LinkMappingType.NOT_DEFINED); this.setChildId(in.readLong()); final Optional<LinkMappingType> childType = LinkMappingType.getType(String.valueOf(in.readObject())); this.setChildType(childType.isPresent() ? childType.get() : LinkMappingType.NOT_DEFINED); }
From source file:com.github.naoghuman.abclist.model.Link.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.setId(in.readLong()); this.setGenerationTime(in.readLong()); this.setAlias(String.valueOf(in.readObject())); // TODO (de-/encrypt for db) this.setDescription(String.valueOf(in.readObject())); // TODO (de-/encrypt for db) this.setUrl(String.valueOf(in.readObject())); // TODO (de-/encrypt for db) this.setImage(String.valueOf(in.readObject())); this.setFavorite(in.readBoolean()); }
From source file:org.drools.core.io.impl.UrlResource.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); this.url = (URL) in.readObject(); this.encoding = (String) in.readObject(); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * Serialize an instance, restore it, and check for equality. */// www. j ava 2 s . c o m public void testSerialization() { Day d1 = new Day(15, 4, 2000); Day d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (Day) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); }
From source file:com.github.naoghuman.abclist.model.Topic.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.setId(in.readLong()); this.setParentId(in.readLong()); this.setGenerationTime(in.readLong()); this.setDescription(String.valueOf(in.readObject())); this.setTitle(String.valueOf(in.readObject())); }
From source file:org.jfree.data.category.junit.DefaultCategoryDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. */// w w w. ja va 2s . co m public void testSerialization() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); d1.setValue(23.4, "R1", "C1"); DefaultCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); }
From source file:org.nuxeo.ecm.platform.ui.web.component.list.StampState.java
@Override @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int size = in.readInt(); if (size > 0) { rows = (Map<DualKey, Object>) in.readObject(); }/*from w w w . j a v a2s .com*/ if (log.isDebugEnabled()) { for (Map.Entry<DualKey, Object> entry : rows.entrySet()) { log.debug("Restoring " + entry.getKey() + ", " + entry.getValue()); } } }
From source file:org.jfree.data.xy.junit.DefaultIntervalXYDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w ww . j av a2s. c om*/ public void testSerialization() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); DefaultIntervalXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultIntervalXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... d1 = createSampleDataset1(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultIntervalXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); }
From source file:com.near.chimerarevo.fragments.SearchFragment.java
private boolean readOfflineFile() { try {//from w w w .j a va2 s. com if (new File(getActivity().getCacheDir() + "/search.ser").exists()) { InputStream file = new FileInputStream(getActivity().getCacheDir() + "/search.ser"); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream(buffer); mJson = ((PostsListObject) input.readObject()).getJSONs(); input.close(); shouldSmoothScroll = false; try { for (String json : mJson) setItems(JSONUtils.getJSONArray(json, Constants.KEY_POSTS)); } catch (Exception e) { e.printStackTrace(); return false; } return true; } else return false; } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } return false; }
From source file:org.apache.openjpa.datacache.QueryKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { _candidateClassName = (String) in.readObject(); _subclasses = in.readBoolean();/*from w w w . j a v a 2 s . c o m*/ _accessPathClassNames = (Set<String>) in.readObject(); _query = (String) in.readObject(); _ignoreChanges = in.readBoolean(); _params = (Map<Object, Object>) in.readObject(); _rangeStart = in.readLong(); _rangeEnd = in.readLong(); _timeout = in.readInt(); }