Skip to content

Commit 5e38103

Browse files
committed
JAXB tests
1 parent c8da1c0 commit 5e38103

File tree

7 files changed

+118
-3
lines changed

7 files changed

+118
-3
lines changed

sources/net.sf.j2s.java.core/src/test/jaxb/PhoneNumber.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package test.jaxb;
22

3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
35
import javax.xml.bind.annotation.XmlAttribute;
46
import javax.xml.bind.annotation.XmlRootElement;
57

68
// source: http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
9+
// note that we are not honoring package-info here. Why not?
710
@XmlRootElement(name="phone-number")
811
public class PhoneNumber {
912

1013
private String type;
1114
private String number;
1215

13-
@XmlAttribute
14-
public String getType() {
15-
return type;
16+
public String getType() {
17+
return type+"????";
1618
}
1719

1820
public void setType(String type) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package test.jaxb.field;
2+
3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
5+
import javax.xml.bind.annotation.XmlAttribute;
6+
import javax.xml.bind.annotation.XmlRootElement;
7+
8+
// source: http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
9+
// note that we are not honoring package-info here. Why not?
10+
@XmlRootElement(name="phone-number")
11+
public class PhoneNumber {
12+
13+
private String type;
14+
private String number;
15+
16+
public String getType() {
17+
return type+"(property)";
18+
}
19+
20+
public void setType(String type) {
21+
this.type = type;
22+
}
23+
24+
public String getNumber() {
25+
return number+"(property)";
26+
}
27+
28+
public void setNumber(String number) {
29+
this.number = number;
30+
}
31+
32+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@javax.xml.bind.annotation.XmlSchema(namespace = "package-namespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
2+
@XmlAccessorType(XmlAccessType.FIELD)
3+
package test.jaxb.field;
4+
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package test.jaxb.property;
2+
3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
5+
import javax.xml.bind.annotation.XmlAttribute;
6+
import javax.xml.bind.annotation.XmlRootElement;
7+
8+
// source: http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
9+
// note that we are not honoring package-info here. Why not?
10+
@XmlRootElement(name="phone-number")
11+
public class PhoneNumber {
12+
13+
private String type;
14+
public String number;
15+
16+
public String getType() {
17+
return type+"(property)";
18+
}
19+
20+
public void setType(String type) {
21+
this.type = type;
22+
}
23+
24+
private String getNumber() {
25+
return number+"(property)";
26+
}
27+
28+
private void setNumber(String number) {
29+
this.number = number;
30+
}
31+
32+
33+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@javax.xml.bind.annotation.XmlSchema(namespace = "package-namespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
2+
@XmlAccessorType(XmlAccessType.PROPERTY)
3+
package test.jaxb.property;
4+
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package test.jaxb.publicmember;
2+
3+
import javax.xml.bind.annotation.XmlRootElement;
4+
5+
// source: http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html
6+
// note that we are not honoring package-info here. Why not?
7+
@XmlRootElement(name="phone-number")
8+
public class PhoneNumber {
9+
10+
private String type;
11+
public String number;
12+
13+
public String getType() {
14+
return type+"(property)";
15+
}
16+
17+
public void setType(String type) {
18+
this.type = type;
19+
}
20+
21+
String getNumber() {
22+
return number+"(property)";
23+
}
24+
25+
void setNumber(String number) {
26+
this.number = number;
27+
}
28+
29+
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@javax.xml.bind.annotation.XmlSchema(namespace = "package-namespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
2+
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
3+
package test.jaxb.publicmember;
4+
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;

0 commit comments

Comments
 (0)