Skip to content

Commit 7b030af

Browse files
hansonrhansonr
authored andcommitted
JAXB fixes; adds @XmlElements
1 parent e517bce commit 7b030af

21 files changed

Lines changed: 611 additions & 257 deletions
3.4 KB
Binary file not shown.
86 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181108204741
1+
20181110183333
3.4 KB
Binary file not shown.
86 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181108204741
1+
20181110183333

sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class CorePlugin extends Plugin {
1919
* register the bundle version properly. So we use VERSION here instead.
2020
*
2121
*/
22-
public static String VERSION = "3.2.4.02";
22+
public static String VERSION = "3.2.4.04";
23+
// BH 11/10/2018 -- 3.2.4.04 additional support for JAXB
2324
// BH 11/04/2018 -- 3.2.4.02 support for JAXB - all accessor types, ObjectFactory, package-level namespace, but not yet accessor type
2425
// BH 10/27/2018 -- 3.2.4.01 support for JAXB FIELD+propOrder and NONE types
2526
// BH 9/28/2018 -- 3.2.4.00 adds minimal support for JAXB

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5419,29 +5419,36 @@ private boolean addAnnotation(Annotation annotation, ASTNode node, int mode) {
54195419
if (annName.startsWith("J2SIgnore")) {
54205420
return false;
54215421
}
5422-
} else if (qName.equals("Override")
5423-
|| qName.equals("Deprecated")
5424-
|| qName.startsWith("Suppress")
5422+
} else if (qName.equals("Override") || qName.equals("Deprecated") || qName.startsWith("Suppress")
54255423
|| qName.startsWith("ConstructorProperties")) {
5426-
// see java\awt\ScrollPane.js @ConstructorProperties({"scrollbarDisplayPolicy"})
5424+
// see java\awt\ScrollPane.js @ConstructorProperties({"scrollbarDisplayPolicy"})
54275425
// ignore
54285426
} else {
54295427
if (class_annotations == null)
54305428
class_annotations = new ArrayList<ClassAnnotation>();
5431-
ClassAnnotation ann = new ClassAnnotation(qName, annotation, node);
5432-
class_annotations.add(ann);
5429+
class_annotations.add(new ClassAnnotation(qName, annotation, node));
54335430
if ("XmlAccessorType".equals(qName)) {
5434-
String s= annotation.toString();
5435-
class_jaxbAccessorType = (
5436-
s.contains("FIELD") ? JAXB_TYPE_FIELD
5431+
String s = annotation.toString();
5432+
class_jaxbAccessorType = (s.contains("FIELD") ? JAXB_TYPE_FIELD
54375433
: s.contains("PUBLIC") ? JAXB_TYPE_PUBLIC_MEMBER
5438-
: s.contains("PROPERTY") ? JAXB_TYPE_PROPERTY
5439-
: JAXB_TYPE_NONE);
5434+
: s.contains("PROPERTY") ? JAXB_TYPE_PROPERTY : JAXB_TYPE_NONE);
54405435
} else if (qName.startsWith("XmlEnum")) {
54415436
class_jaxbAccessorType = JAXB_TYPE_ENUM;
54425437
} else if (class_jaxbAccessorType == JAXB_TYPE_UNKNOWN && qName.startsWith("Xml")) {
54435438
System.out.println(">>>unspecified!");
54445439
class_jaxbAccessorType = JAXB_TYPE_UNSPECIFIED;
5440+
} else if ("XmlElements".equals(qName) && annotation.isSingleMemberAnnotation()) {
5441+
Expression e = ((SingleMemberAnnotation) annotation).getValue();
5442+
if (e instanceof ArrayInitializer) {
5443+
List<Expression> expressions = ((ArrayInitializer) e).expressions();
5444+
for (int i = expressions.size(); --i >= 0;) {
5445+
Expression exp = expressions.get(i);
5446+
if (exp instanceof Annotation) {
5447+
class_annotations.add(new ClassAnnotation(qName, (Annotation) exp, node));
5448+
}
5449+
}
5450+
}
5451+
54455452
}
54465453
}
54475454
return true;
3.4 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/swingjs/xml/JSJAXBClass.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717

1818
class JSJAXBClass implements Cloneable {
1919

20-
// C$.__ANN__ = [[[null,'test.jaxb.Root_ORDERED.SomewhatComplex'],['@XmlAccessorType(XmlAccessType.FIELD)','@XmlType(name="MoreComplex",namespace="st.Olaf")']],
21-
// [['id','String'],['@XmlID','@XmlElement']],
22-
// [['ca','String'],['@XmlElement']],
23-
// [['cb','String'],['@XmlAttribute(namespace="www.jalview.org2")']],
24-
// [['bytes','byte[]'],['@XmlAttribute']]];
25-
// })()
26-
2720
final static int TYPE_NONE = 0;
2821
final static int TYPE_FIELD = 1;
2922
final static int TYPE_PUBLIC_MEMBER = 2;
@@ -206,6 +199,10 @@ public void addSeeAlso(String... javaClassName) {
206199
}
207200

208201
private void addField(JSJAXBField field) {
202+
if (field.listFields != null) {
203+
for (int i = field.listFields.size(); --i >= 0;)
204+
addField(field.listFields.get(i));
205+
}
209206
fields.add(field);
210207
if (isMarshaller && field.javaName != null)
211208
marshallerFieldMap.put(field.javaName, field);

0 commit comments

Comments
 (0)