klute       2003/10/23 13:44:24

  Modified:    src/java/org/apache/poi/hpsf DocumentSummaryInformation.java
                        MutablePropertySet.java MutableSection.java
                        PropertySet.java Section.java VariantSupport.java
  Log:
  - Added Robert Flaherty's method getCustomProperties() (refactored)
  - Got rid of the PropertySet instance variable sectionCount. Use getSectionCount() 
instead!
  - Minor fixes
  
  Revision  Changes    Path
  1.12      +37 -1     
jakarta-poi/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
  
  Index: DocumentSummaryInformation.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DocumentSummaryInformation.java   30 Aug 2003 09:13:52 -0000      1.11
  +++ DocumentSummaryInformation.java   23 Oct 2003 20:44:24 -0000      1.12
  @@ -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 @@
    * @author Rainer Klute <a
    * href="mailto:[EMAIL PROTECTED]">&lt;[EMAIL PROTECTED]&gt;</a>
    * @author Drew Varner (Drew.Varner closeTo sc.edu)
  + * @author [EMAIL PROTECTED]
    * @see SummaryInformation
    * @version $Id$
    * @since 2002-02-09
  @@ -298,6 +303,37 @@
       public boolean getLinksDirty()
       {
           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;
       }
   
   }
  
  
  
  1.5       +1 -4      jakarta-poi/src/java/org/apache/poi/hpsf/MutablePropertySet.java
  
  Index: MutablePropertySet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/MutablePropertySet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MutablePropertySet.java   18 Sep 2003 18:56:35 -0000      1.4
  +++ MutablePropertySet.java   23 Oct 2003 20:44:24 -0000      1.5
  @@ -106,7 +106,6 @@
            * one section it is added right here. */
           sections = new LinkedList();
           sections.add(new MutableSection());
  -        sectionCount = 1;
       }
   
   
  @@ -204,7 +203,6 @@
       public void clearSections()
       {
           sections = null;
  -        sectionCount = 0;
       }
   
   
  @@ -221,7 +219,6 @@
           if (sections == null)
               sections = new LinkedList();
           sections.add(section);
  -        sectionCount = sections.size();
       }
   
   
  
  
  
  1.6       +3 -3      jakarta-poi/src/java/org/apache/poi/hpsf/MutableSection.java
  
  Index: MutableSection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/MutableSection.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MutableSection.java       18 Sep 2003 18:56:35 -0000      1.5
  +++ MutableSection.java       23 Oct 2003 20:44:24 -0000      1.6
  @@ -553,8 +553,8 @@
   
       /**
        * <p>Sets the section's dictionary. All keys in the dictionary must be
  -     * [EMAIL PROTECTED] java.lang.Long} instances, all values must be
  -     * [EMAIL PROTECTED] java.lang.String}s. This method overwrites the properties 
with IDs
  +     * [EMAIL PROTECTED] java.lang.Long} instances, all values must be
  +     * [EMAIL PROTECTED] 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
  
  
  
  1.14      +4 -12     jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java
  
  Index: PropertySet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- PropertySet.java  4 Sep 2003 20:15:24 -0000       1.13
  +++ PropertySet.java  23 Oct 2003 20:44:24 -0000      1.14
  @@ -208,15 +208,6 @@
   
   
       /**
  -     * <p>The number of sections in this [EMAIL PROTECTED] 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 [EMAIL PROTECTED] Section}s in the property
        * set.</p>
        *
  @@ -224,7 +215,7 @@
        */
       public int getSectionCount()
       {
  -        return sectionCount;
  +        return sections.size();
       }
   
   
  @@ -459,7 +450,7 @@
           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 Section getSingleSection()
       {
  +        final int sectionCount = getSectionCount();
           if (sectionCount != 1)
               throw new NoSingleSectionException
                   ("Property set contains " + sectionCount + " sections.");
  
  
  
  1.20      +3 -5      jakarta-poi/src/java/org/apache/poi/hpsf/Section.java
  
  Index: Section.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/Section.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Section.java      20 Sep 2003 15:43:08 -0000      1.19
  +++ Section.java      23 Oct 2003 20:44:24 -0000      1.20
  @@ -515,9 +515,7 @@
           /* 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 @@
               }
               if (id == 1)
               {
  -                p11 = pa1[i];
  +                // p11 = pa1[i];
                   pa1 = remove(pa1, i);
                   i--;
               }
  @@ -545,7 +543,7 @@
               }
               if (id == 1)
               {
  -                p21 = pa2[i];
  +                // p21 = pa2[i];
                   pa2 = remove(pa2, i);
                   i--;
               }
  
  
  
  1.5       +3 -3      jakarta-poi/src/java/org/apache/poi/hpsf/VariantSupport.java
  
  Index: VariantSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/VariantSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VariantSupport.java       18 Sep 2003 18:56:35 -0000      1.4
  +++ VariantSupport.java       23 Oct 2003 20:44:24 -0000      1.5
  @@ -280,9 +280,9 @@
                   // 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:
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to