/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }
/** Create a new object output. * @param os the underlying output stream * @throws IOException for the usual reasons */ public NbObjectOutputStream(OutputStream os) throws IOException { super(os); try { enableReplaceObject(true); } catch (SecurityException ex) { throw (IOException) new IOException(ex.toString()).initCause(ex); } }
if (isSerialVersionUIDDeclared(cl)) { return;
/** * Creates a new <code>NbMarshalledObject</code> that contains the * serialized representation of the provided object. * * @param obj the object to be serialized (must be serializable) * @exception IOException the object is not serializable */ public NbMarshalledObject(Object obj) throws IOException { if (obj == null) { hash = 17; return; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new NbObjectOutputStream(bout); out.writeObject(obj); out.flush(); objBytes = bout.toByteArray(); int h = 0; for (int i = 0; i < objBytes.length; i++) { h = (37 * h) + objBytes[i]; } hash = h; }
public static void store() throws IOException { if (modifiedLoaders.isEmpty()) { return; } FileObject ser = getLoaderPoolStorage(true); OutputStream os = ser.getOutputStream(); try { ObjectOutputStream oos = new NbObjectOutputStream(os); NbObjectOutputStream.writeSafely(oos, getNbLoaderPool()); oos.flush(); oos.close(); } finally { os.close(); } } public static void load() throws IOException {
/** * Creates a new <code>NbMarshalledObject</code> that contains the * serialized representation of the provided object. * * @param obj the object to be serialized (must be serializable) * @exception IOException the object is not serializable */ public NbMarshalledObject(Object obj) throws java.io.IOException { if (obj == null) { hash = 17; return; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new NbObjectOutputStream (bout); out.writeObject(obj); out.flush(); objBytes = bout.toByteArray(); int h = 0; for (int i = 0; i < objBytes.length; i++) { h = 37 * h + objBytes[i]; } hash = h; }
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }
/** * Creates a new <code>NbMarshalledObject</code> that contains the * serialized representation of the provided object. * * @param obj the object to be serialized (must be serializable) * @exception IOException the object is not serializable */ public NbMarshalledObject(Object obj) throws IOException { if (obj == null) { hash = 17; return; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new NbObjectOutputStream(bout); out.writeObject(obj); out.flush(); objBytes = bout.toByteArray(); int h = 0; for (int i = 0; i < objBytes.length; i++) { h = (37 * h) + objBytes[i]; } hash = h; }
/** Create a new object output. * @param os the underlying output stream * @throws IOException for the usual reasons */ public NbObjectOutputStream(OutputStream os) throws IOException { super(os); try { enableReplaceObject(true); } catch (SecurityException ex) { throw (IOException) new IOException(ex.toString()).initCause(ex); } }
if (isSerialVersionUIDDeclared(cl)) { return;
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely (ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream (200); try { NbObjectOutputStream oos = new NbObjectOutputStream (bos); oos.writeObject (obj); oos.flush (); bos.close (); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt (0); throw new SafeException (exc); } oo.writeInt (bos.size ()); oo.write (bos.toByteArray ()); }
/** * Creates a new <code>NbMarshalledObject</code> that contains the * serialized representation of the provided object. * * @param obj the object to be serialized (must be serializable) * @exception IOException the object is not serializable */ public NbMarshalledObject(Object obj) throws java.io.IOException { if (obj == null) { hash = 17; return; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new NbObjectOutputStream (bout); out.writeObject(obj); out.flush(); objBytes = bout.toByteArray(); int h = 0; for (int i = 0; i < objBytes.length; i++) { h = 37 * h + objBytes[i]; } hash = h; }
/** Create a new object output. * @param os the underlying output stream * @throws IOException for the usual reasons */ public NbObjectOutputStream(OutputStream os) throws IOException { super(os); try { enableReplaceObject(true); } catch (SecurityException ex) { throw (IOException) new IOException(ex.toString()).initCause(ex); } }
if (isSerialVersionUIDDeclared(cl)) { return;
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely (ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream (200); try { NbObjectOutputStream oos = new NbObjectOutputStream (bos); oos.writeObject (obj); oos.flush (); bos.close (); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt (0); throw new SafeException (exc); } oo.writeInt (bos.size ()); oo.write (bos.toByteArray ()); }
/** * Creates a new <code>NbMarshalledObject</code> that contains the * serialized representation of the provided object. * * @param obj the object to be serialized (must be serializable) * @exception IOException the object is not serializable */ public NbMarshalledObject(Object obj) throws IOException { if (obj == null) { hash = 17; return; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new NbObjectOutputStream(bout); out.writeObject(obj); out.flush(); objBytes = bout.toByteArray(); int h = 0; for (int i = 0; i < objBytes.length; i++) { h = (37 * h) + objBytes[i]; } hash = h; }
/** Create a new object output. * @param os the underlying output stream * @throws IOException for the usual reasons */ public NbObjectOutputStream(OutputStream os) throws IOException { super (os); try { enableReplaceObject (true); } catch (SecurityException ex) { IOException ioe = new IOException (ex.toString ()); ErrorManager.getDefault().annotate (ioe, ex); throw ioe; } }
if (isSerialVersionUIDDeclared(cl)) { return;
/** Writes an object safely to the object output. * Can be read by {@link NbObjectInputStream#readSafely}. * @param oo object output to write to * @param obj the object to write * @exception SafeException if the object simply fails to be serialized * @exception IOException if something more serious fails */ public static void writeSafely(ObjectOutput oo, Object obj) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(200); try { NbObjectOutputStream oos = new NbObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.close(); } catch (Exception exc) { // exception during safe of the object // encapsulate all exceptions into safe exception oo.writeInt(0); throw new SafeException(exc); } oo.writeInt(bos.size()); oo.write(bos.toByteArray()); }
/** Create a new object output. * @param os the underlying output stream * @throws IOException for the usual reasons */ public NbObjectOutputStream(OutputStream os) throws IOException { super (os); try { enableReplaceObject (true); } catch (SecurityException ex) { IOException ioe = new IOException (ex.toString ()); ErrorManager.getDefault().annotate (ioe, ex); throw ioe; } }