当前位置: 首页>>代码示例>>Java>>正文


Java BeanMap类代码示例

本文整理汇总了Java中net.sf.cglib.beans.BeanMap的典型用法代码示例。如果您正苦于以下问题:Java BeanMap类的具体用法?Java BeanMap怎么用?Java BeanMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BeanMap类属于net.sf.cglib.beans包,在下文中一共展示了BeanMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Override
public void render(HttpRequest request, HttpResponse response, BeanMap beanMap, SpiderBean bean, Field field) {
	ProductList jd = (ProductList)bean;
	StringBuffer sb = new StringBuffer();
	/*for(String code : jd.getCodes()) {
		sb.append("J_").append(code).append(",");
	}*/
	String skuIds = sb.toString();
	try {
		skuIds = URLEncoder.encode(skuIds, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	String url = "http://p.3.cn/prices/mgets?skuIds="+skuIds;
	HttpRequest subRequest = request.subRequest(url);
	try {
		HttpResponse subReponse = DownloaderContext.download(subRequest);
		String json = subReponse.getContent();
		List<JDPrice> prices = JSON.parseArray(json, JDPrice.class);
		beanMap.put(field.getName(), prices);
	} catch(Exception ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:xtuhcy,项目名称:gecco,代码行数:25,代码来源:JdPricesFieldRender.java

示例2: 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);
}
 
开发者ID:xtuhcy,项目名称:gecco,代码行数:25,代码来源:JsonFieldRender.java

示例3: injectImageField

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Object injectImageField(HttpRequest request, BeanMap beanMap, SpiderBean bean, Field field) {
	Object value = beanMap.get(field.getName());
	if(value == null) {
		return null;
	}
	if(value instanceof Collection) {
		Collection<Object> collection = (Collection<Object>)value;
		for(Object item : collection) {
			String imgUrl = downloadImage(request, field, item.toString());
			item = imgUrl;
		}
		return collection;
	} else {
		return downloadImage(request, field, value.toString());
	}
}
 
开发者ID:xtuhcy,项目名称:gecco,代码行数:18,代码来源:ImageFieldRender.java

示例4: decode

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
public void decode(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    DateTime dateTime = (DateTime) annotation;
    byte[] buf = bitBuffer.readBytes(new byte[6]);
    if(dateTime.isBCDCode())
        beanMap.put(field.getName(), ByteBufferUtil.bcdbuf2Date(buf));
    else
        beanMap.put(field.getName(), ByteBufferUtil.buf2Date(buf));
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:9,代码来源:DateTimeCoder.java

示例5: encode

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
public void encode(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    DateTime dateTime = (DateTime) annotation;
    long millSec = (Long) beanMap.get(field.getName());
    if(dateTime.isBCDCode())
        bitBuffer.write(ByteBufferUtil.date2bcdbuf(millSec));
    else
        bitBuffer.write(ByteBufferUtil.date2buf(millSec));
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:9,代码来源:DateTimeCoder.java

示例6: toPrettyHexString

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Override
public String toPrettyHexString(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    DateTime dateTime = (DateTime) annotation;
    long millSec = (Long) beanMap.get(field.getName());
    if(dateTime.isBCDCode()) {
        return String.format(FIELD_TEMPLATE, HexStringUtil.toHexString(ByteBufferUtil.date2bcdbuf(millSec)), field.getName(), millSec);
    } else {
        return String.format(FIELD_TEMPLATE, HexStringUtil.toHexString(ByteBufferUtil.date2buf(millSec)), field.getName(), millSec);
    }
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:11,代码来源:DateTimeCoder.java

示例7: toPrettyHexString

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Override
public String toPrettyHexString(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    bitBuffer.reset();
    encode(bitBuffer, beanMap, field, annotation);
    byte[] array = bitBuffer.toByteArray();
    bitBuffer.reset();
    return String.format(FIELD_TEMPLATE, HexStringUtil.toHexString(array), field.getName(), beanMap.get(field.getName()));
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:9,代码来源:DecimalCoder.java

示例8: decode

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
public void decode(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    AsciiString anno = (AsciiString) annotation;
    int length = CoderHelper.caculateArrayLength(beanMap.getBean(), anno.length());
    if (length > 0) {
        byte[] buf = bitBuffer.readBytes(new byte[length]);
        beanMap.put(field.getName(), new String(buf, anno.charsetName()));
    }
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:9,代码来源:AsciiStringCoder.java

示例9: encode

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
public void encode(BitBuffer bitBuffer, BeanMap beanMap, Field field, Annotation annotation) throws Exception {
    AsciiString arrayAnnocation = (AsciiString) annotation;
    int length = CoderHelper.caculateArrayLength(beanMap.getBean(), arrayAnnocation.length());

    String value = (String) beanMap.get(field.getName());
    byte[] buf = value.getBytes(arrayAnnocation.charsetName());

    if(length != buf.length)
        throw new Exception(field.getName() + " length is not equal to " + length);

    if (buf != null && buf.length > 0) {
        bitBuffer.write(buf);
    }
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:15,代码来源:AsciiStringCoder.java

示例10: doPrettyHexString

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
/**
 * Begin to print pretty string
 *
 * @param obj                 The JavaBean
 * @param prettyStringBuilder The prettystring builder
 * @throws Exception error
 */
private void doPrettyHexString(Object obj, StringBuilder prettyStringBuilder) throws Exception {
    prettyStringBuilder.append(obj.getClass().getSimpleName() + "={");
    Field[] fields = pool.getFields(obj.getClass());

    BeanMap beanMap = BeanMap.create(obj);

    int length = fields.length;
    for (int i = 0; i < length; i++) {
        Field field = fields[i];

        Annotation[] annotations = pool.getAnnotations(field);
        if (annotations != null && annotations.length > 0) {
            if (annotations[0] instanceof Element) {
                Element anno = (Element) annotations[0];
                int arraySize = CoderHelper.caculateArrayLength(obj, anno.length());
                if (arraySize == 1) {
                    prettyStringBuilder.append(field.getName() + "={");
                    doPrettyHexString(beanMap.get(field.getName()), prettyStringBuilder);
                    prettyStringBuilder.append("},");
                } else {
                    Object[] objs = (Object[]) beanMap.get(field.getName());
                    for (Object ob : objs) {
                        prettyStringBuilder.append(field.getName() + "={");
                        doPrettyHexString(ob, prettyStringBuilder);
                        prettyStringBuilder.append("},");
                    }
                }
            } else {
                String line = coderFactory.toPrettyHexString(bitBuffer.get(), beanMap, field, annotations[0]);
                if (i == (length - 1)) {
                    line = line.replace(",", "");
                }
                prettyStringBuilder.append(line);
            }
        }
    }
    prettyStringBuilder.append("}");
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:46,代码来源:ProtocolEngine.java

示例11: test

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Test
public void test() {
    TestDouble testDouble = new TestDouble();
    testDouble.setV1(12.35f);
    testDouble.setV2(12.35f);
    testDouble.setV3(12.35d);
    testDouble.setV4(12.35d);
    BeanMap beanMap = BeanMap.create(testDouble);
    double v = (float)beanMap.get("v1");
    v = (Float)beanMap.get("v2");
    v = (Double)beanMap.get("v3");
    v = (Double)beanMap.get("v4");
}
 
开发者ID:ioprotocol,项目名称:engine,代码行数:14,代码来源:TestDouble.java

示例12: doPrettyHexString

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
/**
 *
 * @param obj
 * @param prettyStringBuilder
 * @throws Exception
 */
private void doPrettyHexString(Object obj, StringBuilder prettyStringBuilder) throws Exception {
    prettyStringBuilder.append(obj.getClass().getSimpleName() + "={");
    Field[] fields = pool.getFields(obj.getClass());

    BeanMap beanMap = BeanMap.create(obj);

    int length = fields.length;
    for (int i = 0; i < length; i++) {
        Field field = fields[i];

        Annotation[] annotations = pool.getAnnotations(field);
        if(annotations != null && annotations.length > 0) {
            if (annotations[0] instanceof Element) {
                Element anno = (Element) annotations[0];
                int arraySize = CoderHelper.caculateArrayLength(obj, anno.length());
                if(arraySize == 1) {
                    prettyStringBuilder.append(field.getName() + "={");
                    doPrettyHexString(beanMap.get(field.getName()), prettyStringBuilder);
                    prettyStringBuilder.append("},");
                } else {
                    Object[] objs = (Object[]) beanMap.get(field.getName());
                    for (Object ob : objs) {
                        prettyStringBuilder.append(field.getName() + "={");
                        doPrettyHexString(ob, prettyStringBuilder);
                        prettyStringBuilder.append("},");
                    }
                }
            } else {
                String line = coderFactory.toPrettyHexString(bitBuffer, beanMap, field, annotations[0]);
                if(i == (length - 1)) {
                    line = line.replace(",", "");
                }
                prettyStringBuilder.append(line);
            }
        }
    }
    prettyStringBuilder.append("}");
}
 
开发者ID:xsyjjh,项目名称:protocol-engine,代码行数:45,代码来源:ProtocolEngine.java

示例13: test

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Test
public void test() {
    TestDouble testDouble = new TestDouble();
    testDouble.setV1(12.35f);
    testDouble.setV2(12.35f);
    testDouble.setV3(12.35d);
    testDouble.setV4(12.35d);
    BeanMap beanMap = BeanMap.create(testDouble);
    double v = (double)beanMap.get("v1");
    v = (double)beanMap.get("v2");
    v = (Double)beanMap.get("v3");
    v = (Double)beanMap.get("v4");
}
 
开发者ID:xsyjjh,项目名称:protocol-engine,代码行数:14,代码来源:TestDouble.java

示例14: copy

import net.sf.cglib.beans.BeanMap; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> copy(F bean) {
    checkNull(bean, "source bean cannot be null!");
    try {
        BeanMap beanMap = BeanMap.create(bean);
        return new HashMap<>(beanMap);
    } catch (Exception e) {
        throw new RuntimeException("create object fail, class: " + bean.getClass().getName(), e);
    }
}
 
开发者ID:drtrang,项目名称:Copiers,代码行数:12,代码来源:BeanToMapCopier.java

示例15: 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);
    }
}
 
开发者ID:drtrang,项目名称:Copiers,代码行数:14,代码来源:MapToBeanCopier.java


注:本文中的net.sf.cglib.beans.BeanMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。