|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
C#跟java类似,但是在跨平台方面理论上可以跨平台,实际上应用不大,执行性能优于java,跟C++基本一致,但是启动速度还是慢.代码安全,但容易性能陷阱.
getset参考BeanUtil包和Xpath
http://commons.apache.org/ 的jxpathUsersGuide
类的加载
JXPathContextcontext=JXPathContext.newContext(obj);
//和xpath的局限断定
一样平常取值存值
StringfName=(String)context.getValue("firstName");//setValue
//参考http://www.blogjava.net/Good-Game/archive/2007/08/10/135739.html
一样平常的统计和利用 c 为list[id,name,.....]- JXPathContextcontext=JXPathContext.newContext(c);System.out.println(context.getValue("count(.[name=ooandid=1])"));//对象name=oo和id=1的有几个System.out.println(context.getValue("sum(.[name=ooandid=1]/id)"));//对象name=oo和id=1的一切id相加
复制代码 失掉汇合
IteratorthreeBooks=context.iterate("books[position()<4]");
//xpath的地位函数position其他函数参考http://www.w3.org/TR/xpath
//4CoreFunctionLibrary
xpath利用- publicclassEmployee{privateMapaddressMap=newHashMap();{addressMap.put("home",newAddress(...));addressMap.put("office",newAddress(...));}publicMapgetAddresses(){returnaddressMap;}...}StringhomeZipCode=(String)context.getValue("addresses[@name=home]/zipCode");//利用的是addressMapmap的key=home的Address类属性的zipCode
复制代码 xml在程序与xpath的切进点- <?xmlversion="1.0"?><vendor><locationid="store101"><address><street>OrchardRoad</street></address>
- </location>
- <locationid="store102">
- <address>
- <street>TangerineDrive</street>
- </address>
- </location>
- </vendor>classCompany{
- privateContainerlocations=null;
- publicContainergetLocations(){
- if(locations==null){
- URLurl=getClass().getResource("Vendor.xml");
- locations=newXMLDocumentContainer(url);
- }
- returnlocations;
- }}
- ...
- context=JXPathContext.newContext(newCompany());...
- Stringstreet=(String)context.getValue(
- "locations/vendor/location[@id=store102]//street");//类Container的属性locations头vendor(xml内).....
复制代码 <p>
恰恰证明了java的简单,要不怎么没有通过c/c++来搞个这种框架? |
|