jox-1.17b3.jar

时间:2016-03-26 17:09:47
【文件属性】:

文件名称:jox-1.17b3.jar

文件大小:1.23MB

文件格式:RAR

更新时间:2016-03-26 17:09:47

jox-1.17b3

通过JOX来实现从JavaBeans到XML文件的相互转换。 为了灵活的满足Web应用和Web services需求的变化,Java和XML的轻便性和可扩展性使它们成为解决这一问题的理想选择。SAX (Simple API for XML), DOM (document.nbspObject Model), XSL (Extensible Stylesheet Language), XSLT (XSL Transformations), SOAP (Simple Object Access Protocol), and BML (Bean Markup Language)是XML领域内的相关技术。本文集合了Java和XML轻便和可扩展的优点,但又不需要开发人员了解上述的相关技术。 在Java分布式应用中使用远程方法调用(RMI),而不是直接用底层的socket或其它网络链接代码。EJB技术也使开发人员从transaction,recovery, activation等底层机制中解放出来。同样,使用本文的JavaBean-XML映射组件,开发人员也不用直接处理与XML有关的APIs。 1.先定义javaBean package com.wutka.jox.test; import com.wutka.jox. * ; import java.util. * ; public class TestBean implements java.io.Serializable { protected int foo; protected String bar; protected java.util.Date baz; protected Vector thingies; protected TestSubbean subbean; public TestBean() { bar = "" ; baz = new Date(); thingies = new Vector(); } public int getFoo() { return foo; } public void setFoo( int aFoo) { foo = aFoo; } public String getBar() { return bar; } public void setBar(String aBar) { bar = aBar; } public java.util.Date getBaz() { return baz; } public void setBaz(java.util.Date aBaz) { baz = aBaz; } public TestSubbean getSub() { return subbean; } public void setSub(TestSubbean aSub) { subbean = aSub; } public String[] getThingies() { String[] retThingies = new String[thingies.size()]; if (thingies.size() > 0 ) thingies.copyInto(retThingies); return retThingies; } public void setThingies(String[] newThingies) { thingies = new Vector(newThingies.length); for ( int i = 0 ; i < newThingies.length; i ++ ) { thingies.addElement(newThingies[i]); } } public String getThingies( int i) { return (String) thingies.elementAt(i); } public void setThingies( int i, String thingy) { thingies.setElementAt(thingy, i); } public String toString() { StringBuffer ret = new StringBuffer( " foo= " + foo + " ;bar= " + bar + " ;baz= " + baz.toString() + " ;thingies= " ); for ( int i = 0 ; i < thingies.size(); i ++ ) { if (i > 0 ) ret.append( " , " ); ret.append((String) thingies.elementAt(i)); } ret.append( " ;sub= " ); ret.append(subbean.toString()); return ret.toString(); } } 2.xml文件 <? xml version="1.0" ?> < MarkTest > < thingies >网 < thingies > 载 < thingies > 下 < thingies > 托 < thingies > 灵 < foo > 5 < baz > 6/25/00 12:46 AM < bar > This is the website value < sub > < age > 1 < name > wangdei 下面的程序是把xml转为成javaBean package com.wutka.jox.test; import com.wutka.jox. * ; import java.io. * ; public class TestDeser { public static void main(String[] args) { try { FileInputStream in = new FileInputStream( " bean.xml " ); JOXBeanInputStream joxIn = new JOXBeanInputStream(in); TestBean testBean = (TestBean) joxIn.readObject( TestBean. class ); System.out.println(testBean); } catch (Exception exc) { exc.printStackTrace(); } } } 下面的程序是把javaBean转为成xml package com.wutka.jox.test; import com.wutka.jox. * ; import java.io. * ; public class TestSer { public static void main(String[] args) { try { TestBean b = new TestBean(); b.setFoo( 5 ); b.setBar( " This is the bar value " ); b.setThingies( new String[] { " 网 " , " 载 " , " 下 " , " 托 " , " 灵 " } ); TestSubbean sub = new TestSubbean(); sub.setName( " Mark " ); sub.setAge( 35 ); b.setSub(sub); FileOutputStream fileOut = new FileOutputStream( " bean.xml " ); JOXBeanOutputStream joxOut = new JOXBeanOutputStream(fileOut); joxOut.writeObject( " MarkTest " , b); joxOut.close(); } } }


【文件预览】:
jox-1.17b3
----junit_3.8.2.jar(118KB)
----xml-apis.jar(190KB)
----parser.jar(133KB)
----xercesImpl.jar(875KB)
----jaxp.jar(28KB)
----jox-1.17b3.jar(66KB)
----dtdparser121.jar(44KB)

网友评论

  • 进来学习,增加技能
  • 已正在使用,不错
  • 找了很久才找到,谢谢分享。
  • 多谢分享该jar包~真的好难找的
  • 可以实现转化,还是比较方便的,但当XML中有数组型数据时,JavaBean的写法需要稍作修改,这一点不大方便
  • 貌似不好用
  • 不错 很使用 非常好
  • 确实能转化,但是和我想要的有点区别。总体来说还是不错的!
  • 可对XML与BEAN之间进行转换,不错,谢谢分享~
  • 多谢分享该jar包~真的好难找的