Package java.io

Examples of java.io.ObjectInputStream$ValidationList


    byte opt = buf[pos++];

    if (opt != Message.NULL) {
      // Reads notification object
      ObjectInputStream ois = null;
      if (compressedFlows) {
        readFully(4);
        int length = readInt();
       
        if (getLogger().isLoggable(BasicLevel.DEBUG))
          getLogger().log(BasicLevel.DEBUG, "readMessage - length=" + length);
       
        byte[] buf = new byte[length];
        int n = 0;
        do {
          int count = read(buf, n, length - n);
          if (count < 0) throw new EOFException();
          n += count;
        } while (n < length);
        ois = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(buf)));
      } else {
        ois = new ObjectInputStream(this);
      }
     
      if (getLogger().isLoggable(BasicLevel.DEBUG))
        getLogger().log(BasicLevel.DEBUG, "readMessage - 2");

      msg.not = (Notification) ois.readObject();
     
      if (getLogger().isLoggable(BasicLevel.DEBUG))
        getLogger().log(BasicLevel.DEBUG, "readMessage - 3");
     
      if (msg.not.expiration > 0)
View Full Code Here


  public void react(AgentId from, Notification not) throws Exception {
    if (not instanceof AgentCreateRequest) {
      AgentCreateRequest cnot = (AgentCreateRequest) not;
      try {
        // Restore the new agent state.
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(cnot.agentState, 0,
            cnot.agentState.length));
        Agent ag = (Agent) ois.readObject();
        try {
          ois.close();
        } catch (IOException exc) {}

        // Initializes and creates the agent
        // TODO: (ThreadEngine) Thread.currentThread() ...
        AgentServer.engine.createAgent(cnot.deploy, ag);
View Full Code Here

      }
     
      FileInputStream fis = null;
      try {
        fis = new FileInputStream(cfgFile);
        ObjectInputStream ois = new ObjectInputStream(fis);
        a3config = (A3CMLConfig) ois.readObject();
      } catch (Exception exc) {
        Log.logger.log(BasicLevel.WARN, "Can't load configuration: " + path, exc);
      } finally {
        if (fis != null) fis.close();
      }

      if (Log.logger.isLoggable(BasicLevel.DEBUG))
        Log.logger.log(BasicLevel.DEBUG,
                       "Config.load : a3cmlconfig = " + a3config);
      return a3config;
    }

    //search a3config in path used to load classes.
    ClassLoader classLoader = null;
    InputStream is = null;
    try {
      classLoader = A3CMLConfig.class.getClassLoader();
      if (classLoader != null) {
        Log.logger.log(BasicLevel.WARN,
                       "Trying to find [" + path + "] using " +
                       classLoader + " class loader.");
        is = classLoader.getResourceAsStream(path);
      }
    } catch(Throwable t) {
      Log.logger.log(BasicLevel.WARN,
                     "Can't find [" + path + "] using " +
                     classLoader + " class loader.", t);
      is = null;
    }
    if (is == null) {
      // Last ditch attempt: get the resource from the system class path.
      Log.logger.log(BasicLevel.WARN,
                     "Trying to find serialized config using ClassLoader.getSystemResource().");
      is = ClassLoader.getSystemResourceAsStream(path);
    }
    if (is != null) {
      ObjectInputStream ois = new ObjectInputStream(is);
      a3config = (A3CMLConfig) ois.readObject();
    }

    if (a3config == null) {
      Log.logger.log(BasicLevel.WARN,
                     "Unable to find configuration file: " + path);
View Full Code Here

   */
  public final Object load(String dirName, String name) throws IOException, ClassNotFoundException {
    byte[] buf = loadByteArray(dirName, name);
    if (buf != null) {
      ByteArrayInputStream bis = new ByteArrayInputStream(buf);
      ObjectInputStream ois = new ObjectInputStream(bis);
      try {
        return ois.readObject();
      } finally {
        ois.close();
        bis.close();
      }
    }
   
    return null;
View Full Code Here

 
  public final Object load(String dirName, String name) throws IOException, ClassNotFoundException {
    byte[] buf = loadByteArray(dirName, name);
    if (buf != null) {
      ByteArrayInputStream bis = new ByteArrayInputStream(buf);
      ObjectInputStream ois = new ObjectInputStream(bis);
      try {
        return ois.readObject();
      } finally {
        ois.close();
        bis.close();
      }
    }
   
    return null;
View Full Code Here

    }
  } else {
  if (selected.getName().endsWith(".gz")) {
    is = new GZIPInputStream(is);
  }
  ObjectInputStream objectInputStream = new ObjectInputStream(is);
  classifier = (Classifier) objectInputStream.readObject();
  try { // see if we can load the header
    trainHeader = (Instances) objectInputStream.readObject();
  } catch (Exception e) {} // don't fuss if we can't
  objectInputStream.close();
  }
      } catch (Exception e) {
 
  JOptionPane.showMessageDialog(null, e, "Load Failed",
              JOptionPane.ERROR_MESSAGE);
View Full Code Here

        final int len = s.readInt();
        final byte[] b = new byte[len];
        s.readFully(b, 0, len);

        FastByteArrayInputStream bis = new FastByteArrayInputStream(b);
        ObjectInputStream ois = new ObjectInputStream(bis);
        this._bodyExpr = (XQExpression) ois.readObject();
        this._bindingVar = (BindingVariable) ois.readObject();

        this._exprBytes = b;
    }
View Full Code Here

        out.close();

        final byte[] b = f.toByteArray();

        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ObjectInputStream oin = new ObjectInputStream(in);

        Assert.assertEquals(student1, oin.readObject());
        Assert.assertEquals(5, oin.readInt());
        Assert.assertEquals(student2, oin.readObject());

        oin.close();
    }
View Full Code Here

        byte[] b2 = out2.toByteArray();
        out.writeInt(b2.length);
        out.write(b2);

        FastByteArrayInputStream bis3 = new FastByteArrayInputStream(b2);
        ObjectInputStream ois3 = new ObjectInputStream(bis3);
        Assert.assertEquals(student2, ois3.readObject());
        Assert.assertEquals(student3, ois3.readObject());

        out.close();

        final byte[] b = f.toByteArray();
        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ObjectInputStream oin = new ObjectInputStream(in);

        Assert.assertEquals(student1, oin.readObject());
        Assert.assertEquals(5, oin.readInt());

        int size3 = oin.readInt();
        byte[] b3 = new byte[size3];
        oin.read(b3);
        ArrayAssert.assertEquals(b2, b3);

        FastByteArrayInputStream bis4 = new FastByteArrayInputStream(b3);
        ObjectInputStream ois4 = new ObjectInputStream(bis4);
        Assert.assertEquals(student2, ois4.readObject());
        Assert.assertEquals(student3, ois4.readObject());

        oin.close();
    }
View Full Code Here

        PlaceHolder holder1 = new PlaceHolder();
        out.writeObject(holder1);
        out.flush();

        FastByteArrayInputStream bis = new FastByteArrayInputStream(f.getInternalArray(), 0, f.size());
        ObjectInputStream ois = new ObjectInputStream(bis);
        Assert.assertEquals(holder1, ois.readObject());
    }
View Full Code Here

TOP

Related Classes of java.io.ObjectInputStream$ValidationList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.