📄 hyperlinkrecord.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: HyperlinkRecord.java
package jxl.read.biff;
import common.Logger;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import jxl.*;
import jxl.biff.*;
// Referenced classes of package jxl.read.biff:
// Record
public class HyperlinkRecord extends RecordData
implements Hyperlink
{
private static class LinkType
{
private LinkType()
{
}
LinkType(_cls1 x0)
{
this();
}
}
private static Logger logger;
private int firstRow;
private int lastRow;
private int firstColumn;
private int lastColumn;
private URL url;
private File file;
private String location;
private SheetRangeImpl range;
private LinkType linkType;
private static final LinkType urlLink = new LinkType(null);
private static final LinkType fileLink = new LinkType(null);
private static final LinkType workbookLink = new LinkType(null);
private static final LinkType unknown = new LinkType(null);
static Class class$jxl$read$biff$HyperlinkRecord; /* synthetic field */
HyperlinkRecord(Record t, Sheet s, WorkbookSettings ws)
{
super(t);
linkType = unknown;
byte data[] = getRecord().getData();
firstRow = IntegerHelper.getInt(data[0], data[1]);
lastRow = IntegerHelper.getInt(data[2], data[3]);
firstColumn = IntegerHelper.getInt(data[4], data[5]);
lastColumn = IntegerHelper.getInt(data[6], data[7]);
range = new SheetRangeImpl(s, firstColumn, firstRow, lastColumn, lastRow);
int options = IntegerHelper.getInt(data[28], data[29], data[30], data[31]);
boolean description = (options & 0x14) != 0;
int startpos = 32;
int descbytes = 0;
if(description)
{
int descchars = IntegerHelper.getInt(data[startpos], data[startpos + 1], data[startpos + 2], data[startpos + 3]);
descbytes = descchars * 2 + 4;
}
startpos += descbytes;
boolean targetFrame = (options & 0x80) != 0;
int targetbytes = 0;
if(targetFrame)
{
int targetchars = IntegerHelper.getInt(data[startpos], data[startpos + 1], data[startpos + 2], data[startpos + 3]);
targetbytes = targetchars * 2 + 4;
}
startpos += targetbytes;
if((options & 0x3) == 3)
{
linkType = urlLink;
if(data[startpos] == 3)
linkType = fileLink;
} else
if((options & 0x1) != 0)
{
linkType = fileLink;
if(data[startpos] == -32)
linkType = urlLink;
} else
if((options & 0x8) != 0)
linkType = workbookLink;
if(linkType == urlLink)
{
String urlString = null;
try
{
startpos += 16;
int bytes = IntegerHelper.getInt(data[startpos], data[startpos + 1], data[startpos + 2], data[startpos + 3]);
urlString = StringHelper.getUnicodeString(data, bytes / 2 - 1, startpos + 4);
url = new URL(urlString);
}
catch(MalformedURLException e)
{
logger.warn("URL " + urlString + " is malformed. Trying a file");
try
{
linkType = fileLink;
file = new File(urlString);
}
catch(Exception e3)
{
logger.warn("Cannot set to file. Setting a default URL");
try
{
linkType = urlLink;
url = new URL("http://www.andykhan.com/jexcelapi/index.html");
}
catch(MalformedURLException e2) { }
}
}
catch(Throwable e)
{
StringBuffer sb1 = new StringBuffer();
StringBuffer sb2 = new StringBuffer();
CellReferenceHelper.getCellReference(firstColumn, firstRow, sb1);
CellReferenceHelper.getCellReference(lastColumn, lastRow, sb2);
sb1.insert(0, "Exception when parsing URL ");
sb1.append('"').append(sb2.toString()).append("\". Using default.");
logger.warn(sb1, e);
try
{
url = new URL("http://www.andykhan.com/jexcelapi/index.html");
}
catch(MalformedURLException e2) { }
}
} else
if(linkType == fileLink)
try
{
startpos += 16;
int upLevelCount = IntegerHelper.getInt(data[startpos], data[startpos + 1]);
int chars = IntegerHelper.getInt(data[startpos + 2], data[startpos + 3], data[startpos + 4], data[startpos + 5]);
String fileName = StringHelper.getString(data, chars - 1, startpos + 6, ws);
StringBuffer sb = new StringBuffer();
for(int i = 0; i < upLevelCount; i++)
sb.append("..\\");
sb.append(fileName);
file = new File(sb.toString());
}
catch(Throwable e)
{
e.printStackTrace();
logger.warn("Exception when parsing file " + e.getClass().getName() + ".");
file = new File(".");
}
else
if(linkType == workbookLink)
{
int chars = IntegerHelper.getInt(data[32], data[33], data[34], data[35]);
location = StringHelper.getUnicodeString(data, chars - 1, 36);
} else
{
logger.warn("Cannot determine link type");
return;
}
}
public boolean isFile()
{
return linkType == fileLink;
}
public boolean isURL()
{
return linkType == urlLink;
}
public boolean isLocation()
{
return linkType == workbookLink;
}
public int getRow()
{
return firstRow;
}
public int getColumn()
{
return firstColumn;
}
public int getLastRow()
{
return lastRow;
}
public int getLastColumn()
{
return lastColumn;
}
public URL getURL()
{
return url;
}
public File getFile()
{
return file;
}
public Record getRecord()
{
return super.getRecord();
}
public Range getRange()
{
return range;
}
public String getLocation()
{
return location;
}
static Class class$(String x0)
{
return Class.forName(x0);
ClassNotFoundException x1;
x1;
throw new NoClassDefFoundError(x1.getMessage());
}
static
{
logger = Logger.getLogger(class$jxl$read$biff$HyperlinkRecord != null ? class$jxl$read$biff$HyperlinkRecord : (class$jxl$read$biff$HyperlinkRecord = class$("jxl.read.biff.HyperlinkRecord")));
}
// Unreferenced inner classes:
/* anonymous class */
static class _cls1
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -