jxl.write.biff
Class HyperlinkRecord

java.lang.Object
  |
  +--jxl.biff.RecordData
        |
        +--jxl.biff.WritableRecordData
              |
              +--jxl.write.biff.HyperlinkRecord
All Implemented Interfaces:
ByteData
Direct Known Subclasses:
WritableHyperlink

public class HyperlinkRecord
extends WritableRecordData

A number record. This is stored as 8 bytes, as opposed to the 4 byte RK record


Inner Class Summary
private static class HyperlinkRecord.LinkType
          The excel type of hyperlink
 
Field Summary
private  java.lang.String contents
          The cell contents of the cell which activate this hyperlink.
private  byte[] data
          The data for this hyperlink
private  java.io.File file
          The local file referred to by this hyperlink
private static HyperlinkRecord.LinkType fileLink
           
private  int firstColumn
          The first column
private  int firstRow
          The first row
private  int lastColumn
          The last column
private  int lastRow
          The last row
private  HyperlinkRecord.LinkType linkType
          The type of this hyperlink
private  java.lang.String location
          The location in this workbook referred to by this hyperlink
private  boolean modified
          Indicates whether this record has been modified since it was copied
private  Range range
          The range of this hyperlink.
private  WritableSheet sheet
          The sheet containing this hyperlink
private static HyperlinkRecord.LinkType unknown
           
private  java.net.URL url
          The URL referred to by this hyperlink
private static HyperlinkRecord.LinkType urlLink
           
private static HyperlinkRecord.LinkType workbookLink
           
 
Fields inherited from class jxl.biff.WritableRecordData
maxRecordLength
 
Fields inherited from class jxl.biff.RecordData
code, record
 
Constructor Summary
protected HyperlinkRecord(Hyperlink h, WritableSheet s)
          Constructs this object from the a readable spreadsheet
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, java.io.File file)
          Constructs a File hyperlink to a range of cells
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, java.lang.String desc, WritableSheet s, int destcol, int destrow, int lastdestcol, int lastdestrow)
          Constructs a hyperlink to some cells within this workbook
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, java.net.URL url)
          Constructs a URL hyperlink to a range of cells
 
Method Summary
 int getColumn()
          Returns the column number of the top left cell
(package private)  java.lang.String getContents()
          Called by the worksheet.
 byte[] getData()
          Gets the binary data to be written to the output file
 java.io.File getFile()
          Returns the local file eferenced by this Hyperlink
private  byte[] getFileData(byte[] cd)
          Gets the hyperlink stream specific to a local file link
 int getLastColumn()
          Returns the column number of the bottom right cell
 int getLastRow()
          Returns the row number of the bottom right cell
private  byte[] getLocationData(byte[] cd)
          Gets the hyperlink stream specific to a location link
 Range getRange()
          Gets the range of cells which activate this hyperlink The get sheet index methods will all return -1, because the cells will all be present on the same sheet
 int getRow()
          Returns the row number of the top left cell
private  java.lang.String getShortName(java.lang.String s)
          Gets the DOS short file name in 8.3 format of the name passed in
 java.net.URL getURL()
          Gets the URL referenced by this Hyperlink
private  byte[] getURLData(byte[] cd)
          Gets the hyperlink stream specific to a URL link
(package private)  void initialize(WritableSheet s)
          Initializes the range when this hyperlink is added to the sheet
(package private)  void insertColumn(int c)
          A column has been inserted, so adjust the range objects accordingly
(package private)  void insertRow(int r)
          A row has been inserted, so adjust the range objects accordingly
 boolean isFile()
          Determines whether this is a hyperlink to a file
 boolean isLocation()
          Determines whether this is a hyperlink to a location in this workbook
 boolean isURL()
          Determines whether this is a hyperlink to a web resource
(package private)  void removeColumn(int c)
          A column has been removed, so adjust the range objects accordingly
(package private)  void removeRow(int r)
          A row has been removed, so adjust the range objects accordingly
 void setFile(java.io.File file)
          Sets the file activated by this hyperlink
protected  void setLocation(java.lang.String desc, WritableSheet sheet, int destcol, int destrow, int lastdestcol, int lastdestrow)
          Sets the location of the cells to be linked to within this workbook
private  void setLocation(WritableSheet sheet, int destcol, int destrow, int lastdestcol, int lastdestrow)
          Initializes the location from the data passed in
 void setURL(java.net.URL url)
          Sets the URL of this hyperlink
 java.lang.String toString()
          A standard toString method
 
Methods inherited from class jxl.biff.WritableRecordData
getBytes, handleContinueRecords
 
Methods inherited from class jxl.biff.RecordData
getCode, getRecord
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

firstRow

private int firstRow
The first row

lastRow

private int lastRow
The last row

firstColumn

private int firstColumn
The first column

lastColumn

private int lastColumn
The last column

url

private java.net.URL url
The URL referred to by this hyperlink

file

private java.io.File file
The local file referred to by this hyperlink

location

private java.lang.String location
The location in this workbook referred to by this hyperlink

contents

private java.lang.String contents
The cell contents of the cell which activate this hyperlink. Only applies to workbook links

linkType

private HyperlinkRecord.LinkType linkType
The type of this hyperlink

data

private byte[] data
The data for this hyperlink

range

private Range range
The range of this hyperlink. When creating a hyperlink, this will be null until the hyperlink is added to the sheet

sheet

private WritableSheet sheet
The sheet containing this hyperlink

modified

private boolean modified
Indicates whether this record has been modified since it was copied

urlLink

private static final HyperlinkRecord.LinkType urlLink

fileLink

private static final HyperlinkRecord.LinkType fileLink

workbookLink

private static final HyperlinkRecord.LinkType workbookLink

unknown

private static final HyperlinkRecord.LinkType unknown
Constructor Detail

HyperlinkRecord

protected HyperlinkRecord(Hyperlink h,
                          WritableSheet s)
Constructs this object from the a readable spreadsheet
Parameters:
hl - the hyperlink from the read spreadsheet

HyperlinkRecord

protected HyperlinkRecord(int col,
                          int row,
                          int lastcol,
                          int lastrow,
                          java.net.URL url)
Constructs a URL hyperlink to a range of cells
Parameters:
col - the column containing this hyperlink
row - the row containing this hyperlink
lastcol - the last column which activates this hyperlink
lastrow - the last row which activates this hyperlink
url - the hyperlink

HyperlinkRecord

protected HyperlinkRecord(int col,
                          int row,
                          int lastcol,
                          int lastrow,
                          java.io.File file)
Constructs a File hyperlink to a range of cells
Parameters:
col - the column containing this hyperlink
row - the row containing this hyperlink
lastcol - the last column which activates this hyperlink
lastrow - the last row which activates this hyperlink
file - the hyperlink

HyperlinkRecord

protected HyperlinkRecord(int col,
                          int row,
                          int lastcol,
                          int lastrow,
                          java.lang.String desc,
                          WritableSheet s,
                          int destcol,
                          int destrow,
                          int lastdestcol,
                          int lastdestrow)
Constructs a hyperlink to some cells within this workbook
Parameters:
col - the column containing this hyperlink
row - the row containing this hyperlink
lastcol - the last column which activates this hyperlink
lastrow - the last row which activates this hyperlink
desc - the contents of the cell which describe this hyperlink
sheet - the sheet containing the cells to be linked to
destcol - the column number of the first destination linked cell
destrow - the row number of the first destination linked cell
lastdestcol - the column number of the last destination linked cell
lastdestrow - the row number of the last destination linked cell
Method Detail

isFile

public boolean isFile()
Determines whether this is a hyperlink to a file
Returns:
TRUE if this is a hyperlink to a file, FALSE otherwise

isURL

public boolean isURL()
Determines whether this is a hyperlink to a web resource
Returns:
TRUE if this is a URL

isLocation

public boolean isLocation()
Determines whether this is a hyperlink to a location in this workbook
Returns:
TRUE if this is a link to an internal location

getRow

public int getRow()
Returns the row number of the top left cell
Returns:
the row number of this cell

getColumn

public int getColumn()
Returns the column number of the top left cell
Returns:
the column number of this cell

getLastRow

public int getLastRow()
Returns the row number of the bottom right cell
Returns:
the row number of this cell

getLastColumn

public int getLastColumn()
Returns the column number of the bottom right cell
Returns:
the column number of this cell

getURL

public java.net.URL getURL()
Gets the URL referenced by this Hyperlink
Returns:
the URL, or NULL if this hyperlink is not a URL

getFile

public java.io.File getFile()
Returns the local file eferenced by this Hyperlink
Returns:
the file, or NULL if this hyperlink is not a file

getData

public byte[] getData()
Gets the binary data to be written to the output file
Overrides:
getData in class WritableRecordData
Returns:
the data to write to file

toString

public java.lang.String toString()
A standard toString method
Overrides:
toString in class java.lang.Object
Returns:
the contents of this object as a string

getRange

public Range getRange()
Gets the range of cells which activate this hyperlink The get sheet index methods will all return -1, because the cells will all be present on the same sheet
Returns:
the range of cells which activate the hyperlink or NULL if this hyperlink has not been added to the sheet

setURL

public void setURL(java.net.URL url)
Sets the URL of this hyperlink
Parameters:
url - the url

setFile

public void setFile(java.io.File file)
Sets the file activated by this hyperlink
Parameters:
file - the file

setLocation

protected void setLocation(java.lang.String desc,
                           WritableSheet sheet,
                           int destcol,
                           int destrow,
                           int lastdestcol,
                           int lastdestrow)
Sets the location of the cells to be linked to within this workbook
Parameters:
desc - the label describing the link
sheet - the sheet containing the cells to be linked to
destcol - the column number of the first destination linked cell
destrow - the row number of the first destination linked cell
lastdestcol - the column number of the last destination linked cell
lastdestrow - the row number of the last destination linked cell

setLocation

private void setLocation(WritableSheet sheet,
                         int destcol,
                         int destrow,
                         int lastdestcol,
                         int lastdestrow)
Initializes the location from the data passed in
Parameters:
sheet - the sheet containing the cells to be linked to
destcol - the column number of the first destination linked cell
destrow - the row number of the first destination linked cell
lastdestcol - the column number of the last destination linked cell
lastdestrow - the row number of the last destination linked cell

insertRow

void insertRow(int r)
A row has been inserted, so adjust the range objects accordingly
Parameters:
r - the row which has been inserted

insertColumn

void insertColumn(int c)
A column has been inserted, so adjust the range objects accordingly
Parameters:
c - the column which has been inserted

removeRow

void removeRow(int r)
A row has been removed, so adjust the range objects accordingly
Parameters:
r - the row which has been inserted

removeColumn

void removeColumn(int c)
A column has been removed, so adjust the range objects accordingly
Parameters:
c - the column which has been removed

getURLData

private byte[] getURLData(byte[] cd)
Gets the hyperlink stream specific to a URL link
Parameters:
cd - the data common for all types of hyperlink
Returns:
the raw data for a URL hyperlink

getFileData

private byte[] getFileData(byte[] cd)
Gets the hyperlink stream specific to a local file link
Parameters:
cd - the data common for all types of hyperlink
Returns:
the raw data for a URL hyperlink

getShortName

private java.lang.String getShortName(java.lang.String s)
Gets the DOS short file name in 8.3 format of the name passed in
Parameters:
s - the name
Returns:
the dos short name

getLocationData

private byte[] getLocationData(byte[] cd)
Gets the hyperlink stream specific to a location link
Parameters:
cd - the data common for all types of hyperlink
Returns:
the raw data for a URL hyperlink

initialize

void initialize(WritableSheet s)
Initializes the range when this hyperlink is added to the sheet
Parameters:
s - the sheet containing this hyperlink

getContents

java.lang.String getContents()
Called by the worksheet. Gets the string contents to put into the cell containing this hyperlink
Returns:
the string contents for the hyperlink cell