📄 anchor.java
字号:
package com.gameislive.browser;
import java.util.Vector;
import com.gameislive.browser.element.FormElement;
/**
* anchor,类似超链接,用于提交FormElement的内容
*
* @author pan
*
*/
public class Anchor{
Browser browser;
/**
* 提交方法:GET or POST
*/
String method;
/**
* 提交链接
*/
String href;
/**
* 提交时,需要提交的元素
*/
Vector postfieldName = new Vector();
/**
* 提交时,需要提交的元素值
*/
Vector postfieldValue = new Vector();
public Anchor(Browser browser){
this.browser = browser;
}
public void setMethod(String method){
if(method==null || method.equals("")){
this.method = "GET";
}else{
this.method = method.toUpperCase();
}
}
public void setHref(String href){
this.href = href;
}
/**
* 添加一个postfield字段,注意参数value可以是字符串,也可以是一个FormElement元素
* @param name
* @param value
*/
public void addPostfield(String name,Object value){
postfieldName.addElement(name);
postfieldValue.addElement(value);
}
public String getMethod(){
return method;
}
public String getHref(){
return href;
}
public String getAnchorString(){
int num = postfieldName.size();
String string = null;
for(int i=0;i<num;i++){
String name = (String)postfieldName.elementAt(i);
Object value = postfieldValue.elementAt(i);
if(value instanceof FormElement){
if(string == null){
string = name+"="+((FormElement)value).getValue();
}else{
string += "&"+name+"="+((FormElement)value).getValue();
}
}else{
if(string == null){
string = name+"="+(String)value;
}else{
string += "&"+name+"="+(String)value;
}
}
}
//#if DEBUG
//# System.out.println("ANCHOR: "+string);
//#endif
return string;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -