Java Code Examples for java.beans.XMLDecoder#readObject()
The following examples show how to use
java.beans.XMLDecoder#readObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestObject.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override protected void validate(XMLDecoder decoder) { JPanel panel = (JPanel) decoder.readObject(); if (2 != panel.getComponents().length) { throw new Error("unexpected component count"); } JButton button = (JButton) panel.getComponents()[0]; if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML throw new Error("unexpected button text"); } if (SwingConstants.CENTER != button.getVerticalAlignment()) { throw new Error("unexpected vertical alignment"); } JLabel label = (JLabel) panel.getComponents()[1]; if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML throw new Error("unexpected label text"); } if (button != label.getLabelFor()) { throw new Error("unexpected component"); } }
Example 2
Source File: TestObject.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override protected void validate(XMLDecoder decoder) { JPanel panel = (JPanel) decoder.readObject(); if (2 != panel.getComponents().length) { throw new Error("unexpected component count"); } JButton button = (JButton) panel.getComponents()[0]; if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML throw new Error("unexpected button text"); } if (SwingConstants.CENTER != button.getVerticalAlignment()) { throw new Error("unexpected vertical alignment"); } JLabel label = (JLabel) panel.getComponents()[1]; if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML throw new Error("unexpected label text"); } if (button != label.getLabelFor()) { throw new Error("unexpected component"); } }
Example 3
Source File: AbstractTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * This is entry point to start testing. * * @param security use {@code true} to start * second pass in secure context */ final void test(boolean security) { byte[] array = getFieldValue("XML").getBytes(); // NON-NLS: the field name ByteArrayInputStream input = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(input); decoder.setExceptionListener(this); validate(decoder); try { throw new Error("unexpected object" + decoder.readObject()); } catch (ArrayIndexOutOfBoundsException exception) { // expected exception } decoder.close(); if (security) { System.setSecurityManager(new SecurityManager()); test(false); } }
Example 4
Source File: AbstractTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(), new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readObject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
Example 5
Source File: WebServicePersistenceManager.java From netbeans with Apache License 2.0 | 6 votes |
private WebServiceDescriptor loadDescriptorFile(String descriptorPath) { if (descriptorPath == null || descriptorPath.length() == 0) { return null; } else { XMLDecoder decoder = null; try { decoder = new java.beans.XMLDecoder(new java.io.BufferedInputStream(new java.io.FileInputStream(descriptorPath))); return (WebServiceDescriptor) decoder.readObject(); } catch (Exception ex) { exceptionThrown(ex); return null; } finally { if (decoder != null) { decoder.close(); } } } }
Example 6
Source File: AbstractTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static void test(AbstractTest object) { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output); encoder.setPersistenceDelegate( object.getClass(), new DefaultPersistenceDelegate(new String[] {"value"})); encoder.writeObject(object); encoder.close(); System.out.print(output); ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); AbstractTest result = (AbstractTest) decoder.readObject(); decoder.close(); if (object.getValue() != result.getValue()) throw new Error("Should be " + object); }
Example 7
Source File: TestJava.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override protected void validate(XMLDecoder decoder) { decoder.setOwner(this); if (this != decoder.readObject()) { throw new Error("owner should be the same"); } if (this.message == null) { throw new Error("owner's method is not called"); } }
Example 8
Source File: TestJava.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected void validate(XMLDecoder decoder) { decoder.setOwner(this); if (this != decoder.readObject()) { throw new Error("owner should be the same"); } if (this.message == null) { throw new Error("owner's method is not called"); } }
Example 9
Source File: Test6329581.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private Object decode(byte[] array) { ByteArrayInputStream in = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(in, null, this, this); Object object = decoder.readObject(); validate(object); decoder.close(); return object; }
Example 10
Source File: Test6329581.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private Object decode(byte[] array) { ByteArrayInputStream in = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(in, null, this, this); Object object = decoder.readObject(); validate(object); decoder.close(); return object; }
Example 11
Source File: AbstractTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private Object readObject(byte[] array) { ByteArrayInputStream input = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(input); decoder.setExceptionListener(this); initialize(decoder); Object object = decoder.readObject(); decoder.close(); return object; }
Example 12
Source File: TestVar.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected void validate(XMLDecoder decoder) { for (int i = 0; i < 3; i++) { if (decoder != decoder.readObject()) { throw new Error("decoder instance expected"); } } }
Example 13
Source File: Test6329581.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Object decode(byte[] array) { ByteArrayInputStream in = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(in, null, this, this); Object object = decoder.readObject(); validate(object); decoder.close(); return object; }
Example 14
Source File: TestJava.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected void validate(XMLDecoder decoder) { decoder.setOwner(this); if (this != decoder.readObject()) { throw new Error("owner should be the same"); } if (this.message == null) { throw new Error("owner's method is not called"); } }
Example 15
Source File: TestVar.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override protected void validate(XMLDecoder decoder) { for (int i = 0; i < 3; i++) { if (decoder != decoder.readObject()) { throw new Error("decoder instance expected"); } } }
Example 16
Source File: AbstractTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Object readObject(byte[] array) { ByteArrayInputStream input = new ByteArrayInputStream(array); XMLDecoder decoder = new XMLDecoder(input); decoder.setExceptionListener(this); initialize(decoder); Object object = decoder.readObject(); decoder.close(); return object; }
Example 17
Source File: TestNull.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override protected void validate(XMLDecoder decoder) { if (null != decoder.readObject()) { throw new Error("null value expected"); } }
Example 18
Source File: TestNull.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override protected void validate(XMLDecoder decoder) { if (null != decoder.readObject()) { throw new Error("null value expected"); } }
Example 19
Source File: XMLMarshallerService.java From dawnsci with Eclipse Public License 1.0 | 4 votes |
@Override public <U> U unmarshal(String string, Class<U> beanClass) throws Exception { XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(string.getBytes("UTF-8"))); return (U)decoder.readObject(); }
Example 20
Source File: Test4822050.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private void parse() { XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(this.buffer)); decoder.readObject(); decoder.close(); }