org.ajaxanywhere.parser.RegexResponseParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jweb-common Show documentation
Show all versions of jweb-common Show documentation
本项目主要弥补在使用mybatis3+springmvc+jquery easyui快速搭建web应用系统是遇到的框架不足.
主要工作包括:
1,扩展了ApplicationContextAware,通过单例注入spring容器,提供spring容器外的bean获取方法
2,扩展了apache shiro框架,统一了安全结构
3,扩展了mybatis3拦截器,在两个拦截器中自动完成分页注入,实现内存分页。
4,分页设计数据库方言
5,提供了一个easyuigrid的模型
6,提供了java泛型的jstl
7, xml工具包等一些小工具
/**
*
*/
package org.ajaxanywhere.parser;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* RegexResponseParser.java is
*
* events
*
* @author Alex
*
*/
@SuppressWarnings("rawtypes")
public class RegexResponseParser implements ResponseParser {
private Pattern imgTag=Pattern.compile(")", Pattern.CASE_INSENSITIVE);
@SuppressWarnings("unchecked")
public HTMLBlock parse(String html) {
long tstart=System.currentTimeMillis();
HTMLBlock ret=new HTMLBlock();
final List scripts = ret.getScriptContents();
final Set images = ret.getImages();
//find images to reload
Matcher matcher=imgTag.matcher(html);
while(matcher.find()){
int start = matcher.start();
StringBuilder imgHtml = new StringBuilder(256);
for(int i=start+5;i') break;
imgHtml.append(html.charAt(i));
}
if(imgHtml.length()==0) continue;
String src=abstractImageSrcAttribute(imgHtml);
if(src==null) continue;
images.add(src);
imgHtml = null;
}
// find all scripts
List markers=new ArrayList();
StringMatcher endOfScript=new StringMatcher("");
StringMatcher startOfCmm=new StringMatcher("");
matcher=scriptTag.matcher(html);
while(matcher.find()){
String g=matcher.group();
int start = matcher.start()+g.length();
int markStart=start;
if(!g.endsWith(">")){//not