*/
package org.apache.poi.hpsf;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
/**
* @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
* @version $Id$
* @since 2002-02-09
return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
}
+
+
+ /**
+ * <p>Gets the custom properties as a map from the property name to
+ * value.</p>
+ *
+ * @return The custom properties if any exist, <code>null</code> otherwise.
+ * @since 2003-10-22
+ */
+ public Map getCustomProperties()
+ {
+ Map nameToValue = null;
+ if (getSectionCount() >= 2)
+ {
+ final Section section = (Section) getSections().get(1);
+ final Map pidToName =
+ (Map) section.getProperty(PropertyIDMap.PID_DICTIONARY);
+ if (pidToName != null)
+ {
+ nameToValue = new HashMap(pidToName.size());
+ for (Iterator i = pidToName.entrySet().iterator(); i.hasNext();)
+ {
+ final Map.Entry e = (Map.Entry) i.next();
+ final long pid = ((Number) e.getKey()).longValue();
+ nameToValue.put(e.getValue(), section.getProperty(pid));
+ }
+ }
+ }
+ return nameToValue;
+ }
+
}
* one section it is added right here. */
sections = new LinkedList();
sections.add(new MutableSection());
- sectionCount = 1;
}
public void clearSections()
{
sections = null;
- sectionCount = 0;
}
if (sections == null)
sections = new LinkedList();
sections.add(section);
- sectionCount = sections.size();
}
/**
* <p>Sets the section's dictionary. All keys in the dictionary must be
- * {@see java.lang.Long} instances, all values must be
- * {@see java.lang.String}s. This method overwrites the properties with IDs
+ * {@link java.lang.Long} instances, all values must be
+ * {@link java.lang.String}s. This method overwrites the properties with IDs
* 0 and 1 since they are reserved for the dictionary and the dictionary's
* codepage. Setting these properties explicitly might have surprising
* effects. An application should never do this but always use this
- /**
- * <p>The number of sections in this {@link PropertySet}.</p>
- *
- * <p>FIXME (2): Get rid of this! The number of sections is implicitly
- * available.</p>
- */
- protected int sectionCount;
-
-
/**
* <p>Returns the number of {@link Section}s in the property
* set.</p>
*/
public int getSectionCount()
{
- return sectionCount;
+ return sections.size();
}
o += LittleEndian.INT_SIZE;
classID = new ClassID(src, o);
o += ClassID.LENGTH;
- sectionCount = LittleEndian.getInt(src, o);
+ final int sectionCount = LittleEndian.getInt(src, o);
o += LittleEndian.INT_SIZE;
if (sectionCount <= 0)
throw new HPSFRuntimeException("Section count " + sectionCount +
*/
public Section getSingleSection()
{
+ final int sectionCount = getSectionCount();
if (sectionCount != 1)
throw new NoSingleSectionException
("Property set contains " + sectionCount + " sections.");
/* Extract properties 0 and 1 and remove them from the copy of the
* arrays. */
Property p10 = null;
- Property p11;
Property p20 = null;
- Property p21;
for (int i = 0; i < pa1.length; i++)
{
final long id = pa1[i].getID();
}
if (id == 1)
{
- p11 = pa1[i];
+ // p11 = pa1[i];
pa1 = remove(pa1, i);
i--;
}
}
if (id == 1)
{
- p21 = pa2[i];
+ // p21 = pa2[i];
pa2 = remove(pa2, i);
i--;
}
// final int first = offset + LittleEndian.INT_SIZE;
long bool = LittleEndian.getUInt(src, o1);
if (bool != 0)
- value = new Boolean(true);
+ value = Boolean.TRUE;
else
- value = new Boolean(false);
+ value = Boolean.FALSE;
break;
}
default: