List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.WebApplicationContext.java
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException { setContextPath((String) in.readObject()); setVirtualHosts((String[]) in.readObject()); Object o = in.readObject();/* w ww . j a v a 2 s . c o m*/ while (o instanceof HttpHandler) { addHandler((HttpHandler) o); o = in.readObject(); } setAttributes((Map) o); setRedirectNullPath(in.readBoolean()); setMaxCachedFileSize(in.readInt()); setMaxCacheSize(in.readInt()); setStatsOn(in.readBoolean()); setPermissions((PermissionCollection) in.readObject()); setClassLoaderJava2Compliant(in.readBoolean()); _defaultsDescriptor = (String) in.readObject(); _war = (String) in.readObject(); _extract = in.readBoolean(); _ignorewebjetty = in.readBoolean(); _distributable = in.readBoolean(); _configurationClassNames = (String[]) in.readObject(); }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void loadParameters(File file) { ObjectInput input = null; try {/*from w w w . ja v a 2 s . c o m*/ input = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file))); @SuppressWarnings("unchecked") Set<AttributeParameters> parameters = (Set<AttributeParameters>) input.readObject(); if (!rawDataTreeModel.checkParametersConsistent(parameters)) { error("Loaded parameters are not consistent with current loaded dataset"); return; } parametersTableModel.loadParameters(parameters); LOG.debug("Read parameters from file " + file.getAbsolutePath()); } catch (Exception ex) { error("Error reading parameters from file."); ex.printStackTrace(); } finally { try { input.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.t2framework.commons.util.ArrayMap.java
@SuppressWarnings("unchecked") public final void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {/*w w w.ja v a2s. c o m*/ int num = in.readInt(); mapTable = new Entry[num]; listTable = new Entry[num]; threshold = (int) (num * LOAD_FACTOR); int size = in.readInt(); for (int i = 0; i < size; i++) { K key = (K) in.readObject(); V value = (V) in.readObject(); put(key, value); } }
From source file:com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo.java
@SuppressWarnings("unchecked") @Override//w w w . j a v a 2s . c o m public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); if (version != 1) { throw new IOException("Invalid version: " + version); } this.id = in.readInt(); this.packageId = in.readInt(); this.name = ExternalizableUtils.readUTF(in); this.version = ExternalizableUtils.readUTF(in); this.release = ExternalizableUtils.readUTF(in); this.completionTime = (Date) in.readObject(); this.creationTime = (Date) in.readObject(); this.nvr = ExternalizableUtils.readUTF(in); this.taskId = (Integer) in.readObject(); this.ownerId = (Integer) in.readObject(); this.ownerName = ExternalizableUtils.readUTF(in); this.buildState = (KojiBuildState) in.readObject(); this.creationEventId = (Integer) in.readObject(); this.mavenGroupId = ExternalizableUtils.readUTF(in); this.mavenArtifactId = ExternalizableUtils.readUTF(in); this.mavenVersion = ExternalizableUtils.readUTF(in); this.platform = ExternalizableUtils.readUTF(in); this.extra = (Map<String, Object>) in.readObject(); this.source = ExternalizableUtils.readUTF(in); // XXX: This has @JsonIgnore this.typeNames = (List<String>) in.readObject(); this.volumeName = ExternalizableUtils.readUTF(in); }
From source file:com.inmobi.grill.driver.hive.HiveDriver.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { synchronized (hiveHandles) { int numHiveHnadles = in.readInt(); for (int i = 0; i < numHiveHnadles; i++) { QueryHandle qhandle = (QueryHandle) in.readObject(); OperationHandle opHandle = new OperationHandle((TOperationHandle) in.readObject()); hiveHandles.put(qhandle, opHandle); LOG.debug("Hive driver recovered " + qhandle + ":" + opHandle); }// w w w. ja v a 2 s . c o m LOG.info("HiveDriver recovered " + hiveHandles.size() + " queries"); int numSessions = in.readInt(); for (int i = 0; i < numSessions; i++) { String grillId = in.readUTF(); SessionHandle sHandle = new SessionHandle((TSessionHandle) in.readObject(), TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6); grillToHiveSession.put(grillId, sHandle); } LOG.info("HiveDriver recovered " + grillToHiveSession.size() + " sessions"); } }
From source file:gridool.db.DBInsertOperation.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); this.createTableDDL = IOUtils.readString(in); this.tableName = IOUtils.readString(in); final int numFields = in.readInt(); final String[] fn; if (numFields == 0) { fn = null;/*from w w w . j a v a2 s .co m*/ } else { fn = new String[numFields]; for (int i = 0; i < numFields; i++) { fn[i] = IOUtils.readString(in); } } this.fieldNames = fn; final int numRecords = in.readInt(); final DBRecord[] r = new DBRecord[numRecords]; for (int i = 0; i < numRecords; i++) { r[i] = (DBRecord) in.readObject(); } this.records = r; }
From source file:org.apache.shindig.gadgets.http.HttpResponse.java
/** * Expected layout:/*from w w w .ja va 2s .c o m*/ * * int - status code * Map<String, List<String>> - headers * int - length of body * byte array - body, of previously specified length */ @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { httpStatusCode = in.readInt(); // We store the multimap as a Map<String,List<String>> to insulate us from google-collections API churn // And to remain backwards compatible Map<String, List<String>> headerCopyMap = (Map<String, List<String>>) in.readObject(); Multimap headerCopy = newHeaderMultimap(); for (Map.Entry<String, List<String>> entry : headerCopyMap.entrySet()) { headerCopy.putAll(entry.getKey(), entry.getValue()); } int bodyLength = in.readInt(); responseBytes = new byte[bodyLength]; int cnt, offset = 0; while ((cnt = in.read(responseBytes, offset, bodyLength)) > 0) { offset += cnt; bodyLength -= cnt; } if (offset != responseBytes.length) { throw new IOException( "Invalid body! Expected length = " + responseBytes.length + ", bytes readed = " + offset + '.'); } date = getAndUpdateDate(headerCopy); encoding = getAndUpdateEncoding(headerCopy, responseBytes); headers = Multimaps.unmodifiableMultimap(headerCopy); metadata = Collections.emptyMap(); }
From source file:com.splicemachine.derby.impl.sql.execute.operations.SpliceBaseOperation.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.optimizerEstimatedCost = in.readDouble(); this.optimizerEstimatedRowCount = in.readDouble(); this.operationInformation = (OperationInformation) in.readObject(); isTopResultSet = in.readBoolean();/*w ww . j a v a 2s . c o m*/ }
From source file:BeanContainer.java
protected JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); //from w w w .j ava 2 s . co m JMenu mFile = new JMenu("File"); JMenuItem mItem = new JMenuItem("New..."); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { String result = (String)JOptionPane.showInputDialog( BeanContainer.this, "Please enter class name to create a new bean", "Input", JOptionPane.INFORMATION_MESSAGE, null, null, m_className); repaint(); if (result==null) return; try { m_className = result; Class cls = Class.forName(result); Object obj = cls.newInstance(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Load..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { m_chooser.setCurrentDirectory(m_currentDir); m_chooser.setDialogTitle( "Please select file with serialized bean"); int result = m_chooser.showOpenDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileInputStream fStream = new FileInputStream(fChoosen); ObjectInput stream = new ObjectInputStream(fStream); Object obj = stream.readObject(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } stream.close(); fStream.close(); validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } repaint(); } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Save..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { if (m_activeBean == null) return; m_chooser.setDialogTitle( "Please choose file to serialize bean"); m_chooser.setCurrentDirectory(m_currentDir); int result = m_chooser.showSaveDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileOutputStream fStream = new FileOutputStream(fChoosen); ObjectOutput stream = new ObjectOutputStream(fStream); stream.writeObject(m_activeBean); stream.close(); fStream.close(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mFile.addSeparator(); mItem = new JMenuItem("Exit"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; mItem.addActionListener(lst); mFile.add(mItem); menuBar.add(mFile); JMenu mEdit = new JMenu("Edit"); mItem = new JMenuItem("Delete"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.dispose(); m_editors.remove(m_activeBean); } getContentPane().remove(m_activeBean); m_activeBean = null; validate(); repaint(); } }; mItem.addActionListener(lst); mEdit.add(mItem); mItem = new JMenuItem("Properties..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.setVisible(true); editor.toFront(); } else { BeanEditor editor = new BeanEditor(m_activeBean); m_editors.put(m_activeBean, editor); } } }; mItem.addActionListener(lst); mEdit.add(mItem); menuBar.add(mEdit); JMenu mLayout = new JMenu("Layout"); ButtonGroup group = new ButtonGroup(); mItem = new JRadioButtonMenuItem("FlowLayout"); mItem.setSelected(true); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ getContentPane().setLayout(new FlowLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("GridLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ int col = 3; int row = (int)Math.ceil(getContentPane(). getComponentCount()/(double)col); getContentPane().setLayout(new GridLayout(row, col, 10, 10)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - X"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.X_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - Y"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.Y_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("DialogLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new DialogLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); menuBar.add(mLayout); return menuBar; }
From source file:org.openfaces.component.table.TableDataModel.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { sortingRules = (List<SortingRule>) in.readObject(); rowKeyExpression = ValueBindings.readValueExpression(in); rowDataByKeyExpression = ValueBindings.readValueExpression(in); pageSize = in.readInt();/* ww w . jav a 2 s .co m*/ pageIndex = in.readInt(); setWrappedData(null); // restoring old extracted row keys is needed for correct restoreRows/restoreRowIndexes functionality, which // in turn is required for correct data submission in case of concurrent data modifications extractedRowKeys = (List) in.readObject(); }