Olá Galera,
Eu estou tentando fazer o
Marshal e Unmarshal do Castor XML
na página principal do Castor XML
tem o seguinte exemplo:
import org.exolab.castor.types.Date;
/** An simple person class */
public class Person implements java.io.Serializable {
/** The name of the person */
private String name = null;
/** The Date of birth */
private Date dob = null;
/** Creates a Person with no name */
public Person() {
super();
}
/** Creates a Person with the given name */
public Person(String name) {
this.name = name;
}
/**
* @return date of birth of the person
*/
public Date getDateOfBirth() {
return dob;
}
/**
* @return name of the person
*/
public String getName() {
return name;
}
/**
* Sets the date of birth of the person
* @param name the name of the person
*/
public void setDateOfBirth(Date dob) {
this.dob = dob;
}
/**
* Sets the name of the person
* @param name the name of the person
*/
public void setName(String name) {
this.name = name;
}
}
E a uma classe para teste:
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.exolab.castor.types.Date;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
public class Main {
public static void main(String[] args) throws MarshalException, ValidationException, IOException{
// Create a new Person
Person person = new Person("Ryan 'Mad Dog' Madden");
person.setName(new String("Ricardo"));
--> ERRO AQUI: person.setDateOfBirth(new Date(1955, 8, 15));
// Create a File to marshal to
FileWriter writer = new FileWriter("test.xml");
// Marshal the person object
Marshaller.marshal(person, writer);
// Create a Reader to the file to unmarshal from
FileReader reader = new FileReader("test.xml");
// Marshal the person object
person = (Person) Unmarshaller.unmarshal(Person.class, reader);
}
}
Mas toda hora que eu vou compilar
aparece o seguinte erro:
14/04/2009 11:26:56 org.exolab.castor.xml.Marshaller staticMarshal
INFO: Marshaller called using one of the *static* marshal(Object, *) methods. This will ignore any mapping files as specified. Please consider switching to using Marshaller instances and calling one of the marshal(*) methods.
Será que agluém sabe o que está
acontecendo que poderia me dar
uma ajuda fazendo o favor?
Abraço.