@Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    VersionChecker.readAndCheckVersion(in, VERSION, PerTableSerializableIdSourceKey.class);

    columnNames = (String[]) in.readObject();
    columnValues = (Object[]) in.readObject();
  }
Example #2
0
  public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException {
    super.readExternal(input);

    short[] flagsArray = readFlags(input);
    for (int i = 0; i < flagsArray.length; i++) {
      short flags = flagsArray[i];
      short reservedPosition = 0;

      if (i == 0) {
        if ((flags & 0x1) != 0) {
          this.identity = ((Map) input.readObject());
        }
        if ((flags & 0x2) != 0) this.operation = ((Number) input.readObject()).intValue();
        else {
          this.operation = 0;
        }
        reservedPosition = 2;
      }

      if (flags >> reservedPosition != 0) {
        for (short j = reservedPosition; j < 6; j = (short) (j + 1)) {
          if ((flags >> j & 0x1) != 0) {
            input.readObject();
          }
        }
      }
    }
  }
 @Override
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   this.propertyName = (String) in.readObject();
   this.persistList = (List<Type>) in.readObject();
   this.clear = in.readBoolean();
   this.exclusive = in.readBoolean();
 }
Example #4
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   int size = in.readInt();
   this.items = UnifiedMap.newMap(size);
   for (int i = 0; i < size; i++) {
     this.addOccurrences((T) in.readObject(), in.readInt());
   }
 }
 // implementation of sayHelloWorld()
 public java.lang.String sayHelloWorld() throws java.rmi.RemoteException {
   try {
     java.rmi.server.RemoteCall call =
         ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
     ref.invoke(call);
     java.lang.String $result;
     try {
       java.io.ObjectInput in = call.getInputStream();
       $result = (java.lang.String) in.readObject();
     } catch (java.io.IOException e) {
       throw new java.rmi.UnmarshalException("error unmarshalling return", e);
     } catch (java.lang.ClassNotFoundException e) {
       throw new java.rmi.UnmarshalException("error unmarshalling return", e);
     } finally {
       ref.done(call);
     }
     return $result;
   } catch (java.lang.RuntimeException e) {
     throw e;
   } catch (java.rmi.RemoteException e) {
     throw e;
   } catch (java.lang.Exception e) {
     throw new java.rmi.UnexpectedException("undeclared checked exception", e);
   }
 }
Example #6
0
  /**
   * Implements Externalizable interface to read serialized form
   *
   * @param s Input stream to serialize from
   */
  public void readExternal(java.io.ObjectInput s) throws ClassNotFoundException, IOException {
    int numFields = s.readInt();
    if (numFields > 0) {
      fields = new ArrayList(numFields);
      columnInfos = new HashMap();
      for (int i = 0; i < numFields; i++) {
        String fieldName = s.readUTF();
        fields.add(fieldName);

        Object colInfo = s.readObject();
        columnInfos.put(fieldName, colInfo);
      }
    }

    int numRows = s.readInt();
    if (numRows > 0) {
      records = new ArrayList(numRows);
      for (int row = 0; row < numRows; row++) {
        List record = new ArrayList(numFields);
        for (int col = 0; col < numFields; col++) {
          record.add(s.readObject());
        }
        records.add(record);
      }
    }
  }
 public static Action deserializeAction(byte[] byteArray) {
   ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
   ObjectInput in = null;
   Action o = null;
   try {
     in = new ObjectInputStream(bis);
     o = (Action) in.readObject();
   } catch (IOException | ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       bis.close();
     } catch (IOException ex) {
       // ignore close exception
     }
     try {
       if (in != null) {
         in.close();
       }
     } catch (IOException ex) {
       // ignore close exception
     }
   }
   return o;
 }
  /** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {

    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");

    List u2 = new java.util.ArrayList();
    u2.add("URL B1");
    u2.add("URL B2");
    u2.add("URL B3");

    CustomXYURLGenerator g1 = new CustomXYURLGenerator();
    CustomXYURLGenerator g2 = null;

    g1.addURLSeries(u1);
    g1.addURLSeries(u2);

    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(g1);
      out.close();

      ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
      g2 = (CustomXYURLGenerator) in.readObject();
      in.close();
    } catch (Exception e) {
      System.out.println(e.toString());
    }
    assertEquals(g1, g2);
  }
Example #9
0
 @Override
 public FileReadLockKey readObject(ObjectInput input)
     throws IOException, ClassNotFoundException {
   String indexName = input.readUTF();
   String fileName = input.readUTF();
   return new FileReadLockKey(indexName, fileName);
 }
Example #10
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   super.readExternal(in);
   rmAddress = (InetAddress) in.readObject();
   filter = (LogFilter) in.readObject();
   port = in.readInt();
   usedAcc = (boolean[]) in.readObject();
 }
Example #11
0
  @Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int len = in.readInt();
    byte[] b = new byte[len];

    // read fully
    int done = 0;
    while (done < len) {
      int got = in.read(b, done, len - done);
      if (got < 0) throw new IOException();
      done += got;
    }

    FileSystemProto.Directory proto = FileSystemProto.Directory.parseFrom(b);

    path = proto.getPath();
    lastModified = proto.getLastModified();
    List<FileSystemProto.File> files = proto.getFilesList();
    children = new CacheFileProto[files.size()];
    for (int i = 0; i < files.size(); i++) {
      FileSystemProto.File fp = files.get(i);
      CacheFileProto cf = new CacheFileProto();
      cf.setShortName(fp.getName());
      cf.setDirectory(fp.getIsDirectory());
      cf.setLastModified(fp.getLastModified());
      cf.setLength(fp.getLength());

      children[i] = cf;
    }
  }
Example #12
0
 @SuppressWarnings("unchecked")
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   super.readExternal(in);
   entryPoint = (EntryPoint) in.readObject();
   objectTypeNodes = (Map<ObjectType, ObjectTypeNode>) in.readObject();
   unlinkingEnabled = in.readBoolean();
 }
  /** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {
    DefaultHighLowDataset d1 =
        new DefaultHighLowDataset(
            "Series 1",
            new Date[] {new Date(123L)},
            new double[] {1.2},
            new double[] {3.4},
            new double[] {5.6},
            new double[] {7.8},
            new double[] {99.9});
    DefaultHighLowDataset 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 = (DefaultHighLowDataset) in.readObject();
      in.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assertEquals(d1, d2);
  }
Example #14
0
 @Override
 public RemoveOperation readObject(ObjectInput input)
     throws IOException, ClassNotFoundException {
   Path parentPath = (Path) input.readObject();
   String fieldName = input.readUTF();
   return new RemoveOperation(parentPath, fieldName, null);
 }
Example #15
0
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    storeId = (String) in.readObject();
    store = (TripleStore) in.readObject();
    tripleFactory = (TripleFactory) in.readObject();

    setObject(in.readObject());
  }
  /** {@inheritDoc} */
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION
    int version = in.readByte();

    // SUPER
    super.readExternal(in);

    // NUMBER OF ENTRIES
    int size = in.readInt();

    if (version >= 1) {
      // LOAD FACTOR
      _loadFactor = in.readFloat();

      // NO ENTRY VALUE
      no_entry_value = in.readShort();
      //noinspection RedundantCast
      if (no_entry_value != (short) 0) {
        Arrays.fill(_set, no_entry_value);
      }
    }

    // ENTRIES
    setUp(size);
    while (size-- > 0) {
      short val = in.readShort();
      add(val);
    }
  }
 @Override
 public void readExternal(ObjectInput objectInput) throws IOException {
   shardId = objectInput.readLong();
   classNameId = objectInput.readLong();
   classPK = objectInput.readLong();
   name = objectInput.readUTF();
 }
 @Override
 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
   super.readExternal(in);
   this.key = (Key) in.readObject();
   this.text = (TextKey) in.readObject();
   this.nextEvent = (Event<?>) in.readObject();
 }
Example #19
0
  /** {@inheritDoc} */
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    byte[] data = new byte[in.readInt()];
    in.readFully(data);
    path = new String(data, Constants.DEFAULT_ENCODING);
  }
Example #20
0
 @Override
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   super.readExternal(in);
   eventType = in.readShort();
   streamId = in.readInt();
   bufferLength = in.readInt();
 }
Example #21
0
  /** Create the serversocket and use its stream to receive serialized objects */
  public static void main(String args[]) {

    ServerSocket ser = null;
    Socket soc = null;
    String str = null;
    Date d = null;

    try {
      ser = new ServerSocket(8020);
      /*
       * This will wait for a connection to be made to this socket.
       */
      soc = ser.accept();
      InputStream o = soc.getInputStream();
      ObjectInput s = new ObjectInputStream(o);
      str = (String) s.readObject();
      d = (Date) s.readObject();
      s.close();

      // print out what we just received
      System.out.println(str);
      System.out.println(d);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      System.out.println("Error during serialization");
      System.exit(1);
    }
  }
