Skip to content

Commit 22b8800

Browse files
authored
Merge pull request #142 from duschata/issue_#139
Issue #139
2 parents 3dec21c + 9bdd84e commit 22b8800

File tree

9 files changed

+1759
-1487
lines changed

9 files changed

+1759
-1487
lines changed

typescript/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Because of the lack of a usable UML editor for Typescript I've used IntelliJ's Java-Uml. Typescript .d.ts are close to Java classes, so the diagram helps me to get the big picture.
2+
I investigated mainly the classes in org/hisrc/jsonix/Jsonix/Model to draw it.
3+
4+
This typescript definitions are the first draft and the work is in progress. It's a base to discuss about.
5+
The aims of this branch are:
6+
7+
Defining the public interfaces from the Context (marshaller, unmarshaller)
8+
Defining the internal data types (TypeInfo, PropertyInfo, Mapping)
9+
10+
... a fully migration to TS?
11+
12+
I started with the data types because I need them for my current project
13+
14+
There are still no tests, my suggestion is to use existing ones (and migrating later carefully to TS) but first we have to clear the working process.
15+
E.g.
16+
- Jsonix (sometimes) uses prototype (multiple) inheritance and there is a discussion how to handle this in TS
17+
- how to implement generics (witch would be very usefull)
18+
like createUnmarshaller<T>(type: T): Unmarshaller<T> (doesn't work without changing th jsonix code)
19+
20+
21+

typescript/src/main/java/org/hisrc/jsonix/Binding/Mashalls/Element.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
public interface Element
44
{
55
Object elementInfo = null;
6+
String CLASS_NAME = "";
67
}

typescript/src/main/java/org/hisrc/jsonix/Binding/Unmashalls/Element.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
public interface Element
44
{
55
Object elementInfo = null;
6+
String CLASS_NAME = "";
67
}

typescript/src/main/java/org/hisrc/jsonix/Mapping/Styled.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
public interface Styled
44
{
55
Object mappingSyle = null;
6+
String CLASS_NAME = "";
67
}

typescript/src/main/java/org/hisrc/jsonix/Model/PropertyInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.hisrc.jsonix.Model;
22

33
public class PropertyInfo {
4+
String CLASS_NAME;
45
Object name = null;
56
boolean collection = false;
67
String targetNamespace = "";
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.hisrc.jsonix.Model;
22

3-
public class TypeInfo {
3+
public class TypeInfo{
4+
String CLASS_NAME;
45
String name = "";
56
TypeInfo baseTypeInfo = null;
67
}

typescript/src/main/java/org/hisrc/jsonix/Schema/XML/QName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ public class QName
77
String localPart = null;
88
String prefix = null;
99
String string = null;
10+
String CLASS_NAME = "";
1011

1112
}

typescript/src/main/resources/diagram.svg

Lines changed: 1627 additions & 1402 deletions
Loading

typescript/src/main/typescript/Jsonix.d.ts

Lines changed: 104 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ interface Unmarshaller { //TODO: <T> @see createUnmarshaller
1010
* @param {string} arg (description)
1111
* @returns {Object} (description)
1212
*/
13-
unmarshalString(arg: string): Object;
13+
unmarshalString(arg:string): Object;
1414

1515
/**
1616
* (description)
17-
*
17+
*
1818
* @param {string} fileName (description)
1919
* @param {(unmarshalled:Object)=> void} callback (description)
2020
* @param {Object} options (description)
2121
*/
22-
unmarshalFile(fileName: string, callback: (unmarshalled: Object) => void, options: Object): void;
22+
unmarshalFile(fileName:string, callback:(unmarshalled:Object) => void, options:Object): void;
2323

2424

2525
/**
2626
* (description)
27-
*
27+
*
2828
* @param {string} url (description)
2929
* @param {(unmarshalled:Object)=> void} callback (description)
3030
* @param {Object} options (description)
3131
*/
32-
unmarshalURL(url: string, callback: (unmarshalled: Object) => void, options: Object): void;
32+
unmarshalURL(url:string, callback:(unmarshalled:Object) => void, options:Object): void;
3333

3434
/**
3535
* (description)
36-
*
36+
*
3737
* @param {Element} doc (description)
3838
* @param {string} scope (description)
3939
* @returns {Object} (description)
4040
*/
41-
unmarshalDocument(doc: Element, scope: string): Object;
41+
unmarshalDocument(doc:Element, scope:string): Object;
4242
}
4343
/**
4444
* (description)
@@ -48,19 +48,19 @@ interface Unmarshaller { //TODO: <T> @see createUnmarshaller
4848
interface Marshaller { // TODO: generics like marshalString(object:T):string;
4949
/**
5050
* (description)
51-
*
51+
*
5252
* @param {Object} object (description)
5353
* @returns {string} (description)
5454
*/
55-
marshalString(object: Object): string;
55+
marshalString(object:Object): string;
5656

5757
/**
5858
* (description)
59-
*
59+
*
6060
* @param {Object} object (description)
6161
* @returns {Element} (description)
6262
*/
63-
marshalDocument(object: Object): Element;
63+
marshalDocument(object:Object): Element;
6464
}
6565

6666
declare module Jsonix {
@@ -70,107 +70,107 @@ declare module Jsonix {
7070
*
7171
* @param {any[]} s (description)
7272
*/
73-
constructor(s: any[]);
73+
constructor(s:any[]);
7474

7575
/**
7676
* (description)
7777
*
7878
* @param {string} name (description)
7979
* @returns {TypeInfo} (description)
8080
*/
81-
getTypeInfoByName(name: string): TypeInfo;
81+
getTypeInfoByName(name:string):TypeInfo;
8282

8383
/**
8484
* (description)
8585
*
8686
* @param {string} typeName (description)
8787
* @returns {TypeInfo} (description)
8888
*/
89-
getTypeInfoByTypeName(typeName: string): TypeInfo;
89+
getTypeInfoByTypeName(typeName:string):TypeInfo;
9090

9191
/**
9292
* (description)
9393
*
9494
* @param {string} typeNameKey (description)
9595
* @returns {TypeInfo} (description)
9696
*/
97-
getTypeInfoByTypeNameKey(typeNameKey: string): TypeInfo;
97+
getTypeInfoByTypeNameKey(typeNameKey:string):TypeInfo;
9898

99-
getElementInfo(name: string, scope: string): any;
99+
getElementInfo(name:string, scope:string):any;
100100

101-
getSubstitutionMembers(name: string): any;
101+
getSubstitutionMembers(name:string):any;
102102

103-
createMarshaller(): Marshaller;
103+
createMarshaller():Marshaller;
104104

105-
createUnmarshaller(): Unmarshaller;
105+
createUnmarshaller():Unmarshaller;
106106

107107
//TODO: createUnmarshaller<T>(type: T): Unmarshaller<T>;
108108

109-
getNamespaceURI(prefix: string): any;
109+
getNamespaceURI(prefix:string):any;
110110

111-
getPrefix(namespaceURI: string, defaultPrefix: string): any;
111+
getPrefix(namespaceURI:string, defaultPrefix:string):any;
112112

113-
builtinTypeInfos: {
113+
builtinTypeInfos:{
114114
Jsonix: {
115115
Schema: {
116116
XSD: {
117-
AnyType: { INSTANCE: {} },
118-
AnySimpleType: { INSTANCE: {} },
119-
AnyURI: { INSTANCE: {} },
120-
Base64Binary: { INSTANCE: {} },
121-
Boolean: { INSTANCE: {} },
122-
Byte: { INSTANCE: {} },
123-
Calendar: { INSTANCE: {} },
124-
DateAsDate: { INSTANCE: {} },
125-
Date: { INSTANCE: {} },
126-
DateTimeAsDate: { INSTANCE: {} },
127-
DateTime: { INSTANCE: {} },
128-
Decimal: { INSTANCE: {} },
129-
Double: { INSTANCE: {} },
130-
Duration: { INSTANCE: {} },
131-
Float: { INSTANCE: {} },
132-
GDay: { INSTANCE: {} },
133-
GMonth: { INSTANCE: {} },
134-
GMonthDay: { INSTANCE: {} },
135-
GYear: { INSTANCE: {} },
136-
GYearMonth: { INSTANCE: {} },
137-
HexBinary: { INSTANCE: {} },
138-
ID: { INSTANCE: {} },
139-
IDREF: { INSTANCE: {} },
140-
IDREFS: { INSTANCE: {} },
141-
Int: { INSTANCE: {} },
142-
Integer: { INSTANCE: {} },
143-
Language: { INSTANCE: {} },
144-
Long: { INSTANCE: {} },
145-
Name: { INSTANCE: {} },
146-
NCName: { INSTANCE: {} },
147-
NegativeInteger: { INSTANCE: {} },
148-
NMToken: { INSTANCE: {} },
149-
NMTokens: { INSTANCE: {} },
150-
NonNegativeInteger: { INSTANCE: {} },
151-
NonPositiveInteger: { INSTANCE: {} },
152-
NormalizedString: { INSTANCE: {} },
153-
Number: { INSTANCE: {} },
154-
PositiveInteger: { INSTANCE: {} },
155-
QName: { INSTANCE: {} },
156-
Short: { INSTANCE: {} },
157-
String: { INSTANCE: {} },
158-
Strings: { INSTANCE: {} },
159-
TimeAsDate: { INSTANCE: {} },
160-
Time: { INSTANCE: {} },
161-
Token: { INSTANCE: {} },
162-
UnsignedByte: { INSTANCE: {} },
163-
UnsignedInt: { INSTANCE: {} },
164-
UnsignedLong: { INSTANCE: {} },
165-
UnsignedShort: { INSTANCE: {} },
117+
AnyType: { INSTANCE: {} };
118+
AnySimpleType: { INSTANCE: {} };
119+
AnyURI: { INSTANCE: {} };
120+
Base64Binary: { INSTANCE: {} };
121+
Boolean: { INSTANCE: {} };
122+
Byte: { INSTANCE: {} };
123+
Calendar: { INSTANCE: {} };
124+
DateAsDate: { INSTANCE: {} };
125+
Date: { INSTANCE: {} };
126+
DateTimeAsDate: { INSTANCE: {} };
127+
DateTime: { INSTANCE: {} };
128+
Decimal: { INSTANCE: {} };
129+
Double: { INSTANCE: {} };
130+
Duration: { INSTANCE: {} };
131+
Float: { INSTANCE: {} };
132+
GDay: { INSTANCE: {} };
133+
GMonth: { INSTANCE: {} };
134+
GMonthDay: { INSTANCE: {} };
135+
GYear: { INSTANCE: {} };
136+
GYearMonth: { INSTANCE: {} };
137+
HexBinary: { INSTANCE: {} };
138+
ID: { INSTANCE: {} };
139+
IDREF: { INSTANCE: {} };
140+
IDREFS: { INSTANCE: {} };
141+
Int: { INSTANCE: {} };
142+
Integer: { INSTANCE: {} };
143+
Language: { INSTANCE: {} };
144+
Long: { INSTANCE: {} };
145+
Name: { INSTANCE: {} };
146+
NCName: { INSTANCE: {} };
147+
NegativeInteger: { INSTANCE: {} };
148+
NMToken: { INSTANCE: {} };
149+
NMTokens: { INSTANCE: {} };
150+
NonNegativeInteger: { INSTANCE: {} };
151+
NonPositiveInteger: { INSTANCE: {} };
152+
NormalizedString: { INSTANCE: {} };
153+
Number: { INSTANCE: {} };
154+
PositiveInteger: { INSTANCE: {} };
155+
QName: { INSTANCE: {} };
156+
Short: { INSTANCE: {} };
157+
String: { INSTANCE: {} };
158+
Strings: { INSTANCE: {} };
159+
TimeAsDate: { INSTANCE: {} };
160+
Time: { INSTANCE: {} };
161+
Token: { INSTANCE: {} };
162+
UnsignedByte: { INSTANCE: {} };
163+
UnsignedInt: { INSTANCE: {} };
164+
UnsignedLong: { INSTANCE: {} };
165+
UnsignedShort: { INSTANCE: {} };
166166
}
167167
}
168168
}
169169
}[];
170170

171171

172172
// private
173-
elementInfos: ClassInfo[];
173+
elementInfos:ClassInfo[];
174174

175175
}
176176
}
@@ -182,7 +182,7 @@ declare module Jsonix {
182182
* @interface Styled
183183
*/
184184
interface Styled {
185-
//{ CLASS_NAME: string },
185+
CLASS_NAME: string;
186186
mappingStyle: Object;
187187
}
188188

@@ -193,6 +193,7 @@ interface Styled {
193193
* @interface QName
194194
*/
195195
interface QName {
196+
CLASS_NAME: string;
196197
key: string;
197198
namespaceURI: string;
198199
localPart: string;
@@ -207,16 +208,34 @@ interface QName {
207208
* @interface TypeInfo
208209
*/
209210
interface TypeInfo {
210-
name: string,
211-
baseTypeInfo: TypeInfo,
211+
name: string;
212+
baseTypeInfo: TypeInfo;
213+
}
214+
215+
/**
216+
* (description)
217+
*
218+
* @interface EnumLeafInfo
219+
* @extends {TypeInfo}
220+
*/
221+
interface EnumLeafInfo extends TypeInfo {
222+
name: string;
223+
baseTypeInfo: TypeInfo;
224+
entries: { [name: string]: string };
225+
keys: { [index: number]: string };
226+
values: { [index: number]: string };
227+
built: boolean;
228+
212229
}
213230

231+
214232
/**
215233
* (description)
216234
*
217235
* @interface PropertyInfo
218236
*/
219237
interface PropertyInfo {
238+
CLASS_NAME: string;
220239
name: string;
221240
collection: boolean;
222241
targetNamespace: string;
@@ -246,7 +265,7 @@ interface AbstractElementPropertyInfo extends PropertyInfo {
246265
* @extends {AbstractElementPropertyInfo}
247266
*/
248267
interface ElementPropertyInfo extends AbstractElementPropertyInfo {
249-
typeInfo: ClassInfo | string;
268+
typeInfo: TypeInfo | string;
250269
elementName: QName;
251270
}
252271

@@ -259,27 +278,28 @@ interface ElementPropertyInfo extends AbstractElementPropertyInfo {
259278
* @extends {Styled}
260279
*/
261280
interface ClassInfo extends TypeInfo, Styled {
281+
CLASS_NAME: string;
262282
localName: string;
263283
typeName: QName;
264284
instanceFactory: {};
265285
properties: { [index: number]: PropertyInfo };
266286
propertiesMap: { [name: string]: PropertyInfo };
267287
//is inner class
268288
structure: {
269-
elements: { [fqn: string]: PropertyInfo },
270-
attributes: {},
271-
anyAttribute: {},
272-
value: {},
289+
elements: { [fqn: string]: PropertyInfo };
290+
attributes: {};
291+
anyAttribute: {};
292+
value: {};
273293
any: {}
274294
};
275-
targetNamespace: string,
276-
defaultElementNamespaceURI: string,
295+
targetNamespace: string;
296+
defaultElementNamespaceURI: string;
277297
defaultAttributeNamespaceURI: string
278-
built: boolean,
298+
built: boolean;
279299
//TODO: confirm this syntax
280300
propertyInfoCreators: {
281301
aa: { aa };
282-
anyAttribute: { aa },
302+
anyAttribute: { aa };
283303
ae: { ae };
284304
anyElement: { ae };
285305
a: { a };

0 commit comments

Comments
 (0)