1 /* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================== */
17 package org
.apache
.poi
.hssf
.usermodel
;
19 import org
.apache
.poi
.hssf
.record
.EscherAggregate
;
20 import org
.apache
.poi
.hssf
.record
.NoteRecord
;
21 import org
.apache
.poi
.hssf
.record
.TextObjectRecord
;
22 import org
.apache
.poi
.hssf
.record
.HyperlinkRecord
;
23 import org
.apache
.poi
.ddf
.*;
26 import java
.util
.List
;
27 import java
.util
.Iterator
;
30 * Represents an Excel hyperlink.
32 * @author Yegor Kozlov (yegor at apache dot org)
34 public class HSSFHyperlink
{
37 * Link to a existing file or web page
39 public static final int LINK_URL
= 1;
42 * Link to a place in this document
44 public static final int LINK_DOCUMENT
= 2;
47 * Link to an E-mail address
49 public static final int LINK_EMAIL
= 3;
54 public static final int LINK_FILE
= 4;
57 * Low-level record object that stores the actual hyperlink data
59 protected HyperlinkRecord record
= null;
62 * If we create a new hypelrink remember its type
64 protected int link_type
;
67 * Construct a new hyperlink
69 * @param type the type of hyperlink to create
71 public HSSFHyperlink( int type
)
73 this.link_type
= type
;
74 record
= new HyperlinkRecord();
84 record
.newDocumentLink();
90 * Initialize the hyperlink by a <code>HyperlinkRecord</code> record
94 protected HSSFHyperlink( HyperlinkRecord record
)
100 * Return the row of the first cell that contains the hyperlink
102 * @return the 0-based row of the cell that contains the hyperlink
104 public int getFirstRow(){
105 return record
.getFirstRow();
109 * Set the row of the first cell that contains the hyperlink
111 * @param row the 0-based row of the first cell that contains the hyperlink
113 public void setFirstRow(int row
){
114 record
.setFirstRow(row
);
118 * Return the row of the last cell that contains the hyperlink
120 * @return the 0-based row of the last cell that contains the hyperlink
122 public int getLastRow(){
123 return record
.getLastRow();
127 * Set the row of the last cell that contains the hyperlink
129 * @param row the 0-based row of the last cell that contains the hyperlink
131 public void setLastRow(int row
){
132 record
.setLastRow(row
);
136 * Return the column of the first cell that contains the hyperlink
138 * @return the 0-based column of the first cell that contains the hyperlink
140 public short getFirstColumn(){
141 return record
.getFirstColumn();
145 * Set the column of the first cell that contains the hyperlink
147 * @param col the 0-based column of the first cell that contains the hyperlink
149 public void setFirstColumn(short col
){
150 record
.setFirstColumn(col
);
154 * Return the column of the last cell that contains the hyperlink
156 * @return the 0-based column of the last cell that contains the hyperlink
158 public short getLastColumn(){
159 return record
.getLastColumn();
163 * Set the column of the last cell that contains the hyperlink
165 * @param col the 0-based column of the last cell that contains the hyperlink
167 public void setLastColumn(short col
){
168 record
.setLastColumn(col
);
172 * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
174 * @return the address of this hyperlink
176 public String
getAddress(){
177 return record
.getAddress();
181 * Hypelink address. Depending on the hyperlink type it can be URL, e-mail, patrh to a file, etc.
183 * @param address the address of this hyperlink
185 public void setAddress(String address
){
186 record
.setAddress(address
);
190 * Return text label for this hyperlink
192 * @return text to display
194 public String
getLabel(){
195 return record
.getLabel();
199 * Sets text label for this hyperlink
201 * @param label text label for this hyperlink
203 public void setLabel(String label
){
204 record
.setLabel(label
);
208 * Return the type of this hyperlink
210 * @return the type of this hyperlink
212 protected int getType(){