/** * Defines a property. Multi-valued properties are not yet supported. */ public void setProperty(PropertyValue value) { properties.put(value.getProperty(), value); }
private void writeFixedLengthValueHeader(OutputStream out, MAPIProperty property, MAPIType type, PropertyValue value) throws IOException { // fixed type header // page 24, point 2.4.2.1.1 byte[] bytes = value.getRawValue(); int length = bytes != null ? bytes.length : 0; if (bytes != null) { out.write(bytes); } out.write(new byte[8 - length]); }
/** * Write the nodes for variable-length data. Those properties are returned by * {@link #writeProperties(java.io.OutputStream)}. * * @param directory * The directory. * @param values * The values. * @throws IOException * If an I/O error occurs. */ protected void writeNodeData(DirectoryEntry directory, List<PropertyValue> values) throws IOException { for (PropertyValue value : values) { byte[] bytes = value.getRawValue(); String nodeName = VARIABLE_LENGTH_PROPERTY_PREFIX + getFileName(value.getProperty(), value.getActualType()); directory.createDocument(nodeName, new ByteArrayInputStream(bytes)); } }
@Override public String toString() { Object v = getValue(); if (v == null) { return "(No value available)"; } if (v instanceof byte[]) { return ByteChunk.toDebugFriendlyString((byte[]) v); } else { // Just use the normal toString on the value return v.toString(); } }
long tag = Long.parseLong(getFileName(property, value.getActualType()), 16); LittleEndian.putUInt(tag, out); LittleEndian.putUInt(value.getFlags(), out); // readable + writable MAPIType type = getTypeMapping(value.getActualType()); if (type.isFixedLength()) {
propVal = new PropertyValue(prop, flags, data, type);
private void writeVariableLengthValueHeader(OutputStream out, MAPIProperty propertyEx, MAPIType type, PropertyValue value) throws IOException { // variable length header // page 24, point 2.4.2.2 byte[] bytes = value.getRawValue(); int length = bytes != null ? bytes.length : 0; // alter the length, as specified in page 25 if (type == Types.UNICODE_STRING) { length += 2; } else if (type == Types.ASCII_STRING) { length += 1; } LittleEndian.putUInt(length, out); // specified in page 25 LittleEndian.putUInt(0, out); }