@Test public void testDeserialization() throws IOException { DBSInvalidations invals; ByteArrayInputStream bain; bain = new ByteArrayInputStream("".getBytes()); invals = DBSInvalidations.deserialize(bain); assertNull(invals); bain = new ByteArrayInputStream("x".getBytes()); invals = DBSInvalidations.deserialize(bain); assertNull(invals); bain = new ByteArrayInputStream("A".getBytes()); invals = DBSInvalidations.deserialize(bain); assertTrue(invals.all); bain = new ByteArrayInputStream(",foo".getBytes()); invals = DBSInvalidations.deserialize(bain); assertEquals(Collections.singleton("foo"), invals.ids); bain = new ByteArrayInputStream(",foo,bar".getBytes()); invals = DBSInvalidations.deserialize(bain); assertEquals(new HashSet<>(Arrays.asList("foo", "bar")), invals.ids); }
public static DBSInvalidations deserialize(InputStream in) throws IOException { int first = in.read(); if (first == -1) { return null; } DBSInvalidations invalidations = new DBSInvalidations(); if (first == ALL_IDS) { invalidations.setAll(); } else if (first != ID_SEP) { return null; } else { ByteArrayOutputStream baout = new ByteArrayOutputStream(36); for (;;) { int b = in.read(); if (b == ID_SEP || b == -1) { invalidations.add(baout.toString(UTF_8)); if (b == -1) { break; } baout.reset(); } else { baout.write(b); } } } return invalidations; }
DBSInvalidations implements SerializableAccumulableInvalidations { public static DBSInvalidations deserialize(InputStream in) throws IOException { int first = in.read(); if (first == -1) { return null; } DBSInvalidations invalidations = new DBSInvalidations(); if (first == ALL_IDS) { invalidations.setAll(); } else if (first != ID_SEP) { return null; } else { ByteArrayOutputStream baout = new ByteArrayOutputStream(36); for (;;) { int b = in.read(); if (b == ID_SEP || b == -1) { invalidations.add(baout.toString(UTF_8)); if (b == -1) { break; } baout.reset(); } else { baout.write(b); } } } return invalidations; } }
DBSInvalidations implements SerializableAccumulableInvalidations { public static DBSInvalidations deserialize(InputStream in) throws IOException { int first = in.read(); if (first == -1) { return null; } DBSInvalidations invalidations = new DBSInvalidations(); if (first == ALL_IDS) { invalidations.setAll(); } else if (first != ID_SEP) { return null; } else { ByteArrayOutputStream baout = new ByteArrayOutputStream(36); for (;;) { int b = in.read(); if (b == ID_SEP || b == -1) { invalidations.add(baout.toString(UTF_8)); if (b == -1) { break; } baout.reset(); } else { baout.write(b); } } } return invalidations; } DBSInvalidations();  DBSInvalidations(boolean all); }
DBSInvalidations implements SerializableAccumulableInvalidations { public static DBSInvalidations deserialize(InputStream in) throws IOException { int first = in.read(); if (first == -1) { return null; } DBSInvalidations invalidations = new DBSInvalidations(); if (first == ALL_IDS) { invalidations.setAll(); } else if (first != ID_SEP) { return null; } else { ByteArrayOutputStream baout = new ByteArrayOutputStream(36); for (;;) { int b = in.read(); if (b == ID_SEP || b == -1) { invalidations.add(baout.toString(UTF_8)); if (b == -1) { break; } baout.reset(); } else { baout.write(b); } } } return invalidations; } DBSInvalidations();  DBSInvalidations(boolean all); @Override boolean isEmpty(); void clear(); @Override void add(SerializableAccumulableInvalidations o); void add(String id); void addAll(Collection<String> idsToAdd); @Override void serialize(OutputStream out); static DBSInvalidations deserialize(InputStream in); @Override String toString(); }
DBSInvalidations implements SerializableAccumulableInvalidations { public static DBSInvalidations deserialize(InputStream in) throws IOException { int first = in.read(); if (first == -1) { return null; } DBSInvalidations invalidations = new DBSInvalidations(); if (first == ALL_IDS) { invalidations.setAll(); } else if (first != ID_SEP) { return null; } else { ByteArrayOutputStream baout = new ByteArrayOutputStream(36); for (;;) { int b = in.read(); if (b == ID_SEP || b == -1) { invalidations.add(baout.toString(UTF_8)); if (b == -1) { break; } baout.reset(); } else { baout.write(b); } } } return invalidations; } DBSInvalidations();  DBSInvalidations(boolean all); @Override boolean isEmpty(); void clear(); @Override void add(SerializableAccumulableInvalidations o); void add(String id); void addAll(Collection<String> idsToAdd); @Override void serialize(OutputStream out); static DBSInvalidations deserialize(InputStream in); @Override String toString(); static final int MAX_SIZE; public boolean all; public Set<String> ids; }