* <p>Convenience class representing a DocumentSummary Information stream in a
* Microsoft Office document.</p>
*
- * @author Rainer Klute <a
- * href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
- * @author Drew Varner (Drew.Varner closeTo sc.edu)
- * @author robert_flaherty@hyperion.com
* @see SummaryInformation
*/
public class DocumentSummaryInformation extends SpecialPropertySet
{
-
/**
* <p>The document name a document summary information stream
* usually has in a POIFS filesystem.</p>
("Not a " + getClass().getName());
}
-
-
+
/**
* <p>Returns the category (or <code>null</code>).</p>
*
*/
public String getCategory()
{
- return (String) getProperty(PropertyIDMap.PID_CATEGORY);
+ return getPropertyStringValue(PropertyIDMap.PID_CATEGORY);
}
/**
*/
public String getPresentationFormat()
{
- return (String) getProperty(PropertyIDMap.PID_PRESFORMAT);
+ return getPropertyStringValue(PropertyIDMap.PID_PRESFORMAT);
}
/**
*/
public String getManager()
{
- return (String) getProperty(PropertyIDMap.PID_MANAGER);
+ return getPropertyStringValue(PropertyIDMap.PID_MANAGER);
}
/**
*/
public String getCompany()
{
- return (String) getProperty(PropertyIDMap.PID_COMPANY);
+ return getPropertyStringValue(PropertyIDMap.PID_COMPANY);
}
/**
}
-
/**
* <p>Returns <code>true</code> if the custom links are dirty.</p> <p>
*
}
-
/**
* <p>Gets the custom properties.</p>
*
}
}
-
-
/**
* <p>Creates section 2 if it is not already present.</p>
*
}
}
-
-
/**
* <p>Removes the custom properties.</p>
*/
}
-
/**
* <p>Throws an {@link UnsupportedOperationException} with a message text
* telling which functionality is not yet implemented.</p>
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
+import org.apache.poi.util.LittleEndian;
/**
* <p>Abstract superclass for the convenience classes {@link
/**
* @see PropertySet#getSections
*/
- public List getSections()
+ public List<Section> getSections()
{
return delegate.getSections();
}
}
+
+ /**
+ * Fetches the property with the given ID, then does its
+ * best to return it as a String
+ * @return The property as a String, or null if unavailable
+ */
+ protected String getPropertyStringValue(final int propertyId) {
+ Object o = getProperty(propertyId);
+
+ // Normal cases
+ if (o == null) return null;
+ if (o instanceof String) return (String)o;
+
+ // Do our best with some edge cases
+ if (o instanceof byte[]) {
+ byte[] b = (byte[])o;
+ if (b.length == 0) {
+ return "";
+ }
+ if (b.length == 1) {
+ return Byte.toString(b[0]);
+ }
+ if (b.length == 2) {
+ return Integer.toString( LittleEndian.getUShort(b) );
+ }
+ if (b.length == 4) {
+ return Long.toString( LittleEndian.getUInt(b) );
+ }
+ // Maybe it's a string? who knows!
+ return new String(b);
+ }
+ return o.toString();
+ }
+
/**
* @see org.apache.poi.hpsf.PropertySet#hashCode()
* <p>Convenience class representing a Summary Information stream in a
* Microsoft Office document.</p>
*
- * @author Rainer Klute <a
- * href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
* @see DocumentSummaryInformation
*/
public final class SummaryInformation extends SpecialPropertySet {
*/
public String getTitle()
{
- return (String) getProperty(PropertyIDMap.PID_TITLE);
+ return getPropertyStringValue(PropertyIDMap.PID_TITLE);
}
*/
public String getSubject()
{
- return (String) getProperty(PropertyIDMap.PID_SUBJECT);
+ return getPropertyStringValue(PropertyIDMap.PID_SUBJECT);
}
*/
public String getAuthor()
{
- return (String) getProperty(PropertyIDMap.PID_AUTHOR);
+ return getPropertyStringValue(PropertyIDMap.PID_AUTHOR);
}
*/
public String getKeywords()
{
- return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
+ return getPropertyStringValue(PropertyIDMap.PID_KEYWORDS);
}
*/
public String getComments()
{
- return (String) getProperty(PropertyIDMap.PID_COMMENTS);
+ return getPropertyStringValue(PropertyIDMap.PID_COMMENTS);
}
*/
public String getTemplate()
{
- return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
+ return getPropertyStringValue(PropertyIDMap.PID_TEMPLATE);
}
*/
public String getLastAuthor()
{
- return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
+ return getPropertyStringValue(PropertyIDMap.PID_LASTAUTHOR);
}
*/
public String getRevNumber()
{
- return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
+ return getPropertyStringValue(PropertyIDMap.PID_REVNUMBER);
}
*/
public String getApplicationName()
{
- return (String) getProperty(PropertyIDMap.PID_APPNAME);
+ return getPropertyStringValue(PropertyIDMap.PID_APPNAME);
}