@Test public void testSetString() { MetadataDescriptor desc = new MetadataDescriptor( ContainerType.METADATA_LIBRARY_OBJECT, "name", MetadataDescriptor.TYPE_BOOLEAN); desc.setString("true"); Assert.assertTrue(desc.getBoolean()); desc.setString("false"); Assert.assertFalse(desc.getBoolean()); desc.setWordValue(10); desc.setString("60"); Assert.assertEquals(60, desc.getNumber()); setStringFail(desc, "nonumber"); setStringFail(desc, String.valueOf(Long.MAX_VALUE)); setStringFail(desc, String.valueOf(-1)); desc.setDWordValue(10); desc.setString("60"); Assert.assertEquals(60, desc.getNumber()); setStringFail(desc, "nonumber"); setStringFail(desc, String.valueOf(Long.MAX_VALUE)); setStringFail(desc, String.valueOf(-1)); desc.setQWordValue(10); desc.setString("60"); Assert.assertEquals(60, desc.getNumber()); desc.setString(MetadataDescriptor.QWORD_MAXVALUE.toString(10)); setStringFail(desc, "nonumber"); setStringFail(desc, MetadataDescriptor.QWORD_MAXVALUE.add( BigInteger.ONE).toString(10)); setStringFail(desc, String.valueOf(-1)); desc.setGUIDValue(GUID.GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT); desc.setString(GUID.GUID_AUDIOSTREAM.toString()); setStringFail(desc, ""); setStringFail(desc, GUID.GUID_AUDIOSTREAM.toString() + "a"); }
public void setString(final String value) throws IllegalArgumentException { try { switch (getType()) { case TYPE_BINARY: throw new IllegalArgumentException("Cannot interpret binary as string."); case TYPE_BOOLEAN: setBooleanValue(Boolean.parseBoolean(value)); break; case TYPE_DWORD: setDWordValue(Long.parseLong(value)); break; case TYPE_QWORD: setQWordValue(new BigInteger(value, 10)); break; case TYPE_WORD: setWordValue(Integer.parseInt(value)); break; case TYPE_GUID: setGUIDValue(GUID.parseGUID(value)); break; case TYPE_STRING: setStringValue(value); break; default: throw new IllegalStateException(); } } catch (final NumberFormatException nfe) { throw new IllegalArgumentException("Value cannot be parsed as Number or is out of range (\"" + value + "\")", nfe); } }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public void setString(final String value) throws IllegalArgumentException { try { switch (getType()) { case TYPE_BINARY: throw new IllegalArgumentException("Cannot interpret binary as string."); case TYPE_BOOLEAN: setBooleanValue(Boolean.parseBoolean(value)); break; case TYPE_DWORD: setDWordValue(Long.parseLong(value)); break; case TYPE_QWORD: setQWordValue(new BigInteger(value, 10)); break; case TYPE_WORD: setWordValue(Integer.parseInt(value)); break; case TYPE_GUID: setGUIDValue(GUID.parseGUID(value)); break; case TYPE_STRING: setStringValue(value); break; default: throw new IllegalStateException(); } } catch (final NumberFormatException nfe) { throw new IllegalArgumentException("Value cannot be parsed as Number or is out of range (\"" + value + "\")", nfe); } } }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public void setString(final String value) throws IllegalArgumentException { try { switch (getType()) { case TYPE_BINARY: throw new IllegalArgumentException("Cannot interpret binary as string."); case TYPE_BOOLEAN: setBooleanValue(Boolean.parseBoolean(value)); break; case TYPE_DWORD: setDWordValue(Long.parseLong(value)); break; case TYPE_QWORD: setQWordValue(new BigInteger(value, 10)); break; case TYPE_WORD: setWordValue(Integer.parseInt(value)); break; case TYPE_GUID: setGUIDValue(GUID.parseGUID(value)); break; case TYPE_STRING: setStringValue(value); break; default: throw new IllegalStateException(); } } catch (final NumberFormatException nfe) { throw new IllegalArgumentException("Value cannot be parsed as Number or is out of range (\"" + value + "\")", nfe); } } MetadataDescriptor(final ContainerType type, final String propName, final int propType);  MetadataDescriptor(final ContainerType type,
                            final String propName,
                            final int propType,
                            final int stream,
                            final int language);  MetadataDescriptor(final String propName);  MetadataDescriptor(final String propName, final int propType); }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public void setString(final String value) throws IllegalArgumentException { try { switch (getType()) { case TYPE_BINARY: throw new IllegalArgumentException("Cannot interpret binary as string."); case TYPE_BOOLEAN: setBooleanValue(Boolean.parseBoolean(value)); break; case TYPE_DWORD: setDWordValue(Long.parseLong(value)); break; case TYPE_QWORD: setQWordValue(new BigInteger(value, 10)); break; case TYPE_WORD: setWordValue(Integer.parseInt(value)); break; case TYPE_GUID: setGUIDValue(GUID.parseGUID(value)); break; case TYPE_STRING: setStringValue(value); break; default: throw new IllegalStateException(); } } catch (final NumberFormatException nfe) { throw new IllegalArgumentException("Value cannot be parsed as Number or is out of range (\"" + value + "\")", nfe); } } MetadataDescriptor(final ContainerType type, final String propName, final int propType);  MetadataDescriptor(final ContainerType type,
                            final String propName,
                            final int propType,
                            final int stream,
                            final int language);  MetadataDescriptor(final String propName);  MetadataDescriptor(final String propName, final int propType); @Override Object clone(); int compareTo(final MetadataDescriptor other); MetadataDescriptor createCopy(); @Override boolean equals(final Object obj); boolean getBoolean(); @Deprecated byte[] getBytes(); ContainerType getContainerType(); GUID getGuid(); String getName(); long getNumber(); byte[] getRawData(); int getRawDataSize(); String getString(); int getType(); @Override int hashCode(); boolean isEmpty(); void setBinaryValue(final byte[] data); void setBooleanValue(final boolean value); void setDWordValue(final long value); void setGUIDValue(final GUID value); void setQWordValue(final long value); void setString(final String value); void setStringValue(final String value); void setWordValue(final int value); @Override String toString(); }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public void setString(final String value) throws IllegalArgumentException { try { switch (getType()) { case TYPE_BINARY: throw new IllegalArgumentException("Cannot interpret binary as string."); case TYPE_BOOLEAN: setBooleanValue(Boolean.parseBoolean(value)); break; case TYPE_DWORD: setDWordValue(Long.parseLong(value)); break; case TYPE_QWORD: setQWordValue(new BigInteger(value, 10)); break; case TYPE_WORD: setWordValue(Integer.parseInt(value)); break; case TYPE_GUID: setGUIDValue(GUID.parseGUID(value)); break; case TYPE_STRING: setStringValue(value); break; default: throw new IllegalStateException(); } } catch (final NumberFormatException nfe) { throw new IllegalArgumentException("Value cannot be parsed as Number or is out of range (\"" + value + "\")", nfe); } } MetadataDescriptor(final ContainerType type, final String propName, final int propType);  MetadataDescriptor(final ContainerType type,
                            final String propName,
                            final int propType,
                            final int stream,
                            final int language);  MetadataDescriptor(final String propName);  MetadataDescriptor(final String propName, final int propType); @Override Object clone(); int compareTo(final MetadataDescriptor other); MetadataDescriptor createCopy(); @Override boolean equals(final Object obj); boolean getBoolean(); @Deprecated byte[] getBytes(); ContainerType getContainerType(); GUID getGuid(); String getName(); long getNumber(); byte[] getRawData(); int getRawDataSize(); String getString(); int getType(); @Override int hashCode(); boolean isEmpty(); void setBinaryValue(final byte[] data); void setBooleanValue(final boolean value); void setDWordValue(final long value); void setGUIDValue(final GUID value); void setQWordValue(final long value); void setString(final String value); void setStringValue(final String value); void setWordValue(final int value); @Override String toString(); static final long DWORD_MAXVALUE; static final int MAX_LANG_INDEX; static final int MAX_STREAM_NUMBER; final static int TYPE_BINARY; final static int TYPE_BOOLEAN; final static int TYPE_DWORD; final static int TYPE_GUID; final static int TYPE_QWORD; final static int TYPE_STRING; final static int TYPE_WORD; }