/** * Deserialize list * @param in Input stream * @param <T> Class * @throws IOException Error accessing to IO * @throws ClassNotFoundException Class not found */ public static <T> Map<String, T> readMap(ObjectInputStream in, Class<T> clazz) throws IOException, ClassNotFoundException { int size = in.readInt(); ValidatingObjectInputStream inputStream = new ValidatingObjectInputStream(in); inputStream.accept(clazz); Map<String, T> map = null; if (size >= 0) { map = new HashMap<>(); for (int i = 0; i < size; i++) { map.put((String) inputStream.readObject(), clazz.cast(inputStream.readObject())); } } return map; } }
/** * Deserialize list * @param in Input stream * @param <T> Class * @throws IOException Error accessing to IO * @throws ClassNotFoundException Class not found */ public static <T> List<T> readList(ObjectInputStream in, Class<T> clazz) throws IOException, ClassNotFoundException { int size = in.readInt(); ValidatingObjectInputStream inputStream = new ValidatingObjectInputStream(in); inputStream.accept(clazz); List<T> list = null; if (size >= 0) { list = new ArrayList<>(); for (int i = 0; i < size; i++) { list.add(clazz.cast(inputStream.readObject())); } } return list; }
/** * De-serialize the pending uploads map from {@link org.apache.jackrabbit.core.data.AsyncUploadCache}. * * @param homeDir the directory where the serialized file is maintained * @return the de-serialized map */ private static Map<String, Long> deSerializeUploadMap(File homeDir) { Map<String, Long> asyncUploadMap = Maps.newHashMap(); File asyncUploadMapFile = new File(homeDir, UPLOAD_MAP); if (asyncUploadMapFile.exists()) { String path = asyncUploadMapFile.getAbsolutePath(); InputStream fis = null; try { fis = (new FileInputStream(path)); ValidatingObjectInputStream input = new ValidatingObjectInputStream(fis); input.accept(HashMap.class, Map.class, Number.class, Long.class, String.class); asyncUploadMap = (Map<String, Long>) input.readObject(); } catch (Exception e) { LOG.error("Error in reading pending uploads map [{}] from location [{}]", UPLOAD_MAP, homeDir, e); } finally { IOUtils.closeQuietly(fis); } LOG.debug("AsyncUploadMap read [{}]", asyncUploadMap); } return asyncUploadMap; }
/** * De-serialize the pending uploads map from {@link org.apache.jackrabbit.core.data.AsyncUploadCache}. * * @param homeDir the directory where the serialized file is maintained * @return the de-serialized map */ private static Map<String, Long> deSerializeUploadMap(File homeDir) { Map<String, Long> asyncUploadMap = Maps.newHashMap(); File asyncUploadMapFile = new File(homeDir, UPLOAD_MAP); if (asyncUploadMapFile.exists()) { String path = asyncUploadMapFile.getAbsolutePath(); InputStream fis = null; try { fis = (new FileInputStream(path)); ValidatingObjectInputStream input = new ValidatingObjectInputStream(fis); input.accept(HashMap.class, Map.class, Number.class, Long.class, String.class); asyncUploadMap = (Map<String, Long>) input.readObject(); } catch (Exception e) { LOG.error("Error in reading pending uploads map [{}] from location [{}]", UPLOAD_MAP, homeDir, e); } finally { IOUtils.closeQuietly(fis); } LOG.debug("AsyncUploadMap read [{}]", asyncUploadMap); } return asyncUploadMap; }
/** * De-serialize the pending uploads map from {@link org.apache.jackrabbit.core.data.AsyncUploadCache}. * * @param homeDir the directory where the serialized file is maintained * @return the de-serialized map */ private static Map<String, Long> deSerializeUploadMap(File homeDir) { Map<String, Long> asyncUploadMap = Maps.newHashMap(); File asyncUploadMapFile = new File(homeDir, UPLOAD_MAP); if (asyncUploadMapFile.exists()) { String path = asyncUploadMapFile.getAbsolutePath(); InputStream fis = null; try { fis = (new FileInputStream(path)); ValidatingObjectInputStream input = new ValidatingObjectInputStream(fis); input.accept(HashMap.class, Map.class, Number.class, Long.class, String.class); asyncUploadMap = (Map<String, Long>) input.readObject(); } catch (Exception e) { LOG.error("Error in reading pending uploads map [{}] from location [{}]", UPLOAD_MAP, homeDir, e); } finally { IOUtils.closeQuietly(fis); } LOG.debug("AsyncUploadMap read [{}]", asyncUploadMap); } return asyncUploadMap; }
org.eclipse.rdf4j.model.impl.SimpleBNode.class); try { Iterable<?> propList = (Iterable<?>) vois.readObject(); Iterable<?> classList = (Iterable<?>) vois.readObject(); for (Object p : propList) { OwlProperty prop = (OwlProperty) p;
org.openrdf.model.impl.IntegerLiteralImpl.class); vois.accept("[B"); // Array of Bytes final Object o = vois.readObject(); if(o instanceof AggregationState) { state = (AggregationState)o;
); vois.accept("[B"); // Array of Bytes final Object o = vois.readObject(); if(o instanceof AggregationState) { state = (AggregationState)o;
); vois.accept("[B"); final Object o = vois.readObject(); if(o instanceof VisibilityBindingSet) { return (VisibilityBindingSet) o;
vois.accept(Pattern.compile("org\\.apache\\.rya\\.api\\.instance\\.RyaDetails.*")); final Object o = vois.readObject();
vois.accept(Pattern.compile("org\\.apache\\.rya\\.api\\.instance\\.RyaDetails.*")); final Object o = vois.readObject();
AggregationElement.class, AggregationType.class); final Object object = vois.readObject(); if (!(object instanceof Collection<?>)) { throw new InvalidClassException("Object read was not of type Collection. It was: " + object.getClass());
AggregationElement.class, AggregationType.class); final Object object = vois.readObject(); if (!(object instanceof Collection<?>)) { throw new InvalidClassException("Object read was not of type Collection. It was: " + object.getClass());
objectInputStream.accept( MailItem.class, ArrayList.class, byte [ ].class, FileAttachment.class, UrlAttachment.class, FileAttachment [ ].class, UrlAttachment [ ].class, URL.class ); mailItem = (MailItem) objectInputStream.readObject( ); objectInputStream.close( );