📄 htmlstream.java
字号:
package com.lightspeedleader.browser;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Image;
import java.io.*;
import java.util.Vector;
public class HTMLStream {
HttpConnection conn;
InputStream is;
ByteArrayInputStream FE;
InputStreamReader FF;
int total;
int _fld0100;
byte buffer[];
String _fld0101;
String _fld0102;
String _fld0103;
public static int vx = 0;
public static int vy = 0;
public static int slen;
Vector sv;
int CanvasWidth;
int CanvasHeight;
Font font;
int fontHeight;
int _fld0104;
int _fld0105;
int _fld0106;
int _fld0107;
public static int lcolor = 255;
Vector _fld0108;
HotSpot hs;
boolean _fld0109;
public static int hsindex = 0;
public static Vector hsvector = new Vector(1);
public static int formindex = -1;
public static Vector formvector = new Vector(1);
boolean _fld010A;
boolean _fld010B;
boolean _fld010C;
String _fld010D;
boolean _fld010E;
boolean _fld010F;
boolean _fld0110;
boolean _fld0111;
int _fld0112;
int _fld0113[];
int _fld0114;
public static GifFrame GF;
public static VideoFrame VF;
public static String ErrorLine;
public HTMLStream(String s) {
_fld0104 = 3;
_fld0105 = 3;
_fld0106 = 0xffffff;
_fld0107 = 0;
_fld0108 = new Vector(1);
_fld0109 = false;
_fld010A = false;
_fld010B = false;
_fld010C = false;
_fld010D = "";
_fld010E = false;
_fld010F = false;
_fld0110 = false;
_fld0111 = false;
_fld0112 = 0;
_fld0113 = new int[8];
_fld0114 = 16;
HTMLStreamX(s, "");
}
HTMLStream(String s, String s1) {
_fld0104 = 3;
_fld0105 = 3;
_fld0106 = 0xffffff;
_fld0107 = 0;
_fld0108 = new Vector(1);
_fld0109 = false;
_fld010A = false;
_fld010B = false;
_fld010C = false;
_fld010D = "";
_fld010E = false;
_fld010F = false;
_fld0110 = false;
_fld0111 = false;
_fld0112 = 0;
_fld0113 = new int[8];
_fld0114 = 16;
HTMLStreamX(s, s1);
}
public void HTMLStreamX(String s, String s1) {
Runtime.getRuntime().gc();
MapCanvas _tmp = JCellBrowser.mc;
MapCanvas.LoadFlag = true;
JCellBrowser.mc.repaint();
JCellBrowser.mc.serviceRepaints();
if (!s.startsWith("http://")) {
s = "http://" + s;
}
_fld0101 = s;
_fld0102 = Tools.GetURLRoot(_fld0101);
_fld0103 = Tools.GetURLBase(_fld0101);
total = 0;
_fld0100 = 0;
buffer = null;
int i = 999;
try {
if ((buffer = JCellBrowser.cachepool.getCache(s)) == null) {
conn = (HttpConnection) Connector.open(s);
if (s1.length() > 0) {
conn.setRequestMethod("POST");
conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
conn.setRequestProperty("Content-Language", "en-US");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", "" + s1.length());
conn.setRequestProperty("Cache-Control", "no-store");
conn.setRequestProperty("Pragma", "no-cache");
conn.setRequestProperty("Expires", "Tue, 1 Jul 1997 00:00:00 GMT");
OutputStream outputstream = conn.openOutputStream();
outputstream.write(s1.getBytes());
outputstream.flush();
outputstream.close();
}
if (((i = conn.getResponseCode()) == 301 || (i = conn.getResponseCode()) == 302) && s1.length() == 0) {
s = conn.getHeaderField("Location");
if (s != null) {
JCellBrowser.pageurl = s;
}
_fld0101 = s;
_fld0102 = Tools.GetURLRoot(_fld0101);
_fld0103 = Tools.GetURLBase(_fld0101);
conn.close();
conn = (HttpConnection) Connector.open(s);
}
if ((i = conn.getResponseCode()) != 200) {
throw new Exception();
}
total = (int) conn.getLength();
if (total > 0) {
buffer = new byte[total];
DataInputStream datainputstream = conn.openDataInputStream();
datainputstream.readFully(buffer);
datainputstream.close();
if (s1.length() == 0 && s.indexOf('?') == -1) {
JCellBrowser.cachepool.setCache(s, buffer);
}
} else {
is = conn.openInputStream();
}
} else {
total = buffer.length;
}
}
catch (Exception exception) {
String s2 = "<center>JCellBrowser Error<br>" + i + "</center><hr size=2>Document <u>" + _fld0101 + "</u> is not found.";
if (i == 999) {
s2 = s2 + "<hr>" + exception.toString();
}
buffer = s2.getBytes();
total = buffer.length;
}
if (total > 0) {
FE = new ByteArrayInputStream(buffer, 0, total);
try {
FF = new InputStreamReader(FE, JCellBrowser.encoding);
}
catch (Exception exception1) {
FF = new InputStreamReader(FE);
}
} else {
try {
FF = new InputStreamReader(is, JCellBrowser.encoding);
}
catch (Exception exception2) {
FF = new InputStreamReader(is);
}
}
sv = new Vector(32);
_mth0100();
buffer = null;
try {
if (FF != null) {
FF.close();
FF = null;
}
if (FE != null) {
FE.close();
FE = null;
}
if (is != null) {
is.close();
is = null;
}
if (conn != null) {
conn.close();
conn = null;
}
}
catch (Exception exception3) {
}
CanvasWidth = MapCanvas.CanvasWidth;
CanvasHeight = MapCanvas.CanvasHeight;
font = MapCanvas.font;
fontHeight = 0;
MapCanvas.VG.reset();
render(MapCanvas.VG);
sv.removeAllElements();
sv = null;
MapCanvas _tmp1 = JCellBrowser.mc;
MapCanvas.LoadFlag = false;
}
String FE() {
StringBuffer stringbuffer = new StringBuffer();
int i = -1;
do {
try {
if ((i = FF.read()) == -1) {
break;
}
char c = (char) i;
if (c == '\n') {
break;
}
if (c != '\r') {
stringbuffer.append(c);
}
continue;
}
catch (Exception exception) {
}
break;
} while (true);
if (stringbuffer.length() == 0) {
if (i == -1) {
return null;
} else {
return "";
}
} else {
return stringbuffer.toString();
}
}
String FF(String s) {
if (s.startsWith("http://")) {
return s;
}
if (s.startsWith("#")) {
return JCellBrowser.pageurl;
}
if (s.startsWith("/") || s.startsWith("\\")) {
s = s.substring(1);
return _fld0102 + s;
} else {
return _fld0103 + s;
}
}
void _mth0100() {
String s = "";
do {
String s1;
if ((s1 = FE()) == null) {
break;
}
s1 = s1.trim();
if (s1.length() != 0) {
if (s.length() > 0) {
s = s + " ";
}
do {
int i;
if ((i = s1.indexOf("<")) != -1) {
s = s + s1.substring(0, i);
if (s.length() > 0) {
sv.addElement(s);
}
s = "<";
s1 = s1.substring(i + 1);
}
if ((i = s1.indexOf(">")) != -1) {
s = s + s1.substring(0, i + 1);
if (s.length() > 0) {
sv.addElement(s);
}
s = "";
s1 = s1.substring(i + 1);
}
} while (s1.indexOf("<") != -1 || s1.indexOf(">") != -1);
s = s + s1;
}
} while (true);
if (s.length() > 0) {
sv.addElement(s);
}
}
Vector _mth0101(String s) {
Vector vector = new Vector(1);
String s1 = "";
String s2;
for (int i = 1; (s2 = Tools.GetTokenZ(s, i, '"', true)) != null; i++) {
if (i % 2 == 0) {
s2 = Tools.RepString(s2, " ", "_");
}
s1 = s1 + s2;
}
s1 = Tools.RepString(s1, "= ", "=");
s1 = Tools.RepString(s1, "<", "");
s1 = Tools.RepString(s1, "/>", ">");
s1 = Tools.RepString(s1, ">", "");
String s3;
for (int j = 1; (s3 = Tools.GetTokenZ(s1, j, ' ', true)) != null; j++) {
vector.addElement(s3);
}
return vector;
}
public int strWidth(String s) {
return font.stringWidth(s);
}
int strHeight() {
if (fontHeight == 0) {
fontHeight = font.getHeight() - 2;
}
return fontHeight;
}
void _mth0102() {
_fld0108.removeAllElements();
}
void _mth0103(VirtualGraphics virtualgraphics, String s, int i, int j) {
if (_fld0109) {
_fld0109 = false;
if (s.startsWith(" ")) {
hs.bx += slen;
}
}
if (!_fld010C) {
virtualgraphics.drawString(s, i, j, 20);
if (_fld010A) {
virtualgraphics.drawString(s, i + 1, j, 20);
}
if (_fld010F || _fld0111) {
int k = j + strHeight();
int l = i;
if (_fld0110 && l != 0) {
virtualgraphics.drawLine(l + slen, k, l + strWidth(s), k);
} else {
virtualgraphics.drawLine(l, k, l + strWidth(s), k);
}
_fld0110 = false;
}
} else {
boolean flag = false;
boolean flag1 = false;
if (_fld010A) {
flag = true;
}
if (_fld010F || _fld0111) {
flag1 = true;
}
CenterText centertext = new CenterText(s, flag, flag1);
_fld0108.addElement(centertext);
if (_fld010E) {
String s1 = "";
for (int i1 = 0; i1 < _fld0108.size(); i1++) {
CenterText centertext1 = (CenterText) _fld0108.elementAt(i1);
s1 = s1 + centertext1.text;
}
int j1 = (CanvasWidth - strWidth(s1)) / 2;
for (int k1 = 0; k1 < _fld0108.size(); k1++) {
CenterText centertext2 = (CenterText) _fld0108.elementAt(k1);
virtualgraphics.drawString(centertext2.text, j1, j, 20);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -