本文整理汇总了Java中net.sf.cglib.beans.BeanMap.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java BeanMap.putAll方法的具体用法?Java BeanMap.putAll怎么用?Java BeanMap.putAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.beans.BeanMap
的用法示例。
在下文中一共展示了BeanMap.putAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ "unchecked" })
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean) {
Map<String, Object> fieldMap = new HashMap<String, Object>();
Set<Field> jsonPathFields = ReflectionUtils.getAllFields(bean.getClass(), ReflectionUtils.withAnnotation(JSONPath.class));
String jsonStr = response.getContent();
jsonStr = jsonp2Json(jsonStr);
if (jsonStr == null) {
return;
}
try {
Object json = JSON.parse(jsonStr);
for (Field field : jsonPathFields) {
Object value = injectJsonField(request, field, json);
if(value != null) {
fieldMap.put(field.getName(), value);
}
}
} catch(JSONException ex) {
//throw new RenderException(ex.getMessage(), bean.getClass());
RenderException.log("json parse error : " + request.getUrl(), bean.getClass(), ex);
}
beanMap.putAll(fieldMap);
}
示例2: copy
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
public T copy(Map<String, Object> map) {
checkNull(map, "map cannot be null!");
checkNull(targetClass, "target class cannot be null!");
try {
T bean = ReflectionUtil.newInstance(targetClass);
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
} catch (Exception e) {
throw new RuntimeException("create object fail, class: " + targetClass.getName(), e);
}
}
示例3: render
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean) {
Map<String, Object> fieldMap = new HashMap<String, Object>();
Set<Field> htmlFields = ReflectionUtils.getAllFields(bean.getClass(), ReflectionUtils.withAnnotation(HtmlField.class));
for (Field htmlField : htmlFields) {
Object value = injectHtmlField(request, response, htmlField, bean.getClass());
if(value != null) {
fieldMap.put(htmlField.getName(), value);
}
}
beanMap.putAll(fieldMap);
}
示例4: render
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean) {
Map<String, Object> fieldMap = new HashMap<String, Object>();
Set<Field> imageFields = ReflectionUtils.getAllFields(bean.getClass(), ReflectionUtils.withAnnotation(Image.class));
for (Field imageField : imageFields) {
Object value = injectImageField(request, beanMap, bean, imageField);
if(value != null) {
fieldMap.put(imageField.getName(), value);
}
}
beanMap.putAll(fieldMap);
}
示例5: render
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ "unchecked" })
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean) {
Context cx = Context.enter();
ScriptableObject scope = cx.initSafeStandardObjects();
String windowScript = "var window = {};var document = {};";
cx.evaluateString(scope, windowScript, "window", 1, null);
HtmlParser parser = new HtmlParser(request.getUrl(), response.getContent());
for (Element ele : parser.$("script")) {
String sc = ele.html();
if (StringUtils.isNotEmpty(sc)) {
try {
cx.evaluateString(scope, sc, "", 1, null);
} catch (Exception ex) {
// ex.printStackTrace();
}
}
}
Map<String, Object> fieldMap = new HashMap<String, Object>();
Set<Field> jsVarFields = ReflectionUtils.getAllFields(bean.getClass(), ReflectionUtils.withAnnotation(JSVar.class));
for (Field jsVarField : jsVarFields) {
Object value = injectJsVarField(request, beanMap, jsVarField, cx, scope);
if(value != null) {
fieldMap.put(jsVarField.getName(), value);
}
}
beanMap.putAll(fieldMap);
Context.exit();
}
示例6: render
import net.sf.cglib.beans.BeanMap; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean) {
Map<String, Object> fieldMap = new HashMap<String, Object>();
Set<Field> ajaxFields = ReflectionUtils.getAllFields(bean.getClass(), ReflectionUtils.withAnnotation(Ajax.class));
for (Field ajaxField : ajaxFields) {
Object value = injectAjaxField(request, beanMap, ajaxField);
if(value != null) {
fieldMap.put(ajaxField.getName(), value);
}
}
beanMap.putAll(fieldMap);
}