List of usage examples for java.io ObjectInputStream readInt
public int readInt() throws IOException
From source file:com.projity.pm.resource.EnterpriseResource.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject();/*from w w w. j av a 2 s .co m*/ hasKey = HasKeyImpl.deserialize(s, this); costRateTables = CostRateTables.deserialize(s); try { customFields = CustomFieldsImpl.deserialize(s); } catch (java.io.OptionalDataException e) { // to ensure compatibilty with old files customFields = new CustomFieldsImpl(); } hasAssignments = new HasAssignmentsImpl(); if (version >= 2) { hasAssignments.setSchedulingType(s.readInt()); hasAssignments.setEffortDriven(s.readBoolean()); availabilityTable = AvailabilityTable.deserialize(s); } else availabilityTable = new AvailabilityTable(null); version = DEFAULT_VERSION; }
From source file:org.bigtextml.topics.ParallelTopicModel.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt(); //This part needs to be re-written data = (TopicAssignmentBigMap) in.readObject(); alphabet = (BigAlphabet) in.readObject(); topicAlphabet = (BigLabelAlphabet) in.readObject(); numTopics = in.readInt();//from w w w . j a v a 2s. c o m topicMask = in.readInt(); topicBits = in.readInt(); numTypes = in.readInt(); alpha = (double[]) in.readObject(); alphaSum = in.readDouble(); beta = in.readDouble(); betaSum = in.readDouble(); typeTopicCounts = (int[][]) in.readObject(); tokensPerTopic = (int[]) in.readObject(); docLengthCounts = (int[]) in.readObject(); topicDocCounts = (int[][]) in.readObject(); numIterations = in.readInt(); burninPeriod = in.readInt(); saveSampleInterval = in.readInt(); optimizeInterval = in.readInt(); showTopicsInterval = in.readInt(); wordsPerTopic = in.readInt(); saveStateInterval = in.readInt(); stateFilename = (String) in.readObject(); saveModelInterval = in.readInt(); modelFilename = (String) in.readObject(); randomSeed = in.readInt(); formatter = (NumberFormat) in.readObject(); printLogLikelihood = in.readBoolean(); numThreads = in.readInt(); }
From source file:com.projity.pm.task.NormalTask.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject();//w w w . j av a2s . co m hasKey = HasKeyImpl.deserialize(s, this); customFields = CustomFieldsImpl.deserialize(s); if (version < 1) currentSchedule = TaskSchedule.deserialize(s); else { snapshots = new SnapshottableImpl(Settings.numBaselines()); int sCount = s.readInt(); for (int i = 0; i < sCount; i++) { int snapshotId = s.readInt(); TaskSnapshot snapshot = TaskSnapshot.deserialize(s, this); setSnapshot(new Integer(snapshotId), snapshot); } } if (version < 1) super.initializeTransientTaskObjects(); else super.initializeTransientTaskObjectsAfterDeserialization(); // barClosureInstance = new BarClosure(); // This shouldn't be called -hk 4/feb/05 // initializeDates(); version = DEFAULT_VERSION; }
From source file:CSSDFarm.UserInterface.java
private int loadUserData(String filePath) { //test load// w w w.jav a 2 s.co m ObjectInputStream instream = null; Integer loadedUserSettings = null; try { FileInputStream fileinput = new FileInputStream(filePath); instream = new ObjectInputStream(fileinput); boolean loop = true; try { loadedUserSettings = instream.readInt(); //set selected based on loaderUserSettings } catch (Exception ex) { //System.out.println("EX:" + ex); } } catch (IOException io) { //System.out.println(io); } if (instream != null) { try { instream.close(); } catch (IOException ex) { //System.out.println(ex); } } if (loadedUserSettings == null) { return 0; } else { return loadedUserSettings; } }
From source file:com.phoenixst.plexus.DefaultGraph.java
/** * Deserialize this <code>DefaultGraph</code>. * * @serialData the number of nodes (int), all the nodes, the * number of edges (int), all the edges. *//*from w w w .j a v a2 s. co m*/ private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { in.defaultReadObject(); observableDelegate = new ObservableGraphDelegate(this, EVENT_LOGGER); int nodeSize = in.readInt(); if (nodeSize < 0) { throw new InvalidObjectException("Node size is less than 0: " + nodeSize); } nodeMap = new HashMap(nodeSize); if (LOGGER.isInfoEnabled()) { LOGGER.info("Deserializing " + instanceString); } for (int i = 0; i < nodeSize; i++) { Object node = in.readObject(); if (nodeMap.containsKey(node)) { throw new InvalidObjectException("Duplicate node: " + node); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + " deserialization: Adding node " + node); } nodeMap.put(node, new AdjacencyList(node)); } edgeSize = in.readInt(); if (edgeSize < 0) { throw new InvalidObjectException("Edge size is less than 0: " + edgeSize); } for (int i = 0; i < edgeSize; i++) { Graph.Edge edge = (Graph.Edge) in.readObject(); AdjacencyList tailAdj = (AdjacencyList) nodeMap.get(edge.getTail()); if (tailAdj == null) { throw new InvalidObjectException("Graph.Edge tail is not a node: " + edge.getTail()); } if (tailAdj.contains(edge)) { throw new InvalidObjectException("Duplicate edge: " + edge); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + " deserialization: Adding edge " + edge); } tailAdj.edges.add(edge); if (!GraphUtils.equals(edge.getTail(), edge.getHead())) { AdjacencyList headAdj = (AdjacencyList) nodeMap.get(edge.getHead()); if (headAdj == null) { throw new InvalidObjectException("Graph.Edge head is not a node: " + edge.getHead()); } headAdj.edges.add(edge); } } }
From source file:org.domainmath.gui.MainFrame.java
private void createRootWindow() { viewMap.addView(0, fileTabView);//from w w w.j a v a2s. c o m viewMap.addView(1, pathsView); viewMap.addView(2, pkgView); viewMap.addView(3, consoleView); viewMap.addView(4, arrayEditorView); viewMap.addView(5, workspaceView); viewMap.addView(6, filesView); viewMap.addView(7, historyView); viewMap.addView(8, debuggerView); viewMap.addView(9, quickHelpView); MixedViewHandler handler = new MixedViewHandler(viewMap, new ViewSerializer() { @Override public void writeView(View view, ObjectOutputStream out) throws IOException { out.writeInt(((DynamicView) view).getId()); } @Override public View readView(ObjectInputStream in) throws IOException { return getDynamicView(in.readInt()); } }); rootWindow = DockingUtil.createRootWindow(viewMap, handler, true); properties.addSuperObject(currentTheme.getRootWindowProperties()); properties.addSuperObject(titleBarStyleProperties); rootWindow.getRootWindowProperties().addSuperObject(properties); rootWindow.getWindowBar(Direction.DOWN).setEnabled(true); rootWindow.addListener(new DockingWindowAdapter() { @Override public void windowAdded(DockingWindow addedToWindow, DockingWindow addedWindow) { updateViews(addedWindow, true); } @Override public void windowRemoved(DockingWindow removedFromWindow, DockingWindow removedWindow) { updateViews(removedWindow, false); } @Override public void windowClosing(DockingWindow window) throws OperationAbortedException { } @Override public void windowDocking(DockingWindow window) throws OperationAbortedException { } @Override public void windowUndocking(DockingWindow window) throws OperationAbortedException { } }); rootWindow.addTabMouseButtonListener(DockingWindowActionMouseButtonListener.MIDDLE_BUTTON_CLOSE_LISTENER); }
From source file:bftsmart.tom.core.TOMLayer.java
/** * This method is called by the MessageHandler each time it received messages related * to the leader change/*from w w w . j a v a 2s.c om*/ * @param msg Message received from the other replica */ public void deliverTimeoutRequest(LCMessage msg) { ByteArrayInputStream bis = null; ObjectInputStream ois = null; switch (msg.getType()) { case TOMUtil.STOP: // message STOP { // this message is for the next leader change? if (msg.getReg() == lcManager.getLastReg() + 1) { Logger.println("(TOMLayer.deliverTimeoutRequest) received regency change request"); try { // deserialize the content of the STOP message bis = new ByteArrayInputStream(msg.getPayload()); ois = new ObjectInputStream(bis); boolean hasReqs = ois.readBoolean(); clientsManager.getClientsLock().lock(); if (hasReqs) { // Store requests that the other replica did not manage to order //TODO: The requests have to be verified! byte[] temp = (byte[]) ois.readObject(); BatchReader batchReader = new BatchReader(temp, controller.getStaticConf().getUseSignatures() == 1); TOMMessage[] requests = batchReader.deserialiseRequests(controller); } clientsManager.getClientsLock().unlock(); ois.close(); bis.close(); } catch (IOException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex); } // store information about the message STOP lcManager.addStop(msg.getReg(), msg.getSender()); evaluateStops(msg.getReg()); // evaluate STOP messages } } break; case TOMUtil.STOPDATA: { // STOPDATA messages int regency = msg.getReg(); // Am I the new leader, and am I expecting this messages? if (regency == lcManager.getLastReg() && this.controller.getStaticConf().getProcessId() == lm .getCurrentLeader()/*(regency % this.reconfManager.getCurrentViewN())*/) { Logger.println("(TOMLayer.deliverTimeoutRequest) I'm the new leader and I received a STOPDATA"); //TODO: It is necessary to verify the proof of the last decided consensus and the signature of the state of the current consensus! LastEidData lastData = null; SignedObject signedCollect = null; int last = -1; byte[] lastValue = null; Set<PaxosMessage> proof = null; try { // deserialize the content of the message bis = new ByteArrayInputStream(msg.getPayload()); ois = new ObjectInputStream(bis); if (ois.readBoolean()) { // content of the last decided eid last = ois.readInt(); lastValue = (byte[]) ois.readObject(); proof = (Set<PaxosMessage>) ois.readObject(); //TODO: Proof is missing! } lastData = new LastEidData(msg.getSender(), last, lastValue, proof); lcManager.addLastEid(regency, lastData); // conteudo do eid a executar signedCollect = (SignedObject) ois.readObject(); ois.close(); bis.close(); lcManager.addCollect(regency, signedCollect); int bizantineQuorum = (controller.getCurrentViewN() + controller.getCurrentViewF()) / 2; int cftQuorum = (controller.getCurrentViewN()) / 2; // I already got messages from a Byzantine/Crash quorum, // related to the last eid as well as for the current? boolean conditionBFT = (controller.getStaticConf().isBFT() && lcManager.getLastEidsSize(regency) > bizantineQuorum && lcManager.getCollectsSize(regency) > bizantineQuorum); boolean conditionCFT = (lcManager.getLastEidsSize(regency) > cftQuorum && lcManager.getCollectsSize(regency) > cftQuorum); if (conditionBFT || conditionCFT) catch_up(regency); } catch (IOException ex) { ex.printStackTrace(System.err); } catch (ClassNotFoundException ex) { ex.printStackTrace(System.err); } } } break; case TOMUtil.SYNC: // message SYNC { int regency = msg.getReg(); // I am waiting for this message, and I received it from the new leader? if (msg.getReg() == lcManager.getLastReg() && msg.getReg() == lcManager.getNextReg() && msg .getSender() == lm.getCurrentLeader()/*(regency % this.reconfManager.getCurrentViewN())*/) { LastEidData lastHighestEid = null; int currentEid = -1; HashSet<SignedObject> signedCollects = null; byte[] propose = null; int batchSize = -1; try { // deserialization of the message content bis = new ByteArrayInputStream(msg.getPayload()); ois = new ObjectInputStream(bis); lastHighestEid = (LastEidData) ois.readObject(); currentEid = ois.readInt(); signedCollects = (HashSet<SignedObject>) ois.readObject(); propose = (byte[]) ois.readObject(); batchSize = ois.readInt(); lcManager.setCollects(regency, signedCollects); // Is the predicate "sound" true? Is the certificate for LastEid valid? if (lcManager.sound(lcManager.selectCollects(regency, currentEid)) && (!controller.getStaticConf().isBFT() || lcManager.hasValidProof(lastHighestEid))) { finalise(regency, lastHighestEid, currentEid, signedCollects, propose, batchSize, false); } ois.close(); bis.close(); } catch (IOException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { ex.printStackTrace(); java.util.logging.Logger.getLogger(TOMLayer.class.getName()).log(Level.SEVERE, null, ex); } } } break; } }