List of usage examples for java.io ObjectInputStream readBoolean
public boolean readBoolean() throws IOException
From source file:org.hibernate.internal.SessionFactoryImpl.java
/** * Custom deserialization hook used during Session deserialization. * /* w w w. j a v a 2 s .c om*/ * @param ois * The stream from which to "read" the factory * @return The deserialized factory * @throws IOException * indicates problems reading back serial data stream * @throws ClassNotFoundException * indicates problems reading back serial data stream */ static SessionFactoryImpl deserialize(ObjectInputStream ois) throws IOException, ClassNotFoundException { LOG.trace("Deserializing SessionFactory from Session"); final String uuid = ois.readUTF(); boolean isNamed = ois.readBoolean(); final String name = isNamed ? ois.readUTF() : null; return (SessionFactoryImpl) locateSessionFactoryOnDeserialization(uuid, name); }
From source file:com.sworddance.util.perf.LapTimer.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { boolean restart = in.readBoolean(); in.defaultReadObject();/*from w w w. jav a 2s . c o m*/ this.hopCount++; if (restart) { this.cont(); //TODO do we continue? this.endLap(); //("EndXMIT"); } }
From source file:bftsmart.tom.core.Synchronizer.java
private void processSTOPDATA(LCMessage msg, int regency) { //TODO: It is necessary to verify the proof of the last decided consensus and the signature of the state of the current consensus! CertifiedDecision lastData = null;/*from ww w . jav a 2 s.com*/ SignedObject signedCollect = null; int last = -1; byte[] lastValue = null; Set<ConsensusMessage> proof = null; ByteArrayInputStream bis; ObjectInputStream ois; try { // deserialize the content of the message bis = new ByteArrayInputStream(msg.getPayload()); ois = new ObjectInputStream(bis); if (ois.readBoolean()) { // content of the last decided cid last = ois.readInt(); lastValue = (byte[]) ois.readObject(); proof = (Set<ConsensusMessage>) ois.readObject(); //TODO: Proof is missing! } lastData = new CertifiedDecision(msg.getSender(), last, lastValue, proof); lcManager.addLastCID(regency, lastData); signedCollect = (SignedObject) ois.readObject(); ois.close(); bis.close(); lcManager.addCollect(regency, signedCollect); int bizantineQuorum = (controller.getCurrentViewN() + controller.getCurrentViewF()) / 2; int cftQuorum = (controller.getCurrentViewN()) / 2; // Did I already got messages from a Byzantine/Crash quorum, // related to the last cid as well as for the current? boolean conditionBFT = (controller.getStaticConf().isBFT() && lcManager.getLastCIDsSize(regency) > bizantineQuorum && lcManager.getCollectsSize(regency) > bizantineQuorum); boolean conditionCFT = (lcManager.getLastCIDsSize(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); } }
From source file:bftsmart.tom.core.Synchronizer.java
private TOMMessage[] deserializeTOMMessages(byte[] playload) { ByteArrayInputStream bis;// ww w .j a v a 2s . com ObjectInputStream ois; TOMMessage[] requests = null; try { // deserialize the content of the STOP message bis = new ByteArrayInputStream(playload); ois = new ObjectInputStream(bis); boolean hasReqs = ois.readBoolean(); 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); requests = batchReader.deserialiseRequests(controller); } 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); } return requests; }
From source file:idontwant2see.IDontWant2See.java
public void readData(final ObjectInputStream in) throws IOException, ClassNotFoundException { final int version = in.readInt(); // read Version int n = in.readInt(); if (version <= 2) { for (int i = 0; i < n; i++) { final StringBuilder value = new StringBuilder("*"); value.append(in.readUTF()).append("*"); mSettings.getSearchList().add(new IDontWant2SeeListEntry(value.toString(), false)); }/*from w ww . jav a 2 s . co m*/ if (version == 2) { n = in.readInt(); for (int i = 0; i < n; i++) { mSettings.getSearchList().add(new IDontWant2SeeListEntry(in.readUTF(), true)); } mSettings.setSimpleMenu(false); } } else { for (int i = 0; i < n; i++) { mSettings.getSearchList().add(new IDontWant2SeeListEntry(in, version)); } mSettings.setSimpleMenu(in.readBoolean()); if (version >= 4) { mSettings.setSwitchToMyFilter(in.readBoolean()); } if (version >= 5) { mSettings.setLastEnteredExclusionString(in.readUTF()); } if (version >= 6) { mSettings.setLastUsedDate(Date.readData(in)); } if (version >= 7) { mSettings.setProgramImportance(in.readByte()); } else { mSettings.setProgramImportance(Program.DEFAULT_PROGRAM_IMPORTANCE); } } }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java
public void init() { maxCluster = state.growingLayer.getXSize() * state.growingLayer.getYSize(); spinnerNoCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerNoCluster.addChangeListener(new ChangeListener() { @Override/*from w w w.j a v a 2s .co m*/ public void stateChanged(ChangeEvent e) { numClusters = (Integer) ((JSpinner) e.getSource()).getValue(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { st = m.get(numClusters).sticky; } else { st = false; } sticky.setSelected(st); redrawClustering(); } }); JPanel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); sticky.setToolTipText( "Marks this number of clusters as sticky for a certain leve; the next set of clusters will have a smaller boundary"); sticky.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { st = sticky.isSelected(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { ClusterElementsStorage c = m.get(numClusters); c.sticky = st; // System.out.println("test"); // ((ClusterElementsStorageNode)m.get(numClusters)).sticky = st; redrawClustering(); } } }); colorCluster = new JCheckBox("colour", state.colorClusters); colorCluster.setToolTipText("Fill the clusters in colours"); colorCluster.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.colorClusters = colorCluster.isSelected(); // TODO: Palette anzeigen (?) redrawClustering(); } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerNoCluster, sticky, colorCluster); getContentPane().add(clusterPanel, c.nextRow()); dendogramPanel = UiUtils.makeBorderedPanel(new GridLayout(0, 1), "Dendogram"); getContentPane().add(dendogramPanel, c.nextRow()); JPanel numLabelPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Labels"); GridBagConstraintsIFS gcLabels = new GridBagConstraintsIFS(); labelSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1)); labelSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { numLabels = (Integer) ((JSpinner) e.getSource()).getValue(); state.clusterWithLabels = numLabels; redrawClustering(); } }); this.showValues = new JCheckBox("values", state.labelsWithValues); this.showValues.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.labelsWithValues = showValues.isSelected(); redrawClustering(); } }); int start = new Double((1 - state.clusterByValue) * 100).intValue(); valueQe = new JSlider(0, 100, start); valueQe.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int byValue = ((JSlider) e.getSource()).getValue(); state.clusterByValue = 1 - byValue / 100; redrawClustering(); } }); numLabelPanel.add(new JLabel("# Labels"), gcLabels); numLabelPanel.add(labelSpinner, gcLabels.nextCol()); numLabelPanel.add(showValues, gcLabels.nextCol()); numLabelPanel.add(valueQe, gcLabels.nextRow().setGridWidth(3).setFill(GridBagConstraints.HORIZONTAL)); getContentPane().add(numLabelPanel, c.nextRow()); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(0, new JLabel("by Value")); labelTable.put(100, new JLabel("by Qe")); valueQe.setToolTipText("Method how to select representative labels - by QE, or the attribute values"); valueQe.setLabelTable(labelTable); valueQe.setPaintLabels(true); final JComboBox initialisationBox = new JComboBox(KMeans.InitType.values()); initialisationBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object o = mapPane.getMap().getClusteringTreeBuilder(); if (o instanceof KMeansTreeBuilder) { ((KMeansTreeBuilder) o).reInit((KMeans.InitType) initialisationBox.getSelectedItem()); // FIXME: is this call needed? mapPane.getMap().getCurrentClusteringTree().getAllClusteringElements(); redrawClustering(); } } }); getContentPane().add(UiUtils.fillPanel(kmeansInitialisationPanel, new JLabel("k-Means initialisation"), initialisationBox), c.nextRow()); JPanel borderPanel = new TitledCollapsiblePanel("Border", new GridLayout(1, 4), true); JSpinner borderSpinner = new JSpinner( new SpinnerNumberModel(ClusteringTree.INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR, 0.1, 5, 0.1)); borderSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { state.clusterBorderWidthMagnificationFactor = ((Double) ((JSpinner) e.getSource()).getValue()) .floatValue(); redrawClustering(); } }); borderPanel.add(new JLabel("width")); borderPanel.add(borderSpinner); borderPanel.add(new JLabel("colour")); buttonColour = new JButton(""); buttonColour.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new ClusterBoderColorChooser(state.parentFrame, state.clusterBorderColour, ClusteringControl.this); } }); buttonColour.setBackground(state.clusterBorderColour); borderPanel.add(buttonColour); getContentPane().add(borderPanel, c.nextRow()); JPanel evaluationPanel = new TitledCollapsiblePanel("Cluster Evaluation", new GridLayout(3, 2), true); evaluationPanel.add(new JLabel("quality measure")); qualityMeasureButton = new JButton(); qualityMeasureButton.setText("ent/pur calc"); qualityMeasureButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("doing entropy here"); ClusteringTree clusteringTree = state.mapPNode.getClusteringTree(); if (clusteringTree == null) { // we have not clustered yet return; } // System.out.println(clusteringTree.getChildrenCount()); // FIXME put this in a method and call it on numcluster.change() SOMLibClassInformation classInfo = state.inputDataObjects.getClassInfo(); ArrayList<ClusterNode> clusters = clusteringTree.getNodesAtLevel(numClusters); System.out.println(clusters.size()); // EntropyMeasure.computeEntropy(clusters, classInfo); EntropyAndPurityCalculator eapc = new EntropyAndPurityCalculator(clusters, classInfo); // FIXME round first entropyLabel.setText(String.valueOf(eapc.getEntropy())); purityLabel.setText(String.valueOf(eapc.getPurity())); } }); evaluationPanel.add(qualityMeasureButton); GridBagConstraintsIFS gcEval = new GridBagConstraintsIFS(); evaluationPanel.add(new JLabel("entropy"), gcEval); evaluationPanel.add(new JLabel("purity"), gcEval.nextCol()); entropyLabel = new JLabel("n/a"); purityLabel = new JLabel("n/a"); evaluationPanel.add(entropyLabel, gcEval.nextRow()); evaluationPanel.add(purityLabel, gcEval.nextCol()); getContentPane().add(evaluationPanel, c.nextRow()); JPanel panelButtons = new JPanel(new GridLayout(1, 4)); JButton saveButton = new JButton("Save"); saveButton.setFont(smallFont); saveButton.setMargin(SMALL_INSETS); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser; if (state.fileChooser.getSelectedFile() != null) { fileChooser = new JFileChooser(state.fileChooser.getSelectedFile().getPath()); } else { fileChooser = new JFileChooser(); } fileChooser.addChoosableFileFilter(clusteringFilter); fileChooser.addChoosableFileFilter(xmlFilter); File filePath = ExportUtils.getFilePath(ClusteringControl.this, fileChooser, "Save Clustering and Labels"); if (filePath != null) { if (xmlFilter.accept(filePath)) { LabelXmlUtils.saveLabelsToFile(state.mapPNode, filePath); } else { try { FileOutputStream fos = new FileOutputStream(filePath); GZIPOutputStream gzipOs = new GZIPOutputStream(fos); PObjectOutputStream oos = new PObjectOutputStream(gzipOs); oos.writeObjectTree(mapPane.getMap().getCurrentClusteringTree()); oos.writeObjectTree(mapPane.getMap().getManualLabels()); oos.writeInt(state.clusterWithLabels); oos.writeBoolean(state.labelsWithValues); oos.writeDouble(state.clusterByValue); oos.writeObject(spinnerNoCluster.getValue()); oos.close(); } catch (Exception ex) { ex.printStackTrace(); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(saveButton); JButton loadButton = new JButton("Load"); loadButton.setFont(smallFont); loadButton.setMargin(SMALL_INSETS); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = getFileChooser(); fileChooser.setName("Open Clustering"); fileChooser.addChoosableFileFilter(xmlFilter); fileChooser.addChoosableFileFilter(clusteringFilter); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Open"); if (returnVal == JFileChooser.APPROVE_OPTION) { File filePath = fileChooser.getSelectedFile(); if (xmlFilter.accept(filePath)) { PNode restoredLabels = null; try { restoredLabels = LabelXmlUtils.restoreLabelsFromFile(fileChooser.getSelectedFile()); PNode manual = state.mapPNode.getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = restoredLabels.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } manual.addChildren(tmp); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Successfully loaded cluster labels."); } catch (Exception e1) { e1.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading cluster labels: " + e1.getMessage()); } } else { try { FileInputStream fis = new FileInputStream(filePath); GZIPInputStream gzipIs = new GZIPInputStream(fis); ObjectInputStream ois = new ObjectInputStream(gzipIs); ClusteringTree tree = (ClusteringTree) ois.readObject(); PNode manual = (PNode) ois.readObject(); PNode all = mapPane.getMap().getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = manual.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } all.addChildren(tmp); state.clusterWithLabels = ois.readInt(); labelSpinner.setValue(state.clusterWithLabels); state.labelsWithValues = ois.readBoolean(); showValues.setSelected(state.labelsWithValues); state.clusterByValue = ois.readDouble(); valueQe.setValue(new Double((1 - state.clusterByValue) * 100).intValue()); mapPane.getMap().buildTree(tree); spinnerNoCluster.setValue(ois.readObject()); ois.close(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Successfully loaded clustering."); } catch (Exception ex) { ex.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading clustering: " + ex.getMessage()); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(loadButton); JButton exportImages = new JButton("Export"); exportImages.setFont(smallFont); exportImages.setMargin(SMALL_INSETS); exportImages.setToolTipText("Export labels as images (not yet working)"); exportImages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); if (CommonSOMViewerStateData.fileNamePrefix != null && !CommonSOMViewerStateData.fileNamePrefix.equals("")) { fileChooser.setCurrentDirectory(new File(CommonSOMViewerStateData.fileNamePrefix)); } else { fileChooser.setCurrentDirectory(state.getFileChooser().getCurrentDirectory()); } fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } fileChooser.setName("Choose path"); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Choose path"); if (returnVal == JFileChooser.APPROVE_OPTION) { // save images String path = fileChooser.getSelectedFile().getAbsolutePath(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Writing label images to " + path); } } }); panelButtons.add(exportImages); JButton deleteManual = new JButton("Delete"); deleteManual.setFont(smallFont); deleteManual.setMargin(SMALL_INSETS); deleteManual.setToolTipText("Delete manually added labels."); deleteManual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.mapPNode.getManualLabels().removeAllChildren(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Manual Labels deleted."); } }); panelButtons.add(deleteManual); c.anchor = GridBagConstraints.NORTH; this.getContentPane().add(panelButtons, c.nextRow()); this.setVisible(true); }
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/* w w w. ja va 2s . co m*/ * @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; } }
From source file:com.projity.pm.resource.EnterpriseResource.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject();/*from w w w . j a v a2s . c o 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:hudson.FilePath.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { Channel channel = Channel.current(); assert channel != null; ois.defaultReadObject();/*from ww w . ja v a 2 s .c o m*/ if (ois.readBoolean()) { this.channel = channel; } else { this.channel = null; } }
From source file:gate.annotation.AnnotationSetImpl.java
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { this.longestAnnot = 0l; ObjectInputStream.GetField gf = in.readFields(); this.name = (String) gf.get("name", null); this.doc = (DocumentImpl) gf.get("doc", null); boolean isIndexedByType = false; boolean isIndexedByStartNode = false; this.annotations = (Annotation[]) gf.get("annotations", null); if (this.annotations == null) { // old style serialised version @SuppressWarnings("unchecked") Map<Integer, Annotation> annotsByIdMap = (Map<Integer, Annotation>) gf.get("annotsById", null); if (annotsByIdMap == null) throw new IOException( "Invalid serialised data: neither annotations array or map by id" + " are present."); annotations = annotsByIdMap.values().toArray(new Annotation[] {}); } else {/* w w w. java 2s .c o m*/ // new style serialised version isIndexedByType = in.readBoolean(); isIndexedByStartNode = in.readBoolean(); } // this.name = (String)in.readObject(); // this.doc = (DocumentImpl)in.readObject(); // Annotation[] annotations = (Annotation[])in.readObject(); // do we need to create the indices? // boolean isIndexedByType = in.readBoolean(); // boolean isIndexedByStartNode = in.readBoolean(); this.annotsById = new HashMap<Integer, Annotation>(annotations.length); // rebuilds the indices if required if (isIndexedByType) { annotsByType = new HashMap<String, AnnotationSet>(Gate.HASH_STH_SIZE); } if (isIndexedByStartNode) { nodesByOffset = new RBTreeMap<Long, Node>(); annotsByStartNode = new HashMap<Integer, Object>(annotations.length); } // add all the annotations one by one for (int i = 0; i < annotations.length; i++) { add(annotations[i]); } annotations = null; }