poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1147134 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf: converter/AbstractWordConverter.java model/Field.java model/FieldsTables.java
Date Fri, 15 Jul 2011 12:58:14 GMT
Author: sergey
Date: Fri Jul 15 12:58:14 2011
New Revision: 1147134

URL: http://svn.apache.org/viewvc?rev=1147134&view=rev
Log:
rename methods to make the difference between field end (exclusive) and field end mark offset
(inclusive)

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Field.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java?rev=1147134&r1=1147133&r2=1147134&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
Fri Jul 15 12:58:14 2011
@@ -118,7 +118,7 @@ public abstract class AbstractWordConver
                         processField( ( (HWPFDocument) hwpfDocument ), range,
                                 currentTableLevel, aliveField, block );
 
-                        int continueAfter = aliveField.getEndOffset();
+                        int continueAfter = aliveField.getFieldEndOffset();
                         while ( c < range.numCharacterRuns()
                                 && range.getCharacterRun( c ).getEndOffset() <=
continueAfter )
                             c++;
@@ -445,7 +445,7 @@ public abstract class AbstractWordConver
                         currentBlock );
                 if ( possibleField != null )
                 {
-                    c = possibleField.getEndOffset();
+                    c = possibleField.getFieldEndOffset();
                 }
                 else
                 {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Field.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Field.java?rev=1147134&r1=1147133&r2=1147134&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Field.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Field.java Fri Jul 15 12:58:14
2011
@@ -4,9 +4,9 @@ import org.apache.poi.hwpf.usermodel.Ran
 
 public class Field
 {
-    private PlexOfField startPlex;
-    private PlexOfField separatorPlex;
     private PlexOfField endPlex;
+    private PlexOfField separatorPlex;
+    private PlexOfField startPlex;
 
     public Field( PlexOfField startPlex, PlexOfField separatorPlex,
             PlexOfField endPlex )
@@ -34,12 +34,42 @@ public class Field
         this.endPlex = endPlex;
     }
 
-    public int getStartOffset()
+    public Range firstSubrange( Range parent )
     {
-        return startPlex.getFcStart();
+        if ( hasSeparator() )
+        {
+            if ( getMarkStartOffset() + 1 == getMarkSeparatorOffset() )
+                return null;
+
+            return new Range( getMarkStartOffset() + 1,
+                    getMarkSeparatorOffset(), parent )
+            {
+                @Override
+                public String toString()
+                {
+                    return "FieldSubrange1 (" + super.toString() + ")";
+                }
+            };
+        }
+
+        if ( getMarkStartOffset() + 1 == getMarkEndOffset() )
+            return null;
+
+        return new Range( getMarkStartOffset() + 1, getMarkEndOffset(), parent )
+        {
+            @Override
+            public String toString()
+            {
+                return "FieldSubrange1 (" + super.toString() + ")";
+            }
+        };
     }
 
-    public int getEndOffset()
+    /**
+     * @return character position of first character after field (i.e.
+     *         {@link #getMarkEndOffset()} + 1)
+     */
+    public int getFieldEndOffset()
     {
         /*
          * sometimes plex looks like [100, 2000), where 100 is the position of
@@ -49,34 +79,53 @@ public class Field
         return endPlex.getFcStart() + 1;
     }
 
-    public boolean hasSeparator()
+    /**
+     * @return character position of first character in field (i.e.
+     *         {@link #getFieldStartOffset()})
+     */
+    public int getFieldStartOffset()
     {
-        return separatorPlex != null;
+        return startPlex.getFcStart();
+    }
+
+    /**
+     * @return character position of end field mark
+     */
+    public int getMarkEndOffset()
+    {
+        return endPlex.getFcStart();
     }
 
-    public int getSeparatorOffset()
+    /**
+     * @return character position of separator field mark (if present,
+     *         {@link NullPointerException} otherwise)
+     */
+    public int getMarkSeparatorOffset()
     {
         return separatorPlex.getFcStart();
     }
 
-    public int getType()
+    /**
+     * @return character position of start field mark
+     */
+    public int getMarkStartOffset()
     {
-        return startPlex.getFld().getFieldType();
+        return startPlex.getFcStart();
     }
 
-    public boolean isZombieEmbed()
+    public int getType()
     {
-        return endPlex.getFld().isFZombieEmbed();
+        return startPlex.getFld().getFieldType();
     }
 
-    public boolean isResultDirty()
+    public boolean hasSeparator()
     {
-        return endPlex.getFld().isFResultDirty();
+        return separatorPlex != null;
     }
 
-    public boolean isResultEdited()
+    public boolean isHasSep()
     {
-        return endPlex.getFld().isFResultEdited();
+        return endPlex.getFld().isFHasSep();
     }
 
     public boolean isLocked()
@@ -84,58 +133,39 @@ public class Field
         return endPlex.getFld().isFLocked();
     }
 
+    public boolean isNested()
+    {
+        return endPlex.getFld().isFNested();
+    }
+
     public boolean isPrivateResult()
     {
         return endPlex.getFld().isFPrivateResult();
     }
 
-    public boolean isNested()
+    public boolean isResultDirty()
     {
-        return endPlex.getFld().isFNested();
+        return endPlex.getFld().isFResultDirty();
     }
 
-    public boolean isHasSep()
+    public boolean isResultEdited()
     {
-        return endPlex.getFld().isFHasSep();
+        return endPlex.getFld().isFResultEdited();
     }
 
-    public Range firstSubrange( Range parent )
+    public boolean isZombieEmbed()
     {
-        if ( hasSeparator() )
-        {
-            if ( getStartOffset() + 1 == getSeparatorOffset() )
-                return null;
-
-            return new Range( getStartOffset() + 1, getSeparatorOffset(),
-                    parent )
-            {
-                @Override
-                public String toString()
-                {
-                    return "FieldSubrange1 (" + super.toString() + ")";
-                }
-            };
-        }
-
-        if ( getStartOffset() + 1 == getEndOffset() )
-            return null;
-
-        return new Range( getStartOffset() + 1, getEndOffset(), parent )
-        {
-            @Override
-            public String toString()
-            {
-                return "FieldSubrange1 (" + super.toString() + ")";
-            }
-        };
+        return endPlex.getFld().isFZombieEmbed();
     }
 
     public Range secondSubrange( Range parent )
     {
-        if ( !hasSeparator() || getSeparatorOffset() + 1 == getEndOffset() )
+        if ( !hasSeparator()
+                || getMarkSeparatorOffset() + 1 == getMarkEndOffset() )
             return null;
 
-        return new Range( getSeparatorOffset() + 1, getEndOffset(), parent )
+        return new Range( getMarkSeparatorOffset() + 1, getMarkEndOffset(),
+                parent )
         {
             @Override
             public String toString()
@@ -148,7 +178,7 @@ public class Field
     @Override
     public String toString()
     {
-        return "Field [" + getStartOffset() + "; " + getEndOffset()
+        return "Field [" + getFieldStartOffset() + "; " + getFieldEndOffset()
                 + "] (type: 0x" + Integer.toHexString( getType() ) + " = "
                 + getType() + " )";
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java?rev=1147134&r1=1147133&r2=1147134&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java Fri Jul 15 12:58:14
2011
@@ -114,7 +114,7 @@ public class FieldsTables
                 fields.size() );
         for ( Field field : fields )
         {
-            result.put( Integer.valueOf( field.getStartOffset() ), field );
+            result.put( Integer.valueOf( field.getFieldStartOffset() ), field );
         }
         return result;
     }



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


Mime
View raw message