Package org.nutz.lang

Examples of org.nutz.lang.Mirror$DefaultTypeExtractor


    if (obj == null) {
      type = "null";
      return;
    }
    info = obj.getClass().getName();
    Mirror mirror = Mirror.me(obj);
    //判断是否为原生支持类型
    if (mirror.isNumber() || mirror.isBoolean() || mirror.isChar()
        || mirror.isStringLike()
        || obj instanceof Pattern
        || obj instanceof Date
        || obj instanceof byte[]
        || obj instanceof BSONTimestamp
        || obj instanceof Code
        || obj instanceof CodeWScope
        || obj instanceof ObjectId
        || obj instanceof Binary
        || obj instanceof UUID
        || obj instanceof Symbol
        || obj instanceof DBRefBase
        || obj instanceof MinKey
        || obj instanceof MaxKey) {
      type = "simple";
      data = obj;
      return;
    }
    if (obj instanceof DBObject ) {
      type = "dbo";
      data = obj;
      return;
    }
    if (obj.getClass().getAnnotation(Co.class) != null) {
      type = "nutz_mongo";
      data = Mongos.entity(obj).toDBObject(obj).get("_id").toString();
      return;
    }
    if (mirror.isContainer()) {
      if (mirror.isMap()) {
        type = "map";
        Map<String, Object> map = new HashMap<String, Object>();
        for (Entry<String, Object> entry : ((Map<String, Object>) obj)
            .entrySet()) {
          SessionValue attr = new SessionValue(
              entry.getValue());
          map.put(entry.getKey(), attr.dbo());
        }
        data = map;
        return;
      } else if (mirror.isArray() || obj instanceof List
          || obj instanceof Set) {
        if (mirror.isArray())
          type = "array";
        else if (obj instanceof List)
          type = "list";
        else
          type = "set";
View Full Code Here

TOP

Related Classes of org.nutz.lang.Mirror$DefaultTypeExtractor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.