Skip to content

Commit 0c0cc23

Browse files
committed
Issue #70.
1 parent c92bfab commit 0c0cc23

File tree

5 files changed

+24
-51
lines changed

5 files changed

+24
-51
lines changed

nodejs/scripts/jsonix.js

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ Jsonix.Request = Jsonix
297297
transport.onreadystatechange = function() {
298298
that.handleTransport(transport, onSuccess, onFailure);
299299
};
300-
console.log('Sending.');
301300
transport.send(data);
302301
}
303302
}
@@ -1872,7 +1871,7 @@ Jsonix.Binding.ElementUnmarshaller = Jsonix.Class({
18721871
if (input.eventType != 1) {
18731872
throw new Error("Parser must be on START_ELEMENT to read next element.");
18741873
}
1875-
var typeInfo = this.getInputTypeInfo(context, input, scope);
1874+
var typeInfo = this.getTypeInfoByInputElement(context, input, scope);
18761875
var name = input.getName();
18771876
var elementValue;
18781877
if (this.allowTypedObject && Jsonix.Util.Type.exists(typeInfo)) {
@@ -1889,21 +1888,26 @@ Jsonix.Binding.ElementUnmarshaller = Jsonix.Class({
18891888
}
18901889
callback(elementValue);
18911890
},
1892-
getInputTypeInfo : function (context, input, scope)
1893-
{
1894-
// Issue #70 work in progress here
1891+
getTypeInfoByInputElement : function(context, input, scope) {
18951892
var xsiTypeInfo = null;
18961893
if (context.supportXsiType) {
18971894
var xsiType = input.getAttributeValueNS(Jsonix.Schema.XSI.NAMESPACE_URI, Jsonix.Schema.XSI.TYPE);
1898-
if (Jsonix.Util.StringUtils.isNotBlank(xsiType))
1899-
{
1895+
if (Jsonix.Util.StringUtils.isNotBlank(xsiType)) {
19001896
var xsiTypeName = Jsonix.Schema.XSD.QName.INSTANCE.parse(xsiType, context, input, scope);
19011897
xsiTypeInfo = context.getTypeInfoByTypeNameKey(xsiTypeName.key);
19021898
}
19031899
}
19041900
var name = input.getName();
19051901
var typeInfo = xsiTypeInfo ? xsiTypeInfo : this.getTypeInfoByElementName(name, context, scope);
19061902
return typeInfo;
1903+
},
1904+
getTypeInfoByElementName : function(name, context, scope) {
1905+
var elementInfo = context.getElementInfo(name, scope);
1906+
if (Jsonix.Util.Type.exists(elementInfo)) {
1907+
return elementInfo.typeInfo;
1908+
} else {
1909+
return undefined;
1910+
}
19071911
}
19081912
});
19091913

@@ -2000,14 +2004,6 @@ Jsonix.Binding.Unmarshaller = Jsonix.Class(Jsonix.Binding.ElementUnmarshaller, {
20002004
convertToElementValue : function(elementValue, context, input, scope) {
20012005
return elementValue;
20022006
},
2003-
getTypeInfoByElementName : function(name, context, scope) {
2004-
var elementInfo = context.getElementInfo(name, scope);
2005-
if (Jsonix.Util.Type.exists(elementInfo)) {
2006-
return elementInfo.typeInfo;
2007-
} else {
2008-
return undefined;
2009-
}
2010-
},
20112007
CLASS_NAME : 'Jsonix.Binding.Unmarshaller'
20122008
});
20132009
Jsonix.Binding.Unmarshaller.Simplified = Jsonix.Class(Jsonix.Binding.Unmarshaller, Jsonix.Binding.ElementUnmarshaller.Simplified, {
@@ -3019,12 +3015,8 @@ Jsonix.Model.ElementsPropertyInfo = Jsonix.Class(Jsonix.Model.AbstractElementsPr
30193015
var actualTypeInfo = context.getTypeInfoByValue(value);
30203016
if (actualTypeInfo && actualTypeInfo.typeName)
30213017
{
3022-
console.log("Actual type info:");
3023-
console.log(actualTypeInfo);
30243018
for (var jndex = 0; jndex < this.elementTypeInfos.length; jndex++) {
30253019
var eti = this.elementTypeInfos[jndex];
3026-
console.log("Checking element type info:");
3027-
console.log(eti);
30283020
var ti = eti.typeInfo;
30293021
// TODO Can be optimized
30303022
// Find an element type info which has a type info that is a supertype of the actual type info
@@ -3132,7 +3124,7 @@ Jsonix.Model.ElementMapPropertyInfo = Jsonix.Class(Jsonix.Model.AbstractElements
31323124
}
31333125
return result;
31343126
},
3135-
getInputTypeInfo : function (context, input, scope) {
3127+
getTypeInfoByInputElement : function (context, input, scope) {
31363128
return this.entryTypeInfo;
31373129
},
31383130
convertToElementValue : function(elementValue, context, input, scope) {
@@ -3583,14 +3575,6 @@ Jsonix.Model.AnyElementPropertyInfo = Jsonix.Class(Jsonix.Binding.ElementMarshal
35833575
convertToElementValue : function(elementValue, context, input, scope) {
35843576
return elementValue;
35853577
},
3586-
getTypeInfoByElementName : function(name, context, scope) {
3587-
var elementInfo = context.getElementInfo(name, scope);
3588-
if (Jsonix.Util.Type.exists(elementInfo)) {
3589-
return elementInfo.typeInfo;
3590-
} else {
3591-
return undefined;
3592-
}
3593-
},
35943578
doBuild : function(context, module) {
35953579
// Nothing to do
35963580
},

scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Binding/ElementUnmarshaller.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Jsonix.Binding.ElementUnmarshaller = Jsonix.Class({
2323
if (input.eventType != 1) {
2424
throw new Error("Parser must be on START_ELEMENT to read next element.");
2525
}
26-
var typeInfo = this.getInputTypeInfo(context, input, scope);
26+
var typeInfo = this.getTypeInfoByInputElement(context, input, scope);
2727
var name = input.getName();
2828
var elementValue;
2929
if (this.allowTypedObject && Jsonix.Util.Type.exists(typeInfo)) {
@@ -40,21 +40,26 @@ Jsonix.Binding.ElementUnmarshaller = Jsonix.Class({
4040
}
4141
callback(elementValue);
4242
},
43-
getInputTypeInfo : function (context, input, scope)
44-
{
45-
// Issue #70 work in progress here
43+
getTypeInfoByInputElement : function(context, input, scope) {
4644
var xsiTypeInfo = null;
4745
if (context.supportXsiType) {
4846
var xsiType = input.getAttributeValueNS(Jsonix.Schema.XSI.NAMESPACE_URI, Jsonix.Schema.XSI.TYPE);
49-
if (Jsonix.Util.StringUtils.isNotBlank(xsiType))
50-
{
47+
if (Jsonix.Util.StringUtils.isNotBlank(xsiType)) {
5148
var xsiTypeName = Jsonix.Schema.XSD.QName.INSTANCE.parse(xsiType, context, input, scope);
5249
xsiTypeInfo = context.getTypeInfoByTypeNameKey(xsiTypeName.key);
5350
}
5451
}
5552
var name = input.getName();
5653
var typeInfo = xsiTypeInfo ? xsiTypeInfo : this.getTypeInfoByElementName(name, context, scope);
5754
return typeInfo;
55+
},
56+
getTypeInfoByElementName : function(name, context, scope) {
57+
var elementInfo = context.getElementInfo(name, scope);
58+
if (Jsonix.Util.Type.exists(elementInfo)) {
59+
return elementInfo.typeInfo;
60+
} else {
61+
return undefined;
62+
}
5863
}
5964
});
6065

scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Binding/Unmarshaller.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ Jsonix.Binding.Unmarshaller = Jsonix.Class(Jsonix.Binding.ElementUnmarshaller, {
5757
convertToElementValue : function(elementValue, context, input, scope) {
5858
return elementValue;
5959
},
60-
getTypeInfoByElementName : function(name, context, scope) {
61-
var elementInfo = context.getElementInfo(name, scope);
62-
if (Jsonix.Util.Type.exists(elementInfo)) {
63-
return elementInfo.typeInfo;
64-
} else {
65-
return undefined;
66-
}
67-
},
6860
CLASS_NAME : 'Jsonix.Binding.Unmarshaller'
6961
});
7062
Jsonix.Binding.Unmarshaller.Simplified = Jsonix.Class(Jsonix.Binding.Unmarshaller, Jsonix.Binding.ElementUnmarshaller.Simplified, {

scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Model/AnyElementPropertyInfo.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ Jsonix.Model.AnyElementPropertyInfo = Jsonix.Class(Jsonix.Binding.ElementMarshal
8080
convertToElementValue : function(elementValue, context, input, scope) {
8181
return elementValue;
8282
},
83-
getTypeInfoByElementName : function(name, context, scope) {
84-
var elementInfo = context.getElementInfo(name, scope);
85-
if (Jsonix.Util.Type.exists(elementInfo)) {
86-
return elementInfo.typeInfo;
87-
} else {
88-
return undefined;
89-
}
90-
},
9183
doBuild : function(context, module) {
9284
// Nothing to do
9385
},

scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Model/ElementMapPropertyInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Jsonix.Model.ElementMapPropertyInfo = Jsonix.Class(Jsonix.Model.AbstractElements
6464
}
6565
return result;
6666
},
67-
getInputTypeInfo : function (context, input, scope) {
67+
getTypeInfoByInputElement : function (context, input, scope) {
6868
return this.entryTypeInfo;
6969
},
7070
convertToElementValue : function(elementValue, context, input, scope) {

0 commit comments

Comments
 (0)