[JAVA-9021] Clean up uncommitted artifacts (#11754)
This commit is contained in:
parent
19d7034d42
commit
a7980094d1
|
@ -1,3 +1,5 @@
|
||||||
*.docx
|
*.docx
|
||||||
temp.xls
|
temp.xls
|
||||||
temp.xlsx
|
temp.xlsx
|
||||||
|
|
||||||
|
CellStyleTest_output.xlsx
|
|
@ -1,4 +1,6 @@
|
||||||
/target/
|
/target/
|
||||||
.settings/
|
.settings/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
|
||||||
|
*.log
|
||||||
|
|
|
@ -1,14 +1,29 @@
|
||||||
package com.baeldung.externalizable;
|
package com.baeldung.externalizable;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ExternalizableUnitTest {
|
public class ExternalizableUnitTest {
|
||||||
|
|
||||||
private final static String OUTPUT_FILE = "externalizable.txt";
|
private final static String OUTPUT_FILE_NAME = "externalizable.txt";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||||
|
|
||||||
|
private File outputFile;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException {
|
public void whenSerializing_thenUseExternalizable() throws IOException, ClassNotFoundException {
|
||||||
|
@ -18,7 +33,7 @@ public class ExternalizableUnitTest {
|
||||||
c.setCode(374);
|
c.setCode(374);
|
||||||
c.setName("Armenia");
|
c.setName("Armenia");
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||||
c.writeExternal(objectOutputStream);
|
c.writeExternal(objectOutputStream);
|
||||||
|
|
||||||
|
@ -26,7 +41,7 @@ public class ExternalizableUnitTest {
|
||||||
objectOutputStream.close();
|
objectOutputStream.close();
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
|
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||||
|
|
||||||
Country c2 = new Country();
|
Country c2 = new Country();
|
||||||
|
@ -35,8 +50,8 @@ public class ExternalizableUnitTest {
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
|
|
||||||
assertTrue(c2.getCode() == c.getCode());
|
assertEquals(c2.getCode(), c.getCode());
|
||||||
assertTrue(c2.getName().equals(c.getName()));
|
assertEquals(c2.getName(), c.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,7 +64,7 @@ public class ExternalizableUnitTest {
|
||||||
r.setClimate("Mediterranean");
|
r.setClimate("Mediterranean");
|
||||||
r.setPopulation(120.000);
|
r.setPopulation(120.000);
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(OUTPUT_FILE);
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||||
r.writeExternal(objectOutputStream);
|
r.writeExternal(objectOutputStream);
|
||||||
|
|
||||||
|
@ -57,7 +72,7 @@ public class ExternalizableUnitTest {
|
||||||
objectOutputStream.close();
|
objectOutputStream.close();
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream(OUTPUT_FILE);
|
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||||
|
|
||||||
Region r2 = new Region();
|
Region r2 = new Region();
|
||||||
|
@ -66,6 +81,6 @@ public class ExternalizableUnitTest {
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
|
|
||||||
assertTrue(r2.getPopulation() == null);
|
assertNull(r2.getPopulation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,54 @@
|
||||||
package com.baeldung.serialization;
|
package com.baeldung.serialization;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PersonUnitTest {
|
public class PersonUnitTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||||
|
|
||||||
|
private File outputFile;
|
||||||
|
|
||||||
|
private File outputFile2;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
outputFile = tempFolder.newFile("yourfile.txt");
|
||||||
|
outputFile2 = tempFolder.newFile("yourfile2.txt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException {
|
public void whenSerializingAndDeserializing_ThenObjectIsTheSame() throws IOException, ClassNotFoundException {
|
||||||
Person p = new Person();
|
Person p = new Person();
|
||||||
p.setAge(20);
|
p.setAge(20);
|
||||||
p.setName("Joe");
|
p.setName("Joe");
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||||
objectOutputStream.writeObject(p);
|
objectOutputStream.writeObject(p);
|
||||||
objectOutputStream.flush();
|
objectOutputStream.flush();
|
||||||
objectOutputStream.close();
|
objectOutputStream.close();
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
|
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||||
Person p2 = (Person) objectInputStream.readObject();
|
Person p2 = (Person) objectInputStream.readObject();
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
|
|
||||||
assertTrue(p2.getAge() == p.getAge());
|
assertEquals(p2.getAge(), p.getAge());
|
||||||
assertTrue(p2.getName().equals(p.getName()));
|
assertEquals(p2.getName(), p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -46,19 +64,19 @@ public class PersonUnitTest {
|
||||||
e.setPerson(p);
|
e.setPerson(p);
|
||||||
e.setAddress(a);
|
e.setAddress(a);
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile2.txt");
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile2);
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
|
||||||
objectOutputStream.writeObject(e);
|
objectOutputStream.writeObject(e);
|
||||||
objectOutputStream.flush();
|
objectOutputStream.flush();
|
||||||
objectOutputStream.close();
|
objectOutputStream.close();
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream("yofile2.txt");
|
FileInputStream fileInputStream = new FileInputStream(outputFile2);
|
||||||
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
|
||||||
Employee e2 = (Employee) objectInputStream.readObject();
|
Employee e2 = (Employee) objectInputStream.readObject();
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
|
|
||||||
assertTrue(e2.getPerson().getAge() == e.getPerson().getAge());
|
assertEquals(e2.getPerson().getAge(), e.getPerson().getAge());
|
||||||
assertTrue(e2.getAddress().getHouseNumber() == (e.getAddress().getHouseNumber()));
|
assertEquals(e2.getAddress().getHouseNumber(), (e.getAddress().getHouseNumber()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -13,17 +14,32 @@ import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.baeldung.util.MySerializationUtils;
|
import com.baeldung.util.MySerializationUtils;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
public class SerializationUnitTest {
|
public class SerializationUnitTest {
|
||||||
|
|
||||||
|
private final static String OUTPUT_FILE_NAME = "yourfile.txt";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||||
|
|
||||||
|
private File outputFile;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
outputFile = tempFolder.newFile(OUTPUT_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = NotSerializableException.class)
|
@Test(expected = NotSerializableException.class)
|
||||||
public void whenSerializing_ThenThrowsError() throws IOException {
|
public void whenSerializing_ThenThrowsError() throws IOException {
|
||||||
Address address = new Address();
|
Address address = new Address();
|
||||||
address.setHouseNumber(10);
|
address.setHouseNumber(10);
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||||
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
||||||
objectOutputStream.writeObject(address);
|
objectOutputStream.writeObject(address);
|
||||||
}
|
}
|
||||||
|
@ -35,12 +51,12 @@ public class SerializationUnitTest {
|
||||||
p.setAge(20);
|
p.setAge(20);
|
||||||
p.setName("Joe");
|
p.setName("Joe");
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream("yofile.txt");
|
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
|
||||||
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
|
||||||
objectOutputStream.writeObject(p);
|
objectOutputStream.writeObject(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream("yofile.txt");
|
FileInputStream fileInputStream = new FileInputStream(outputFile);
|
||||||
try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
try (ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream)) {
|
||||||
Person p2 = (Person) objectInputStream.readObject();
|
Person p2 = (Person) objectInputStream.readObject();
|
||||||
assertEquals(p2.getAge(), p.getAge());
|
assertEquals(p2.getAge(), p.getAge());
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
|
|
||||||
package com.baeldung.jaxb.gen;
|
package com.baeldung.jaxb.gen;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRegistry;
|
import javax.xml.bind.annotation.XmlRegistry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object contains factory methods for each
|
* This object contains factory methods for each
|
||||||
* Java content interface and Java element interface
|
* Java content interface and Java element interface
|
||||||
* generated in the com.baeldung.jaxb.gen package.
|
* generated in the com.baeldung.jaxb.gen package.
|
||||||
* <p>An ObjectFactory allows you to programatically
|
* <p>An ObjectFactory allows you to programatically
|
||||||
* construct new instances of the Java representation
|
* construct new instances of the Java representation
|
||||||
* for XML content. The Java representation of XML
|
* for XML content. The Java representation of XML
|
||||||
* content can consist of schema derived interfaces
|
* content can consist of schema derived interfaces
|
||||||
* and classes representing the binding of schema
|
* and classes representing the binding of schema
|
||||||
* type definitions, element declarations and model
|
* type definitions, element declarations and model
|
||||||
* groups. Factory methods for each of these are
|
* groups. Factory methods for each of these are
|
||||||
* provided in this class.
|
* provided in this class.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@XmlRegistry
|
@XmlRegistry
|
||||||
public class ObjectFactory {
|
public class ObjectFactory {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
|
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxb.gen
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ObjectFactory() {
|
public ObjectFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of {@link UserRequest }
|
* Create an instance of {@link UserRequest }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public UserRequest createUserRequest() {
|
public UserRequest createUserRequest() {
|
||||||
return new UserRequest();
|
return new UserRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of {@link UserResponse }
|
* Create an instance of {@link UserResponse }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public UserResponse createUserResponse() {
|
public UserResponse createUserResponse() {
|
||||||
return new UserResponse();
|
return new UserResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
|
|
||||||
package com.baeldung.jaxb.gen;
|
package com.baeldung.jaxb.gen;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Java class for UserRequest complex type.
|
* <p>Java class for UserRequest complex type.
|
||||||
*
|
*
|
||||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* <complexType name="UserRequest">
|
* <complexType name="UserRequest">
|
||||||
* <complexContent>
|
* <complexContent>
|
||||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||||
* <sequence>
|
* <sequence>
|
||||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
* </sequence>
|
* </sequence>
|
||||||
* </restriction>
|
* </restriction>
|
||||||
* </complexContent>
|
* </complexContent>
|
||||||
* </complexType>
|
* </complexType>
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "UserRequest", propOrder = {
|
@XmlType(name = "UserRequest", propOrder = {
|
||||||
"id",
|
"id",
|
||||||
"name"
|
"name"
|
||||||
})
|
})
|
||||||
@XmlRootElement(name = "userRequest")
|
@XmlRootElement(name = "userRequest")
|
||||||
public class UserRequest
|
public class UserRequest
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
private final static long serialVersionUID = -1L;
|
private final static long serialVersionUID = -1L;
|
||||||
protected int id;
|
protected int id;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the id property.
|
* Gets the value of the id property.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the id property.
|
* Sets the value of the id property.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setId(int value) {
|
public void setId(int value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the name property.
|
* Gets the value of the name property.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* possible object is
|
* possible object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the name property.
|
* Sets the value of the name property.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* allowed object is
|
* allowed object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setName(String value) {
|
public void setName(String value) {
|
||||||
this.name = value;
|
this.name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,149 +1,149 @@
|
||||||
|
|
||||||
package com.baeldung.jaxb.gen;
|
package com.baeldung.jaxb.gen;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlSchemaType;
|
import javax.xml.bind.annotation.XmlSchemaType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
import org.w3._2001.xmlschema.Adapter1;
|
import org.w3._2001.xmlschema.Adapter1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Java class for UserResponse complex type.
|
* <p>Java class for UserResponse complex type.
|
||||||
*
|
*
|
||||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* <complexType name="UserResponse">
|
* <complexType name="UserResponse">
|
||||||
* <complexContent>
|
* <complexContent>
|
||||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||||
* <sequence>
|
* <sequence>
|
||||||
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
* <element name="gender" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
* <element name="gender" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
* <element name="created" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
|
* <element name="created" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
|
||||||
* </sequence>
|
* </sequence>
|
||||||
* </restriction>
|
* </restriction>
|
||||||
* </complexContent>
|
* </complexContent>
|
||||||
* </complexType>
|
* </complexType>
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "UserResponse", propOrder = {
|
@XmlType(name = "UserResponse", propOrder = {
|
||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
"gender",
|
"gender",
|
||||||
"created"
|
"created"
|
||||||
})
|
})
|
||||||
@XmlRootElement(name = "userResponse")
|
@XmlRootElement(name = "userResponse")
|
||||||
public class UserResponse
|
public class UserResponse
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
private final static long serialVersionUID = -1L;
|
private final static long serialVersionUID = -1L;
|
||||||
protected int id;
|
protected int id;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
protected String name;
|
protected String name;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
protected String gender;
|
protected String gender;
|
||||||
@XmlElement(required = true, type = String.class)
|
@XmlElement(required = true, type = String.class)
|
||||||
@XmlJavaTypeAdapter(Adapter1 .class)
|
@XmlJavaTypeAdapter(Adapter1 .class)
|
||||||
@XmlSchemaType(name = "dateTime")
|
@XmlSchemaType(name = "dateTime")
|
||||||
protected Calendar created;
|
protected Calendar created;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the id property.
|
* Gets the value of the id property.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the id property.
|
* Sets the value of the id property.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setId(int value) {
|
public void setId(int value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the name property.
|
* Gets the value of the name property.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* possible object is
|
* possible object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the name property.
|
* Sets the value of the name property.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* allowed object is
|
* allowed object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setName(String value) {
|
public void setName(String value) {
|
||||||
this.name = value;
|
this.name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the gender property.
|
* Gets the value of the gender property.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* possible object is
|
* possible object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public String getGender() {
|
public String getGender() {
|
||||||
return gender;
|
return gender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the gender property.
|
* Sets the value of the gender property.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* allowed object is
|
* allowed object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setGender(String value) {
|
public void setGender(String value) {
|
||||||
this.gender = value;
|
this.gender = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the created property.
|
* Gets the value of the created property.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* possible object is
|
* possible object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Calendar getCreated() {
|
public Calendar getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of the created property.
|
* Sets the value of the created property.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* allowed object is
|
* allowed object is
|
||||||
* {@link String }
|
* {@link String }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setCreated(Calendar value) {
|
public void setCreated(Calendar value) {
|
||||||
this.created = value;
|
this.created = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/jaxb/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/jaxb/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||||
package com.baeldung.jaxb.gen;
|
package com.baeldung.jaxb.gen;
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
|
|
||||||
package org.w3._2001.xmlschema;
|
package org.w3._2001.xmlschema;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
|
||||||
public class Adapter1
|
public class Adapter1
|
||||||
extends XmlAdapter<String, Calendar>
|
extends XmlAdapter<String, Calendar>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public Calendar unmarshal(String value) {
|
public Calendar unmarshal(String value) {
|
||||||
return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
|
return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String marshal(Calendar value) {
|
public String marshal(Calendar value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (javax.xml.bind.DatatypeConverter.printDateTime(value));
|
return (javax.xml.bind.DatatypeConverter.printDateTime(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue