📄 superlink.java
字号:
package html_parser;
import java.net.MalformedURLException;
import java.net.URL;
class NotLinkException extends Exception{
final static long serialVersionUID = 8272;
}
public class SuperLink {
private URL url;
String describe;
public SuperLink(Tag tag, URL currentURL) throws NotLinkException {
String tagString = tag.toString();
if (tagString.indexOf("a ") != 0) throw new NotLinkException();
int index = tagString.indexOf("href");
if (index == -1) throw new NotLinkException();
int i1;
boolean equalBefore = false;
boolean quoteBefore = false;
for (i1=index+4;i1<tagString.length();i1++) {
if (tagString.charAt(i1) == '=') {
if (equalBefore) throw new NotLinkException();
else equalBefore = true;
} else if (tagString.charAt(i1) == '\"') {
if (quoteBefore) throw new NotLinkException();
else quoteBefore = true;
} else if (tagString.charAt(i1) != ' ') break;
}
int i2;
for (i2=i1+1;i2<tagString.length();i2++) {
if (tagString.charAt(i2) == ' ' || tagString.charAt(i2) == '\"') break;
}
try {
url = new URL(currentURL, StringTools.stringTransfer(tagString.substring(i1, i2)));
} catch (MalformedURLException err) {
throw new NotLinkException();
}
}
public URL getURL() {
return url;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -