poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r658984 - /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
Date Thu, 22 May 2008 03:00:29 GMT
Author: josh
Date: Wed May 21 20:00:29 2008
New Revision: 658984

URL: http://svn.apache.org/viewvc?rev=658984&view=rev
Log:
Fixed compiler errors.  Other improvements for type safety and immutability.

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java?rev=658984&r1=658983&r2=658984&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java Wed May 21 20:00:29
2008
@@ -21,17 +21,18 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * This class holds all the FSPA (File Shape Address) structures.
  * 
  * @author Squeeself
  */
-public class FSPATable 
+public final class FSPATable 
 {
-    protected ArrayList shapes = new ArrayList();
-    protected HashMap cps = new HashMap();
-    protected List _text;
+    private final List _shapes = new ArrayList();
+    private final Map _shapeIndexesByPropertyStart = new HashMap();
+    private final List _text;
     
     public FSPATable(byte[] tableStream, int fcPlcspa, int lcbPlcspa, List tpt)
     {
@@ -46,32 +47,35 @@
             GenericPropertyNode property = plex.getProperty(i);
             FSPA fspa = new FSPA(property.getBytes(), 0);
             
-            shapes.add(fspa);
-            cps.put(Integer.valueOf(property.getStart()), Integer.valueOf(i));
+            _shapes.add(fspa);
+            _shapeIndexesByPropertyStart.put(new Integer(property.getStart()), new Integer(i));
         }
     }
     
     public FSPA getFspaFromCp(int cp)
     {
-        Integer idx = (Integer)cps.get(Integer.valueOf(cp));
-        if (idx == null)
+        Integer idx = (Integer)_shapeIndexesByPropertyStart.get(new Integer(cp));
+        if (idx == null) {
             return null;
-        return (FSPA)shapes.get(idx.intValue());
+        }
+        return (FSPA)_shapes.get(idx.intValue());
     }
     
-    public List getShapes()
+    public FSPA[] getShapes()
     {
-        return shapes;
+        FSPA[] result = new FSPA[_shapes.size()];
+        _shapes.toArray(result);
+        return result;
     }
     
     public String toString()
     {
         StringBuffer buf = new StringBuffer();
-        buf.append("[FPSA PLC size=").append(shapes.size()).append("]\n");
-        for (Iterator it = cps.keySet().iterator(); it.hasNext(); )
+        buf.append("[FPSA PLC size=").append(_shapes.size()).append("]\n");
+        for (Iterator it = _shapeIndexesByPropertyStart.keySet().iterator(); it.hasNext();
)
         {
             Integer i = (Integer) it.next();
-            FSPA fspa = (FSPA) shapes.get(((Integer)cps.get(i)).intValue());
+            FSPA fspa = (FSPA) _shapes.get(((Integer)_shapeIndexesByPropertyStart.get(i)).intValue());
             buf.append("  [FC: ").append(i.toString()).append("] ");
             buf.append(fspa.toString());
             buf.append("\n");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message