jxl.biff
Class XFRecord

java.lang.Object
  |
  +--jxl.biff.RecordData
        |
        +--jxl.biff.WritableRecordData
              |
              +--jxl.biff.XFRecord
All Implemented Interfaces:
ByteData, CellFormat
Direct Known Subclasses:
CellXFRecord, StyleXFRecord

public class XFRecord
extends WritableRecordData
implements CellFormat

Holds an extended formatting record


Inner Class Summary
private static class XFRecord.BiffType
           
 
Field Summary
private  Alignment align
          The alignment for this cell (left, right, centre)
private  Colour backgroundColour
          The background colour
static XFRecord.BiffType biff7
           
static XFRecord.BiffType biff8
           
private  XFRecord.BiffType biffType
          The biff type
private  BorderLineStyle bottomBorder
          The border indicator for the bottom of the cell
private  boolean copied
          Flag to indicate whether this cell was copied.
private  boolean date
          Indicates whether this is a date formatting record
private  java.text.DateFormat dateFormat
          The date format for this record.
private static int[] dateFormats
           
private  Format excelFormat
          The excel format for this record.
private  FontRecord font
          The font object for this XF record
private  int fontIndex
          The index to the font record used by this XF record
private  DisplayFormat format
          The format object for this XF record.
private  int formatIndex
          The index to the format record
private  boolean formatInfoInitialized
          Flag to indicate whether the format information has been initialized.
private  FormattingRecords formattingRecords
          A handle to the formatting records.
private  boolean hidden
          Flag to indicate whether this XF record is hidden
private  boolean initialized
          Flag to indicate whether this XF record has been initialized
private static java.text.DateFormat[] javaDateFormats
           
private static java.text.NumberFormat[] javaNumberFormats
           
private  BorderLineStyle leftBorder
          The border indicator for the left of this cell
private  boolean locked
          Flag to indicate whether this XF record represents a locked cell
private  boolean number
          Indicates whether this is a number formatting record
private  java.text.NumberFormat numberFormat
          The number format for this record.
private static int[] numberFormats
           
private  int options
          The options mask which is used to store the processed cell options (such as alignment, borders etc)
private  Orientation orientation
          The orientation of the cell
private  Pattern pattern
          The background pattern
private  boolean read
          Indicates whether this cell was constructed by an API or read from an existing Excel file
private  BorderLineStyle rightBorder
          The border indicator for the right of the cell
private  BorderLineStyle topBorder
          The border indicator for the top of the cell
private  VerticalAlignment valign
          The vertical alignment for the cell (top, bottom, centre)
private  boolean wrap
          Flag to indicates whether the data (normally text) in the cell will be wrapped around to fit in the cell width
private  int xfIndex
          The index of this XF record within the workbook
 
Fields inherited from class jxl.biff.RecordData
code, record
 
Constructor Summary
  XFRecord(FontRecord fnt, DisplayFormat form)
          A constructor used when creating a writable record
  XFRecord(Record t, XFRecord.BiffType bt)
          Constructs this object from the raw data
protected XFRecord(XFRecord fmt)
          Copy constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Equals method.
 Alignment getAlignment()
          Gets the horizontal cell alignment
 Colour getBackgroundColour()
          Gets the background colour used by this cell
 BorderLineStyle getBorder(Border border)
          Gets the line style for the given cell border If a border type of ALL or NONE is specified, then a line style of NONE is returned
 byte[] getData()
          Converts the various fields into binary data.
 java.text.DateFormat getDateFormat()
          Gets the java date format for this format record
 Font getFont()
          Gets the font used by this format
 Format getFormat()
          Gets the format used by this format
 int getFormatRecord()
          Gets the lookup number of the format record
protected  boolean getHidden()
          Accessor for the hidden flag
protected  boolean getLocked()
          Accessor for the locked flag
 java.text.NumberFormat getNumberFormat()
          Gets the java number format for this format record
 Orientation getOrientation()
          Gets the orientation
 Pattern getPattern()
          Gets the pattern used by this cell format
 VerticalAlignment getVerticalAlignment()
          Gets the vertical cell alignment
 boolean getWrap()
          Gets whether or not the contents of this cell are wrapped
 int getXFIndex()
          Accessor for the XF index
 boolean hasBorders()
          Determines if this cell format has any borders at all.
 void initialize(int pos, FormattingRecords fr, Fonts fonts)
          If this cell has not been read in from an existing Excel sheet, then initializes this record with the XF index passed in.
private  void initializeFormatInformation()
          Initializes the internal format information from the data read in
 boolean isDate()
          Sees if this format is a date format
 boolean isInitialized()
          Accessor to see if this format is initialized
 boolean isNumber()
          Sees if this format is a number format
 boolean isRead()
          Accessor to see if this format was read in.
 void setLocked(boolean l)
          Sets whether or not this XF record locks the cell
protected  void setXFAlignment(Alignment a)
          Sets the horizontal alignment for the data in this cell.
protected  void setXFBackground(Colour c, Pattern p)
          Sets the horizontal alignment for the data in this cell.
