Package org.nutz.lang

Examples of org.nutz.lang.Mirror$DefaultTypeExtractor


      // 循环监听的主程序
      final SocketLock lock = new SocketLock();
      ExecutorService execs = Executors.newCachedThreadPool();
      SocketMain main = null;
      Mirror mirror = Mirror.me(klass);
      Borning<SocketMain> borning = null;
      List<SocketAtom> atoms = new LinkedList<SocketAtom>();
      while (!lock.isStop()) {
        if (log.isDebugEnabled())
          log.debug("create new main thread to wait...");
        if(borning == null)
          borning = mirror.getBorning(atoms, lock, server, service, saTable);
        main = borning.born(new Object[]{atoms, lock, server, service, saTable});

        if (log.isDebugEnabled())
          log.debug("Ready for listen");
View Full Code Here


    } else if (obj instanceof Class) {
      string2Json(((Class<?>) obj).getName());
    } else if (obj instanceof Mirror) {
      string2Json(((Mirror<?>) obj).getType().getName());
    } else {
      Mirror mr = Mirror.me(obj.getClass());
      if (mr.isEnum()) {
        string2Json(((Enum) obj).name());
      } else if (mr.isNumber() || mr.isBoolean()) {
        writer.append(obj.toString());
      } else if (mr.isStringLike() || mr.isChar()) {
        string2Json(obj.toString());
      } else if (mr.isDateTimeLike()) {
        string2Json(format.getCastors().castToString(obj));
      } else if (memo.containsKey(obj)) {
        writer.append("null");
      } else {
        memo.put(obj, null);
View Full Code Here

      return ary;
    }
    if (List.class.isAssignableFrom(clazz)) {
      if (tt == null) // 没有泛型信息? 那只好直接返回了
        return list;
      Mirror me = Mirror.me(clazz);
      List re = null;
      if (clazz.isInterface())
        re = new LinkedList();
      else
        re = (List) me.born();
      for (Object object : list) {
        re.add(convert(tt, object));
      }
      return re;
    }
View Full Code Here

        } else if (obj instanceof Class) {
            string2Json(((Class<?>) obj).getName());
        } else if (obj instanceof Mirror) {
            string2Json(((Mirror<?>) obj).getType().getName());
        } else {
            Mirror mr = Mirror.me(obj.getClass());
            // 枚举
            if (mr.isEnum()) {
                string2Json(((Enum) obj).name());
            }
            // 数字,布尔等
            else if (mr.isNumber() || mr.isBoolean()) {
                writer.append(obj.toString());
            }
            // 字符串
            else if (mr.isStringLike() || mr.isChar()) {
                string2Json(obj.toString());
            }
            // 日期时间
            else if (mr.isDateTimeLike()) {
                string2Json(format.getCastors().castToString(obj));
            }
            // 其他
            else {
                // Map
View Full Code Here

                // 判断是否应该被忽略
                if (!this.isIgnore(name, value)) {
                    // 以前曾经输出过 ...
                    if (null != value) {
                        // zozoh: 循环引用的默认行为,应该为 null,以便和其他语言交换数据
                        Mirror mirror = Mirror.me(value);
                        if (mirror.isPojo()) {
                            if (memo.contains(value))
                                value = null;
                        }
                    }
                    // 加入输出列表 ...
View Full Code Here

      throw new DaoException("Blank table Name!");
    }
    NutEntity en = new NutEntity(Class.forName(className));
    en.setTableName(tableName);
    en.setViewName(tableName);
    Mirror mirror = Mirror.me(en.getType());
   
    Element pkElement = Xmls.firstChild(klassElement, "^id$");
    if (pkElement != null) {
      NutMappingField pk = ele2FieldMapping(en, pkElement);
      if (Mirror.me(mirror.getField(pk.getName()).getType()).isNumber()) {
        pk.setAsId();
      } else {
        pk.setAsName();
      }
      en.addMappingField(pk);
View Full Code Here

        T info = Mirror.me(classOfT).born();
        info.name = field.getName();
        // XXX 兼容性改变 从1.b.51开始, 优先走getter/setter
        // 老版本是只从属性取值/设置值,不走getter/setter
        info.fieldType = field.getGenericType();
        Mirror me = Mirror.me(field.getDeclaringClass());
        info.injecting = me.getInjecting(field.getName());
        info.ejecting = me.getEjecting(field.getName());
        return info;
    }
View Full Code Here

        } else if (obj instanceof Class) {
            return obj;
        } else if (obj instanceof Mirror) {
            return ((Mirror<?>) obj).getType().getName();
        } else {
            Mirror mr = Mirror.me(obj.getClass());
            // 枚举
            if (mr.isEnum()) {
                return obj;
            }
            // 数字,布尔等
            else if (mr.isNumber() || mr.isBoolean()) {
                return obj;
            }
            // 字符串
            else if (mr.isStringLike() || mr.isChar()) {
                return obj;
            }
            // 日期时间
            else if (mr.isDateTimeLike()) {
                return obj;
            }
            // 其他
            else {
                // 既然到了这里, 那么断定它只有List, Array, Map, Object这4种类型
View Full Code Here

        } else if (obj instanceof Class) {
            string2Json(((Class<?>) obj).getName());
        } else if (obj instanceof Mirror) {
            string2Json(((Mirror<?>) obj).getType().getName());
        } else {
            Mirror mr = Mirror.me(obj.getClass());
            // 枚举
            if (mr.isEnum()) {
                string2Json(((Enum) obj).name());
            }
            // 数字,布尔等
            else if (mr.isNumber() || mr.isBoolean()) {
                writer.append(obj.toString());
            }
            // 字符串
            else if (mr.isStringLike() || mr.isChar()) {
                string2Json(obj.toString());
            }
            // 日期时间
            else if (mr.isDateTimeLike()) {
                string2Json(format.getCastors().castToString(obj));
            }
            // 其他
            else {
                // Map
View Full Code Here

                // 判断是否应该被忽略
                if (!this.isIgnore(name, value)) {
                    // 以前曾经输出过 ...
                    if (null != value) {
                        // zozoh: 循环引用的默认行为,应该为 null,以便和其他语言交换数据
                        Mirror mirror = Mirror.me(value);
                        if (mirror.isPojo()) {
                            if (memo.contains(value))
                                value = null;
                        }
                    }
                    // 如果是强制输出为字符串的
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.