Example #22
0
 /**
  * Reads a saved serialized HashMap of TreeData objects in 'dir' named 'id' and returns the
  * TreeContainer object.
  *
  * @param id name of HashMap
  * @param dir location of saved .ser file
  * @param printData if true, will print HashMap to string (via toString method)
  * @return HashMap of TreeData objects specified by 'id' and 'dir', or null if no TreeContainer
  *     found
  */
 @SuppressWarnings("unchecked")
 public static HashMap<String, TreeData> readTreeDataMap(
     String id, String dir, boolean printData) {
   ObjectInput inputObject;
   HashMap<String, TreeData> tdHash = null;
   try {
     inputObject =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(dir + id + ".ser")));
     try {
       tdHash = (HashMap<String, TreeData>) inputObject.readObject();
     } catch (ClassNotFoundException e) {
       tdHash = null;
       Logger.logln("Couldn't load ArrayList<TreeData>: " + id + ", from: " + dir);
       e.printStackTrace();
     } finally {
       inputObject.close();
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
   if (printData == true && tdHash != null) {
     System.out.println(tdHash.toString());
   }
   return tdHash;
 }
Example #23
0
    public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException {
      event = in.readByte();

      if (in.readByte() != NULL) {
        parms = (List) in.readObject();
      }
    }
Example #24
0
 public static TaggedDocument readTaggedDocument(String id, String dir, boolean printData) {
   ObjectInput inputObject;
   TaggedDocument td = null;
   try {
     inputObject =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(dir + id + ".ser")));
     try {
       td = (TaggedDocument) inputObject.readObject();
     } catch (ClassNotFoundException e) {
       td = null;
       Logger.logln("Couldn't load TaggedDocument: " + id + ", from: " + dir);
       e.printStackTrace();
     } finally {
       inputObject.close();
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
   if (printData == true && td != null) {
     System.out.println(td.toString());
   }
   return td;
 }
  /**
   * @param in Object input.
   * @return Read collection.
   * @throws IOException If failed.
   * @throws ClassNotFoundException If failed.
   */
  private Collection<Object> readFieldsCollection(ObjectInput in)
      throws IOException, ClassNotFoundException {
    assert fields;

    int size = in.readInt();

    if (size == -1) return null;

    Collection<Object> res = new ArrayList<>(size);

    for (int i = 0; i < size; i++) {
      int size0 = in.readInt();

      Collection<Object> col = new ArrayList<>(size0);

      for (int j = 0; j < size0; j++) col.add(in.readObject());

      assert col.size() == size0;

      res.add(col);
    }

    assert res.size() == size;

    return res;
  }
Example #26
0
 @SuppressWarnings("unchecked")
 private Map<String, IBean> loadMap() {
   if (m_file.exists()) {
     try (FileInputStream fin = new FileInputStream(m_file);
         ObjectInput oin = new ObjectInputStream(fin); ) {
       final Object o = oin.readObject();
       if (o instanceof Map) {
         final Map<?, ?> m = (Map<?, ?>) o;
         for (final Object o1 : m.keySet()) {
           if (!(o1 instanceof String)) {
             throw new Exception("Map is corrupt");
           }
         }
       } else {
         throw new Exception("File is corrupt");
       }
       // we know that the map has proper type key/value
       return (HashMap<String, IBean>) o;
     } catch (final Exception e) {
       // on error we delete the cache file, if we can
       m_file.delete();
       System.err.println("Serialization cache invalid: " + e.getMessage());
       ClientLogger.logQuietly(e);
     }
   }
   return new HashMap<>();
 }
Example #27
0
 @Override
 public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException {
   keyTypeClassName = input.readUTF();
   version = input.readInt();
   mergePoint = input.readInt();
   instanceCount = input.readInt();
 }
Example #28
0
 // ------------------------------------------------------------
 // Instance methods
 // ------------------------------------------------------------
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   super.readExternal(in);
   query = (QueryImpl) in.readObject();
   subrule = (GroupElement) in.readObject();
   subruleIndex = in.readInt();
   initDeclarations();
 }
Example #29
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 public void readExternal(final ObjectInput s) throws IOException, ClassNotFoundException {
   hashCode = s.readInt();
   key = (KEY) s.readObject();
   value = (VALUE) s.readObject();
   next = (Entry<KEY, VALUE>) s.readObject();
 }
Example #30
0
  /** Restores this <code>DataFlavor</code> from a Serialized state. */
  public synchronized void readExternal(ObjectInput is) throws IOException, ClassNotFoundException {
    String rcn = null;
    mimeType = (MimeType) is.readObject();

    if (mimeType != null) {
      humanPresentableName = mimeType.getParameter("humanPresentableName");
      mimeType.removeParameter("humanPresentableName");
      rcn = mimeType.getParameter("class");
      if (rcn == null) {
        throw new IOException("no class parameter specified in: " + mimeType);
      }
    }

    try {
      representationClass = (Class) is.readObject();
    } catch (OptionalDataException ode) {
      if (!ode.eof || ode.length != 0) {
        throw ode;
      }
      // Ensure backward compatibility.
      // Old versions didn't write the representation class to the stream.
      if (rcn != null) {
        representationClass = DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
      }
    }
  }