aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorSergey Vladimirov <sergey@apache.org>2011-08-31 12:59:31 +0000
committerSergey Vladimirov <sergey@apache.org>2011-08-31 12:59:31 +0000
commit43e3ab672dbc0c44c9660eb2a90055d79c530906 (patch)
tree7b85bb446fbf5b249d7b682308e35b085e4f97f3 /src/java
parentb442d2a74afa604bfce862746eeed7a95acd694f (diff)
downloadpoi-43e3ab672dbc0c44c9660eb2a90055d79c530906.tar.gz
poi-43e3ab672dbc0c44c9660eb2a90055d79c530906.zip
split option field into version and instance
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1163609 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/ddf/EscherRecord.java73
1 files changed, 64 insertions, 9 deletions
diff --git a/src/java/org/apache/poi/ddf/EscherRecord.java b/src/java/org/apache/poi/ddf/EscherRecord.java
index e1e140a93d..55840fa2e0 100644
--- a/src/java/org/apache/poi/ddf/EscherRecord.java
+++ b/src/java/org/apache/poi/ddf/EscherRecord.java
@@ -18,12 +18,14 @@
package org.apache.poi.ddf;
-import org.apache.poi.util.LittleEndian;
-
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.LittleEndian;
+
/**
* The base abstract record from which all escher records are defined. Subclasses will need
* to define methods for serialization/deserialization and for determining the record size.
@@ -31,6 +33,9 @@ import java.util.List;
* @author Glen Stampoultzis
*/
public abstract class EscherRecord {
+ private static BitField fInstance = BitFieldFactory.getInstance(0xfff0);
+ private static BitField fVersion = BitFieldFactory.getInstance(0x000f);
+
private short _options;
private short _recordId;
@@ -85,20 +90,27 @@ public abstract class EscherRecord {
* @return true is this is a container field.
*/
public boolean isContainerRecord() {
- return (_options & (short)0x000f) == (short)0x000f;
+ return getVersion() == (short)0x000f;
}
/**
- * @return The options field for this record. All records have one.
+ * @return The options field for this record. All records have one.
+ * @deprecated Options is an internal field. Use {@link #getInstance()} and
+ * {@link #getVersion()} to access actual fields.
*/
- public short getOptions() {
+ @Deprecated
+ public short getOptions()
+ {
return _options;
}
/**
* Set the options this this record. Container records should have the
* last nibble set to 0xF.
+ * @deprecated Options is an internal field. Use {@link #getInstance()} and
+ * {@link #getVersion()} to access actual fields.
*/
+ @Deprecated
public void setOptions( short options ) {
_options = options;
}
@@ -224,11 +236,44 @@ public abstract class EscherRecord {
/**
* Returns the instance part of the option record.
- *
+ *
* @return The instance part of the record
*/
- public short getInstance() {
- return (short) ( _options >> 4 );
+ public short getInstance()
+ {
+ return fInstance.getShortValue( _options );
+ }
+
+ /**
+ * Sets the instance part of record
+ *
+ * @param value
+ * instance part value
+ */
+ public void setInstance( short value )
+ {
+ fInstance.setShortValue( _options, value );
+ }
+
+ /**
+ * Returns the version part of the option record.
+ *
+ * @return The version part of the option record
+ */
+ public short getVersion()
+ {
+ return fVersion.getShortValue( _options );
+ }
+
+ /**
+ * Sets the version part of record
+ *
+ * @param value
+ * version part value
+ */
+ public void setVersion( short value )
+ {
+ fVersion.setShortValue( _options, value );
}
/**
@@ -253,6 +298,15 @@ public abstract class EscherRecord {
return header;
}
+ public byte getVersion()
+ {
+ return (byte) fVersion.getShortValue( options );
+ }
+
+ public short getInstance()
+ {
+ return fInstance.getShortValue( options );
+ }
public short getOptions()
{
@@ -272,7 +326,8 @@ public abstract class EscherRecord {
public String toString()
{
return "EscherRecordHeader{" +
- "options=" + options +
+ "ver=" + getVersion() +
+ "instance=" + getInstance() +
", recordId=" + recordId +
", remainingBytes=" + remainingBytes +
"}";