protected  void setXFBorder(Border b, BorderLineStyle ls)
          Sets the border for this cell This method should only be called from its writable subclass CellXFRecord
protected  void setXFCellOptions(int opt)
          Sets the raw cell options
protected  void setXFOrientation(Orientation o)
          Sets the vertical alignment for the data in this cell This method should only be called from its writable subclass CellXFRecord
protected  void setXFVerticalAlignment(VerticalAlignment va)
          Sets the vertical alignment for the data in this cell This method should only be called from its writable subclass CellXFRecord
protected  void setXFWrap(boolean w)
          Sets whether the data in this cell is wrapped This method should only be called from its writable subclass CellXFRecord
 void uninitialize()
          Resets the initialize flag.
 
Methods inherited from class jxl.biff.WritableRecordData
getBytes
 
Methods inherited from class jxl.biff.RecordData
getCode, getRecord
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

formatIndex

private int formatIndex
The index to the format record

date

private boolean date
Indicates whether this is a date formatting record

number

private boolean number
Indicates whether this is a number formatting record

dateFormat

private java.text.DateFormat dateFormat
The date format for this record. Deduced when the record is read in from a spreadsheet

numberFormat

private java.text.NumberFormat numberFormat
The number format for this record. Deduced when the record is read in from a spreadsheet

fontIndex

private int fontIndex
The index to the font record used by this XF record

locked

private boolean locked
Flag to indicate whether this XF record represents a locked cell

hidden

private boolean hidden
Flag to indicate whether this XF record is hidden

align

private Alignment align
The alignment for this cell (left, right, centre)

valign

private VerticalAlignment valign
The vertical alignment for the cell (top, bottom, centre)

orientation

private Orientation orientation
The orientation of the cell

wrap

private boolean wrap
Flag to indicates whether the data (normally text) in the cell will be wrapped around to fit in the cell width

leftBorder

private BorderLineStyle leftBorder
The border indicator for the left of this cell

rightBorder

private BorderLineStyle rightBorder
The border indicator for the right of the cell

topBorder

private BorderLineStyle topBorder
The border indicator for the top of the cell

bottomBorder

private BorderLineStyle bottomBorder
The border indicator for the bottom of the cell

backgroundColour

private Colour backgroundColour
The background colour

pattern

private Pattern pattern
The background pattern

options

private int options
The options mask which is used to store the processed cell options (such as alignment, borders etc)

xfIndex

private int xfIndex
The index of this XF record within the workbook

font

private FontRecord font
The font object for this XF record

format

private DisplayFormat format
The format object for this XF record. This is used when creating a writable record

initialized

private boolean initialized
Flag to indicate whether this XF record has been initialized

read

private boolean read
Indicates whether this cell was constructed by an API or read from an existing Excel file

excelFormat

private Format excelFormat
The excel format for this record. This is used to display the actual excel format string back to the user (eg. when generating certain types of XML document) as opposed to the java equivalent

formatInfoInitialized

private boolean formatInfoInitialized
Flag to indicate whether the format information has been initialized. This is false if the xf record has been read in, but true if it has been written

copied

private boolean copied
Flag to indicate whether this cell was copied. If it was copied, then it can be set to uninitialized, allowing us to change certain format information

formattingRecords

private FormattingRecords formattingRecords
A handle to the formatting records. The purpose of this is to read the formatting information back, for the purposes of output eg. to some form of XML

dateFormats

private static int[] dateFormats

javaDateFormats

private static java.text.DateFormat[] javaDateFormats

numberFormats

private static int[] numberFormats

javaNumberFormats

private static java.text.NumberFormat[] javaNumberFormats

biff8

public static final XFRecord.BiffType biff8

biff7

public static final XFRecord.BiffType biff7

biffType

private XFRecord.BiffType biffType
The biff type
Constructor Detail

XFRecord

public XFRecord(Record t,
                XFRecord.BiffType bt)
Constructs this object from the raw data
Parameters:
t - the raw data

XFRecord

public XFRecord(FontRecord fnt,
                DisplayFormat form)
A constructor used when creating a writable record
Parameters:
fnt - the font
form - the format

XFRecord

protected XFRecord(XFRecord fmt)
Copy constructor. Used for copying writable formats, typically when duplicating formats to handle merged cells
Parameters:
fmt - XFRecord
Method Detail

getDateFormat

public java.text.DateFormat getDateFormat()
Gets the java date format for this format record
Returns:
returns the date format

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Gets the java number format for this format record
Returns:
returns the number format

getFormatRecord

public int getFormatRecord()
Gets the lookup number of the format record
Returns:
returns the lookup number of the format record

isDate

public boolean isDate()
Sees if this format is a date format
Returns:
TRUE if this refers to a built in date format

isNumber

public boolean isNumber()
Sees if this format is a number format
Returns:
TRUE if this refers to a built in date format

getData

public byte[] getData()
Converts the various fields into binary data. If this object has been read from an Excel file rather than being requested by a user (ie. if the read flag is TRUE) then no processing takes place and the raw data is simply returned.
Overrides:
getData in class WritableRecordData
Returns:
the raw data for writing

