一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码的例子 - lizongbo 的编程学习
来源:百度文库 编辑:神马文学网 时间:2024/04/29 03:07:37
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码的例子 一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc
通过xml数据绑定可以省下很多写Javabean代码的时间。
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。 关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc xsd文件:
Comment describing your root element
登陆信息
用户名
密码
邮件地址
Email Address
收件人名字
xml文件:
lizongbo
lizongbopass
lizongbo @ gamil.com
lzb
java文件Userinfo.java:(Loginifo.java略去)/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Comment describing your root element
*
* @version $Revision$ $Date$
*/
public class Userinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 登陆信息
*/
private com.lizongbo..Loginifo _loginifo; /**
* Field _mailinfo
*/
private com.lizongbo..Mailinfo _mailinfo;
//----------------/
//- Constructors -/
//----------------/ public Userinfo() {
super();
} //-- com.lizongbo..Userinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘loginifo‘. The field ‘loginifo‘
* has the following description: 登陆信息
*
* @return the value of field ‘loginifo‘.
*/
public com.lizongbo..Loginifo getLoginifo()
{
return this._loginifo;
} //-- com.lizongbo..Loginifo getLoginifo() /**
* Returns the value of field ‘mailinfo‘.
*
* @return the value of field ‘mailinfo‘.
*/
public com.lizongbo..Mailinfo getMailinfo()
{
return this._mailinfo;
} //-- com.lizongbo..Mailinfo getMailinfo() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘loginifo‘. The field ‘loginifo‘ has
* the following description: 登陆信息
*
* @param loginifo the value of field ‘loginifo‘.
*/
public void setLoginifo(com.lizongbo..Loginifo loginifo)
{
this._loginifo = loginifo;
} //-- void setLoginifo(com.lizongbo..Loginifo) /**
* Sets the value of field ‘mailinfo‘.
*
* @param mailinfo the value of field ‘mailinfo‘.
*/
public void setMailinfo(com.lizongbo..Mailinfo mailinfo)
{
this._mailinfo = mailinfo;
} //-- void setMailinfo(com.lizongbo..Mailinfo) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Userinfo) Unmarshaller.unmarshal(com.lizongbo..Userinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
--------------------------------------------------/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Class Mailinfo.
*
* @version $Revision$ $Date$
*/
public class Mailinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 邮件地址
*/
private java.lang.String _addr = "lizongbo @ gamil.com"; /**
* 收件人名字
*/
private java.lang.String _person = "lzb";
//----------------/
//- Constructors -/
//----------------/ public Mailinfo() {
super();
setAddr("lizongbo @ gamil.com");
setPerson("lzb");
} //-- com.lizongbo..Mailinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @return the value of field ‘addr‘.
*/
public java.lang.String getAddr()
{
return this._addr;
} //-- java.lang.String getAddr() /**
* Returns the value of field ‘person‘. The field ‘person‘ has
* the following description: 收件人名字
*
* @return the value of field ‘person‘.
*/
public java.lang.String getPerson()
{
return this._person;
} //-- java.lang.String getPerson() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @param addr the value of field ‘addr‘.
*/
public void setAddr(java.lang.String addr)
{
this._addr = addr;
} //-- void setAddr(java.lang.String) /**
* Sets the value of field ‘person‘. The field ‘person‘ has the
* following description: 收件人名字
*
* @param person the value of field ‘person‘.
*/
public void setPerson(java.lang.String person)
{
this._person = person;
} //-- void setPerson(java.lang.String) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Mailinfo) Unmarshaller.unmarshal(com.lizongbo..Mailinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
通过xml数据绑定可以省下很多写Javabean代码的时间。
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码例子。平时只使用到了最简单的xml数据绑定,现在测试一个稍微复杂点的例子。 关于xml Schema,有篇好文章:http://gis.pku.edu.cn/Resources/TR/XML_Schema.doc xsd文件:
xml文件:
java文件Userinfo.java:(Loginifo.java略去)/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Comment describing your root element
*
* @version $Revision$ $Date$
*/
public class Userinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 登陆信息
*/
private com.lizongbo..Loginifo _loginifo; /**
* Field _mailinfo
*/
private com.lizongbo..Mailinfo _mailinfo;
//----------------/
//- Constructors -/
//----------------/ public Userinfo() {
super();
} //-- com.lizongbo..Userinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘loginifo‘. The field ‘loginifo‘
* has the following description: 登陆信息
*
* @return the value of field ‘loginifo‘.
*/
public com.lizongbo..Loginifo getLoginifo()
{
return this._loginifo;
} //-- com.lizongbo..Loginifo getLoginifo() /**
* Returns the value of field ‘mailinfo‘.
*
* @return the value of field ‘mailinfo‘.
*/
public com.lizongbo..Mailinfo getMailinfo()
{
return this._mailinfo;
} //-- com.lizongbo..Mailinfo getMailinfo() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘loginifo‘. The field ‘loginifo‘ has
* the following description: 登陆信息
*
* @param loginifo the value of field ‘loginifo‘.
*/
public void setLoginifo(com.lizongbo..Loginifo loginifo)
{
this._loginifo = loginifo;
} //-- void setLoginifo(com.lizongbo..Loginifo) /**
* Sets the value of field ‘mailinfo‘.
*
* @param mailinfo the value of field ‘mailinfo‘.
*/
public void setMailinfo(com.lizongbo..Mailinfo mailinfo)
{
this._mailinfo = mailinfo;
} //-- void setMailinfo(com.lizongbo..Mailinfo) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Userinfo) Unmarshaller.unmarshal(com.lizongbo..Userinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
--------------------------------------------------/*
* This class was automatically generated with
* Castor 0.9.5.3, using an XML
* Schema.
* $Id$
*/ package com.lizongbo.; //---------------------------------/
//- Imported classes and packages -/
//---------------------------------/ import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler; /**
* Class Mailinfo.
*
* @version $Revision$ $Date$
*/
public class Mailinfo implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/ /**
* 邮件地址
*/
private java.lang.String _addr = "lizongbo @ gamil.com"; /**
* 收件人名字
*/
private java.lang.String _person = "lzb";
//----------------/
//- Constructors -/
//----------------/ public Mailinfo() {
super();
setAddr("lizongbo @ gamil.com");
setPerson("lzb");
} //-- com.lizongbo..Mailinfo()
//-----------/
//- Methods -/
//-----------/ /**
* Returns the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @return the value of field ‘addr‘.
*/
public java.lang.String getAddr()
{
return this._addr;
} //-- java.lang.String getAddr() /**
* Returns the value of field ‘person‘. The field ‘person‘ has
* the following description: 收件人名字
*
* @return the value of field ‘person‘.
*/
public java.lang.String getPerson()
{
return this._person;
} //-- java.lang.String getPerson() /**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid() /**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer) /**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler) /**
* Sets the value of field ‘addr‘. The field ‘addr‘ has the
* following description: 邮件地址
*
* @param addr the value of field ‘addr‘.
*/
public void setAddr(java.lang.String addr)
{
this._addr = addr;
} //-- void setAddr(java.lang.String) /**
* Sets the value of field ‘person‘. The field ‘person‘ has the
* following description: 收件人名字
*
* @param person the value of field ‘person‘.
*/
public void setPerson(java.lang.String person)
{
this._person = person;
} //-- void setPerson(java.lang.String) /**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (com.lizongbo..Mailinfo) Unmarshaller.unmarshal(com.lizongbo..Mailinfo.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader) /**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate() }
一个使用自定义命名空间的Schema文件,xml文件和castor生成的java代码的例子 - lizongbo 的编程学习
一个简单的XML Schema的例子
hibernate 映射文件 schema catalog 参数 导致的问题 - Java...
C#的Windows编程中多语言的实现(使用XML文件)
C#的Windows编程中多语言的实现(使用XML文件)
Tomcat 5.5.x 配置集锦 (续) - lizongbo 的编程学习
使用JSP + JAVABEAN + XML 开发的一个例子
Java的XML文件操作之DOM入门篇
Java的XML文件操作之DOM入门篇
M文件的命名规则
Java log4j配置每天生成一个日志文件 - 永恒ぃ☆心 的日志 - 网易博客
为Tomcat写了一个增强的可以限制浏览器和防盗链过滤器提交到Tomcat的bug里被拒了:( - lizongbo 的编程学习
XML安全:使用SAML确保可移植的信任 - XML与XML Schema - TT SO...
使用XML文件来实现对Servlet的配置
ps生成文件的保存
QQ空间代码-几个不错的代码(JS文件)
awk数组处理两个文件的例子
XML Schema的基本语法(转)
使用JSmooth软件制作java的exe文件
使用JSP JAVABEAN XML 开发的一个例子 统一教学网
Spring的applicationContext.xml文件1
澄清SAML的不实说法和误解 - XML与XML Schema - TT SOA - Te...
几个解析XML的例子
Java入门--生成可执行jar文件的教程 — IT技术