public void testProperties() { // Config.TABLES.add(User.class); float density = Tools.getDensity(getContext()); int width = (int) (220 * density); int height = (int) (120 * density); XLog.e(TAG, "density: " + density); XLog.e(TAG, "width: " + width); XLog.e(TAG, "height: " + height); System.out.println("density: " + density); System.out.println("width: " + width + "," + Tools.dip2px(getContext(), 220)); System.out.println("height: " + height + "," + Tools.dip2px(getContext(), 120)); List<String> list = new ArrayList<String>(); list.add("A"); list.add("B"); list.add("我爱中国"); C c = new C(); c.id = 222; c.name = "zs"; c.list = list; Gson gson = new Gson(); String jsonStr = gson.toJson(c); System.out.println(jsonStr); C cc = gson.fromJson(jsonStr, C.class); System.out.println(cc); try { } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public ChronicleSource(C chronicle, int port, int delayNS) throws IOException { this.chronicle = chronicle; this.delayNS = delayNS; server = ServerSocketChannel.open(); server.socket().bind(new InetSocketAddress(port)); name = chronicle.name() + "@" + port; logger = Logger.getLogger(getClass().getName() + "." + name); service = Executors.newCachedThreadPool(new NamedThreadFactory(name)); service.execute(new Acceptor()); }
public static void main(String[] args) { SuperC sc = new SuperC(); C c = new C(); SubC subc = new SubC(); Tester.checkEqual(sc.name, "SuperC"); Tester.checkEqual(sc.count, 1, "SuperC"); Tester.checkEqual(c.name, "C"); Tester.checkEqual(c.count, 1, "C"); Tester.checkEqual(subc.name, "C"); Tester.checkEqual(subc.count, 1, "SubC"); Tester.checkEqual(((SuperC)c).name, "SuperC"); Tester.checkEqual(c.count, 2, "C as SuperC"); c.name = null; }