getLocked

protected final boolean getLocked()
Accessor for the locked flag
Returns:
TRUE if this XF record locks cells, FALSE otherwise

getHidden

protected final boolean getHidden()
Accessor for the hidden flag
Returns:
TRUE if this XF record hides the cell, FALSE otherwise

setLocked

public final void setLocked(boolean l)
Sets whether or not this XF record locks the cell
Parameters:
l - the locked flag

setXFCellOptions

protected final void setXFCellOptions(int opt)
Sets the raw cell options
Parameters:
opt - the cell options

setXFAlignment

protected void setXFAlignment(Alignment a)
Sets the horizontal alignment for the data in this cell. This method should only be called from its writable subclass CellXFRecord
Parameters:
a - the alignment

getAlignment

public Alignment getAlignment()
Gets the horizontal cell alignment
Specified by:
getAlignment in interface CellFormat
Returns:
the alignment

getVerticalAlignment

public VerticalAlignment getVerticalAlignment()
Gets the vertical cell alignment
Specified by:
getVerticalAlignment in interface CellFormat
Returns:
the alignment

getOrientation

public Orientation getOrientation()
Gets the orientation
Specified by:
getOrientation in interface CellFormat
Returns:
the orientation

setXFBackground

protected void setXFBackground(Colour c,
                               Pattern p)
Sets the horizontal alignment for the data in this cell. This method should only be called from its writable subclass CellXFRecord
Parameters:
c - the background colour
p - the background pattern

getBackgroundColour

public Colour getBackgroundColour()
Gets the background colour used by this cell
Specified by:
getBackgroundColour in interface CellFormat
Returns:
the foreground colour

getPattern

public Pattern getPattern()
Gets the pattern used by this cell format
Specified by:
getPattern in interface CellFormat
Returns:
the background pattern

setXFVerticalAlignment

protected void setXFVerticalAlignment(VerticalAlignment va)
Sets the vertical alignment for the data in this cell This method should only be called from its writable subclass CellXFRecord
Parameters:
va - the vertical alignment

setXFOrientation

protected void setXFOrientation(Orientation o)
Sets the vertical alignment for the data in this cell This method should only be called from its writable subclass CellXFRecord
Parameters:
o - the orientation

setXFWrap

protected void setXFWrap(boolean w)
Sets whether the data in this cell is wrapped This method should only be called from its writable subclass CellXFRecord
Parameters:
w - the wrap flag

getWrap

public boolean getWrap()
Gets whether or not the contents of this cell are wrapped
Specified by:
getWrap in interface CellFormat
Returns:
TRUE if this cell's contents are wrapped, FALSE otherwise

setXFBorder

protected void setXFBorder(Border b,
                           BorderLineStyle ls)
Sets the border for this cell This method should only be called from its writable subclass CellXFRecord
Parameters:
b -  
ls -  

getBorder

public BorderLineStyle getBorder(Border border)
Gets the line style for the given cell border If a border type of ALL or NONE is specified, then a line style of NONE is returned
Specified by:
getBorder in interface CellFormat
Parameters:
border - the cell border we are interested in
Returns:
the line style of the specified border

hasBorders

public final boolean hasBorders()
Determines if this cell format has any borders at all. Used to set the new borders when merging a group of cells
Specified by:
hasBorders in interface CellFormat
Returns:
TRUE if this cell has any borders, FALSE otherwise

initialize

public final void initialize(int pos,
                             FormattingRecords fr,
                             Fonts fonts)
                      throws NumFormatRecordsException
If this cell has not been read in from an existing Excel sheet, then initializes this record with the XF index passed in. Calls initialized on the font and format record
Parameters:
pos - the xf index to initialize this record with
fr - the containing formatting records
fonts - the container for the fonts
Throws:
NumFormatRecordsException -  

uninitialize

public final void uninitialize()
Resets the initialize flag. This is called by the constructor of WritableWorkbookImpl to reset the statically declared fonts

getXFIndex

public final int getXFIndex()
Accessor for the XF index
Returns:
the XF index for this cell

isInitialized

public final boolean isInitialized()
Accessor to see if this format is initialized
Returns:
TRUE if this format is initialized, FALSE otherwise

isRead

public final boolean isRead()
Accessor to see if this format was read in. Used when checking merged cells
Returns:
TRUE if this XF record was read in, FALSE if it was generated by the user API

getFormat

public Format getFormat()
Gets the format used by this format
Specified by:
getFormat in interface CellFormat
Returns:
the format

getFont

public Font getFont()
Gets the font used by this format
Specified by:
getFont in interface CellFormat
Returns:
the font

initializeFormatInformation

private void initializeFormatInformation()
Initializes the internal format information from the data read in

equals

public boolean equals(java.lang.Object o)
Equals method. This is called when comparing writable formats in order to prevent duplicate formats being added to the workbook
Overrides:
equals in class java.lang.Object
Parameters:
o - object to compare
Returns:
TRUE if the objects are equal, FALSE otherwise