📄 httpmethodtype.java
字号:
package lib.commons.net.http;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import lib.commons.logging.Log;
public final class HttpMethodType {
private HttpMethodBase _method;
private Log _log;
private HttpMethodType(HttpMethodBase method) {
_method = method;
_log = lib.commons.logging.LogFactory.getLog("HttpMethod - "
+ method.getName());
}
public String getName() {
return _method.getName();
}
public HttpMethodBase getMethodInstance(String uri) {
HttpMethodBase method = null;
try {
method = (HttpMethodBase) _method.getClass().getConstructor(
new Class[] { String.class }).newInstance(
new Object[] { uri });
} catch (Exception err) {
_log.error(err.getMessage(), err);
}
return method;
}
public String toString() {
return getName();
}
public static final HttpMethodType GET = new HttpMethodType(new GetMethod());
public static final HttpMethodType POST = new HttpMethodType(
new PostMethod());
private static final HttpMethodType[] _methodTypes = new HttpMethodType[] {
GET, POST };
public static final HttpMethodType getHttpMethodTypeByName(String name) {
HttpMethodType methodType = null;
for (int i = 0; i < _methodTypes.length; i++) {
if (_methodTypes[i].getName().equalsIgnoreCase(name)) {
methodType = _methodTypes[i];
break;
}
}
return methodType;
}
public static void main(String[] args) {
java.util.regex.Pattern p = java.util.regex.Pattern.compile(
"<(img|image)[^>]+src=['\"]([^'\"]+)[\"']",
java.util.regex.Pattern.CASE_INSENSITIVE
| java.util.regex.Pattern.MULTILINE);
java.util.regex.Matcher m = p
.matcher("<img src=\"http://www.datuu.com/templates/rhuk_solarflare_ii/images/datuu_logo.gif?A=1&amp;2&b=2\" width=\"200\" height=\"70\" />\r\n<image src=\"http://www.datuu.com/templates/rhuk_solarflare_ii/images/datuu_logo.gif\" width=\"200\" height=\"70\" />");
while (m.find()) {
String url = m.group(2);
System.out.println(url.replace("&", "&"));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -