Skip to content

Commit 48cd462

Browse files
hansonrhansonr
authored andcommitted
JAXB marshalling.
implemented: @XmlAccessorType @XmlAttribute @xmlelement @XmlJavaTypeAdapter @XmlRootElement @XmlSeeAlso @XmlType @XmlValue not implemented yet: @xmlid @XmlEnum @XmlEnumValue
1 parent 5398514 commit 48cd462

File tree

19 files changed

+942
-583
lines changed

19 files changed

+942
-583
lines changed
17.2 KB
Binary file not shown.
583 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181016154021
1+
20181020060436
17.2 KB
Binary file not shown.
583 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181016154021
1+
20181020060436

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5349,7 +5349,7 @@ private Object checkAnnotations(BodyDeclaration node, String tagName) {
53495349
}
53505350
} else if (!qName.equals("Override")
53515351
&& !qName.equals("Deprecated")
5352-
&& !qName.equals("Suppress")
5352+
&& !qName.startsWith("Suppress")
53535353
&& !qName.equals("XmlTransient")
53545354
) {
53555355
if (class_annotations == null)
@@ -6135,6 +6135,7 @@ protected ClassAnnotation(String qName, Annotation annotation, BodyDeclaration n
61356135
this.node = node;
61366136
}
61376137

6138+
@SuppressWarnings("unchecked")
61386139
public static void addClassAnnotations(List<ClassAnnotation> class_annotations, TrailingBuffer trailingBuffer) {
61396140
if (class_annotations == null)
61406141
return;
@@ -6144,8 +6145,33 @@ public static void addClassAnnotations(List<ClassAnnotation> class_annotations,
61446145
for (int i = 0; i < class_annotations.size(); i++) {
61456146
ClassAnnotation a = class_annotations.get(i);
61466147
String str = a.annotation.toString();
6147-
if (str.startsWith("@SuppressWarnings"))
6148-
continue;
6148+
if (a.annotation instanceof SingleMemberAnnotation) {
6149+
// resolve classes
6150+
List<ASTNode> expressions = null;
6151+
Expression e = ((SingleMemberAnnotation) a.annotation).getValue();
6152+
if (e instanceof TypeLiteral) {
6153+
expressions = new ArrayList<ASTNode>();
6154+
expressions.add(e);
6155+
} else if (e instanceof ArrayInitializer) {
6156+
expressions = ((ArrayInitializer) e).expressions();
6157+
}
6158+
if (expressions != null) {
6159+
str = str.substring(0, str.indexOf("(") + 1);
6160+
int n = expressions.size();
6161+
String sep = (n > 1 ? "{" : "");
6162+
for (int j = 0; j < n; j++) {
6163+
str += sep;
6164+
e = (Expression) expressions.get(j);
6165+
if (e instanceof TypeLiteral) {
6166+
str += ((TypeLiteral) e).getType().resolveBinding().getQualifiedName() + ".class";
6167+
} else {
6168+
str += e.toString();
6169+
}
6170+
sep = ",";
6171+
}
6172+
str += (n > 1 ? "})" : ")");
6173+
}
6174+
}
61496175
if (a.node == lastNode) {
61506176
trailingBuffer.append(",");
61516177
} else {
@@ -6155,7 +6181,9 @@ public static void addClassAnnotations(List<ClassAnnotation> class_annotations,
61556181
// time to pick up the fragments
61566182
addTrailingFragments(fragments, trailingBuffer, ptBuf);
61576183
fragments = null;
6158-
if (a.node instanceof FieldDeclaration) {
6184+
if (a.node instanceof TypeDeclaration) {
6185+
type = ((TypeDeclaration) a.node).resolveBinding();
6186+
} else if (a.node instanceof FieldDeclaration) {
61596187
FieldDeclaration field = (FieldDeclaration) a.node;
61606188
fragments = field.fragments();
61616189
VariableDeclarationFragment identifier = (VariableDeclarationFragment) fragments.get(0);
@@ -6169,8 +6197,14 @@ public static void addClassAnnotations(List<ClassAnnotation> class_annotations,
61696197
type = var.getReturnType();
61706198
}
61716199
String className = (type == null ? null
6172-
: stripJavaLang(NameMapper.checkClassReplacement(
6173-
removeBracketsAndFixNullPackageName(getJavaClassNameQualified(type)))));
6200+
: stripJavaLang(
6201+
//NameMapper.checkClassReplacement(
6202+
//removeBracketsAndFixNullPackageName(
6203+
NameMapper.fixPackageName(
6204+
getJavaClassNameQualified(type)
6205+
)
6206+
//))
6207+
));
61746208
trailingBuffer.append(pt++ == 0 ? "C$.__ANN__ = [[[" : "]],\n [[");
61756209
trailingBuffer.append((varName == null ? null : "'" + varName + "'"));
61766210
ptBuf = trailingBuffer.buf.length();

sources/net.sf.j2s.java.core/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
88
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
99
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
1010
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
11-
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
12-
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
13-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
14-
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
15-
org.eclipse.jdt.core.compiler.compliance=1.8
16-
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
17-
org.eclipse.jdt.core.compiler.debug.localVariable=generate
18-
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
1911
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
20-
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
2112
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
2213
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
2314
org.eclipse.jdt.core.compiler.problem.deadCode=warning
@@ -26,7 +17,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
2617
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
2718
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
2819
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
29-
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
3020
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
3121
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
3222
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
@@ -103,5 +93,3 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
10393
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
10494
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
10595
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
106-
org.eclipse.jdt.core.compiler.release=disabled
107-
org.eclipse.jdt.core.compiler.source=1.8

sources/net.sf.j2s.java.core/src/javax/xml/bind/DatatypeConverterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul>
6767
* @since JAXB 2.1
6868
*/
69-
final class DatatypeConverterImpl implements DatatypeConverterInterface {
69+
final public class DatatypeConverterImpl implements DatatypeConverterInterface {
7070

7171
/**
7272
* To avoid re-creating instances, we cache one instance.

sources/net.sf.j2s.java.core/src/swingjs/api/js/DOMNode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public static Object getAttr(DOMNode node, String attr) {
7979
return (/** @j2sNative node && node[attr] ||*/ null);
8080
}
8181

82+
public static int getAttrInt(DOMNode node, String attr) {
83+
return (/** @j2sNative node && node[attr] ||*/ 0);
84+
}
85+
8286
public static String getStyle(DOMNode node, String style) {
8387
return (/** @j2sNative node && node.style[style] ||*/ null);
8488
}

0 commit comments

Comments
 (0)