aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-17 09:20:21 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-17 09:20:21 +0000
commit9816a7ccd8578d31ea4ce62af2457951ed71b399 (patch)
tree06ec3b9e3c5eb124f7d95a7a6b49920e8f0a0746 /src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
parentfe46099398636324c2fc79aea16bdd2469aacf20 (diff)
downloadpoi-9816a7ccd8578d31ea4ce62af2457951ed71b399.tar.gz
poi-9816a7ccd8578d31ea4ce62af2457951ed71b399.zip
bug 59873: replace Hyperlink.LINK_* int constants with HyperlinkType enum
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753035 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java86
1 files changed, 46 insertions, 40 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
index 1f3175121c..d91498679c 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
@@ -16,37 +16,15 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.record.HyperlinkRecord;
import org.apache.poi.ss.usermodel.Hyperlink;
+import org.apache.poi.util.Internal;
/**
* Represents an Excel hyperlink.
*/
-public class HSSFHyperlink implements Hyperlink {
-
- /**
- * Link to an existing file or web page
- * May be deprecated in the future. Consider using {@link Hyperlink#LINK_URL} instead.
- */
- public static final int LINK_URL = Hyperlink.LINK_URL;
-
- /**
- * Link to a place in this document
- * May be deprecated in the future. Consider using {@link Hyperlink#LINK_DOCUMENT} instead.
- */
- public static final int LINK_DOCUMENT = Hyperlink.LINK_DOCUMENT;
-
- /**
- * Link to an E-mail address
- * May be deprecated in the future. Consider using {@link Hyperlink#LINK_EMAIL} instead.
- */
- public static final int LINK_EMAIL = Hyperlink.LINK_EMAIL;
-
- /**
- * Link to a file
- * May be deprecated in the future. Consider using {@link Hyperlink#LINK_FILE} instead.
- */
- public static final int LINK_FILE = Hyperlink.LINK_FILE;
+public class HSSFHyperlink implements Hyperlink {
/**
* Low-level record object that stores the actual hyperlink data
@@ -56,26 +34,43 @@ public class HSSFHyperlink implements Hyperlink {
/**
* If we create a new hyperlink remember its type
*/
- final protected int link_type;
-
+ final protected HyperlinkType link_type;
+
/**
* Construct a new hyperlink
+ *
+ * This method is internal to be used only by {@link HSSFCreationHelper#createHyperlink(int)}
*
* @param type the type of hyperlink to create
+ * @deprecated POI 3.15 beta 3
*/
- public HSSFHyperlink( int type )
+ @Internal(since="3.15 beta 3")
+ protected HSSFHyperlink( int type )
+ {
+ this(HyperlinkType.forInt(type));
+ }
+
+ /**
+ * Construct a new hyperlink
+ *
+ * This method is internal to be used only by {@link HSSFCreationHelper#createHyperlink(int)}
+ *
+ * @param type the type of hyperlink to create
+ */
+ @Internal(since="3.15 beta 3")
+ protected HSSFHyperlink( HyperlinkType type )
{
this.link_type = type;
record = new HyperlinkRecord();
switch(type){
- case LINK_URL:
- case LINK_EMAIL:
+ case URL:
+ case EMAIL:
record.newUrlLink();
break;
- case LINK_FILE:
+ case FILE:
record.newFileLink();
break;
- case LINK_DOCUMENT:
+ case DOCUMENT:
record.newDocumentLink();
break;
default:
@@ -94,19 +89,19 @@ public class HSSFHyperlink implements Hyperlink {
link_type = getType(record);
}
- private int getType(HyperlinkRecord record) {
- int link_type;
+ private static HyperlinkType getType(HyperlinkRecord record) {
+ HyperlinkType link_type;
// Figure out the type
if (record.isFileLink()) {
- link_type = LINK_FILE;
+ link_type = HyperlinkType.FILE;
} else if(record.isDocumentLink()) {
- link_type = LINK_DOCUMENT;
+ link_type = HyperlinkType.DOCUMENT;
} else {
if(record.getAddress() != null &&
record.getAddress().startsWith("mailto:")) {
- link_type = LINK_EMAIL;
+ link_type = HyperlinkType.EMAIL;
} else {
- link_type = LINK_URL;
+ link_type = HyperlinkType.URL;
}
}
return link_type;
@@ -119,7 +114,7 @@ public class HSSFHyperlink implements Hyperlink {
link_type = getType(record);
}
else {
- link_type = other.getType();
+ link_type = other.getTypeEnum();
record = new HyperlinkRecord();
setFirstRow(other.getFirstRow());
setFirstColumn(other.getFirstColumn());
@@ -275,9 +270,20 @@ public class HSSFHyperlink implements Hyperlink {
* Return the type of this hyperlink
*
* @return the type of this hyperlink
+ * @see HyperlinkType#forInt
+ */
+ @Override
+ public int getType() {
+ return link_type.getCode();
+ }
+
+ /**
+ * Return the type of this hyperlink
+ *
+ * @return the type of this hyperlink
*/
@Override
- public int getType(){
+ public HyperlinkType getTypeEnum() {
return link_type;
}