@Test public void testGetString() { this.descriptor1.setBooleanValue(true); Assert.assertEquals(Boolean.TRUE.toString(), this.descriptor1.getString()); this.descriptor1.setBooleanValue(false); Assert.assertEquals(Boolean.FALSE.toString(), this.descriptor1.getString()); this.descriptor1.setWordValue(334); Assert.assertEquals("334", this.descriptor1.getString()); this.descriptor1.setDWordValue(12345); Assert.assertEquals("12345", this.descriptor1.getString()); this.descriptor1.setQWordValue(123456); Assert.assertEquals("123456", this.descriptor1.getString()); this.descriptor1.setStringValue("this is a test string"); Assert.assertEquals("this is a test string", this.descriptor1.getString()); this.descriptor1.setBinaryValue(new byte[20]); Assert.assertEquals("binary data", this.descriptor1.getString()); }
public String getString() { String result = null; switch (getType()) { case TYPE_BINARY: result = "binary data"; break; case TYPE_BOOLEAN: result = String.valueOf(getBoolean()); break; case TYPE_GUID: result = getGuid() == null ? "Invalid GUID" : getGuid().toString(); break; case TYPE_QWORD: case TYPE_DWORD: case TYPE_WORD: result = String.valueOf(getNumber()); break; case TYPE_STRING: try { result = new String(this.content, "UTF-16LE"); } catch (final UnsupportedEncodingException e) { LOG.log(WARN, e, "Bad encoding"); } break; default: throw new IllegalStateException("Current type is not known."); } return result; }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public String getString() { String result = null; switch (getType()) { case TYPE_BINARY: result = "binary data"; break; case TYPE_BOOLEAN: result = String.valueOf(getBoolean()); break; case TYPE_GUID: result = getGuid() == null ? "Invalid GUID" : getGuid().toString(); break; case TYPE_QWORD: case TYPE_DWORD: case TYPE_WORD: result = String.valueOf(getNumber()); break; case TYPE_STRING: try { result = new String(this.content, "UTF-16LE"); } catch (final UnsupportedEncodingException e) { LOG.log(WARN, e, "Bad encoding"); } break; default: throw new IllegalStateException("Current type is not known."); } return result; } }
MetadataDescriptor implements Comparable<MetadataDescriptor>, Cloneable { public String getString() { String result = null; switch (getType()) { case TYPE_BINARY: result = "binary data"; break; case TYPE_BOOLEAN: result = String.valueOf(getBoolean()); break; case TYPE_GUID: result = getGuid() == null ? "Invalid GUID" : getGuid().toString(); break; case TYPE_QWORD: case TYPE_DWORD: case TYPE_WORD: result = String.valueOf(getNumber()); break; case TYPE_STRING: try { result = new String(this.content, "UTF-16LE"); } catch (final UnsupportedEncodingException e) { LOG.log(WARN, e, "Bad encoding"); } break; default: throw new IllegalStateException("Current type is not known."); } return result; } 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 String getString() { String result = null; switch (getType()) { case TYPE_BINARY: result = "binary data"; break; case TYPE_BOOLEAN: result = String.valueOf(getBoolean()); break; case TYPE_GUID: result = getGuid() == null ? "Invalid GUID" : getGuid().toString(); break; case TYPE_QWORD: case TYPE_DWORD: case TYPE_WORD: result = String.valueOf(getNumber()); break; case TYPE_STRING: try { result = new String(this.content, "UTF-16LE"); } catch (final UnsupportedEncodingException e) { LOG.log(WARN, e, "Bad encoding"); } break; default: throw new IllegalStateException("Current type is not known."); } return result; } 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 String getString() { String result = null; switch (getType()) { case TYPE_BINARY: result = "binary data"; break; case TYPE_BOOLEAN: result = String.valueOf(getBoolean()); break; case TYPE_GUID: result = getGuid() == null ? "Invalid GUID" : getGuid().toString(); break; case TYPE_QWORD: case TYPE_DWORD: case TYPE_WORD: result = String.valueOf(getNumber()); break; case TYPE_STRING: try { result = new String(this.content, "UTF-16LE"); } catch (final UnsupportedEncodingException e) { LOG.log(WARN, e, "Bad encoding"); } break; default: throw new IllegalStateException("Current type is not known."); } return result; } 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; }