aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRainer Klute <klute@apache.org>2003-10-23 20:44:24 +0000
committerRainer Klute <klute@apache.org>2003-10-23 20:44:24 +0000
commit6d1eefc2eac5872073df2cb1e513ef5b5c1a0ec4 (patch)
tree5c3867d804de6c813ed8f2844323c0d5ef8fe9cf /src
parent88b95cab72cb5abd025ea716563ca4fa526949e7 (diff)
downloadpoi-6d1eefc2eac5872073df2cb1e513ef5b5c1a0ec4.tar.gz
poi-6d1eefc2eac5872073df2cb1e513ef5b5c1a0ec4.zip
- Added Robert Flaherty's method getCustomProperties() (refactored)
- Got rid of the PropertySet instance variable sectionCount. Use getSectionCount() instead! - Minor fixes git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353409 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java36
-rw-r--r--src/java/org/apache/poi/hpsf/MutablePropertySet.java3
-rw-r--r--src/java/org/apache/poi/hpsf/MutableSection.java4
-rw-r--r--src/java/org/apache/poi/hpsf/PropertySet.java14
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java6
-rw-r--r--src/java/org/apache/poi/hpsf/VariantSupport.java4
6 files changed, 45 insertions, 22 deletions
diff --git a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
index 704717cf91..9295b735e5 100644
--- a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
@@ -54,6 +54,10 @@
*/
package org.apache.poi.hpsf;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
/**
@@ -63,6 +67,7 @@ import org.apache.poi.hpsf.wellknown.PropertyIDMap;
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
* @author Drew Varner (Drew.Varner closeTo sc.edu)
+ * @author robert_flaherty@hyperion.com
* @see SummaryInformation
* @version $Id$
* @since 2002-02-09
@@ -300,4 +305,35 @@ public class DocumentSummaryInformation extends SpecialPropertySet
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;
+ }
+
}
diff --git a/src/java/org/apache/poi/hpsf/MutablePropertySet.java b/src/java/org/apache/poi/hpsf/MutablePropertySet.java
index f9f1333eec..94bdfdc16b 100644
--- a/src/java/org/apache/poi/hpsf/MutablePropertySet.java
+++ b/src/java/org/apache/poi/hpsf/MutablePropertySet.java
@@ -106,7 +106,6 @@ public class MutablePropertySet extends PropertySet
* one section it is added right here. */
sections = new LinkedList();
sections.add(new MutableSection());
- sectionCount = 1;
}
@@ -204,7 +203,6 @@ public class MutablePropertySet extends PropertySet
public void clearSections()
{
sections = null;
- sectionCount = 0;
}
@@ -221,7 +219,6 @@ public class MutablePropertySet extends PropertySet
if (sections == null)
sections = new LinkedList();
sections.add(section);
- sectionCount = sections.size();
}
diff --git a/src/java/org/apache/poi/hpsf/MutableSection.java b/src/java/org/apache/poi/hpsf/MutableSection.java
index e60edf5bd4..871c133605 100644
--- a/src/java/org/apache/poi/hpsf/MutableSection.java
+++ b/src/java/org/apache/poi/hpsf/MutableSection.java
@@ -553,8 +553,8 @@ public class MutableSection extends Section
/**
* <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
diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java
index d0af70efe0..dae88e73c5 100644
--- a/src/java/org/apache/poi/hpsf/PropertySet.java
+++ b/src/java/org/apache/poi/hpsf/PropertySet.java
@@ -208,15 +208,6 @@ public class PropertySet
/**
- * <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>
*
@@ -224,7 +215,7 @@ public class PropertySet
*/
public int getSectionCount()
{
- return sectionCount;
+ return sections.size();
}
@@ -459,7 +450,7 @@ public class PropertySet
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 +
@@ -635,6 +626,7 @@ public class PropertySet
*/
public Section getSingleSection()
{
+ final int sectionCount = getSectionCount();
if (sectionCount != 1)
throw new NoSingleSectionException
("Property set contains " + sectionCount + " sections.");
diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java
index dcbea1b60d..2cc4cc1485 100644
--- a/src/java/org/apache/poi/hpsf/Section.java
+++ b/src/java/org/apache/poi/hpsf/Section.java
@@ -515,9 +515,7 @@ public class Section
/* 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();
@@ -529,7 +527,7 @@ public class Section
}
if (id == 1)
{
- p11 = pa1[i];
+ // p11 = pa1[i];
pa1 = remove(pa1, i);
i--;
}
@@ -545,7 +543,7 @@ public class Section
}
if (id == 1)
{
- p21 = pa2[i];
+ // p21 = pa2[i];
pa2 = remove(pa2, i);
i--;
}
diff --git a/src/java/org/apache/poi/hpsf/VariantSupport.java b/src/java/org/apache/poi/hpsf/VariantSupport.java
index 3bc0c39c38..17892abd22 100644
--- a/src/java/org/apache/poi/hpsf/VariantSupport.java
+++ b/src/java/org/apache/poi/hpsf/VariantSupport.java
@@ -280,9 +280,9 @@ public class VariantSupport extends Variant
// 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: