Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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.
I investigated mainly the classes in org/hisrc/jsonix/Jsonix/Model to draw it.

This typescript definitions are the first draft and the work is in progress. It's a base to discuss about.
The aims of this branch are:

Defining the public interfaces from the Context (marshaller, unmarshaller)
Defining the internal data types (TypeInfo, PropertyInfo, Mapping)

... a fully migration to TS?

I started with the data types because I need them for my current project

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.
E.g.
- Jsonix (sometimes) uses prototype (multiple) inheritance and there is a discussion how to handle this in TS
- how to implement generics (witch would be very usefull)
like createUnmarshaller<T>(type: T): Unmarshaller<T> (doesn't work without changing th jsonix code)



Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface Element
{
Object elementInfo = null;
String CLASS_NAME = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface Element
{
Object elementInfo = null;
String CLASS_NAME = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface Styled
{
Object mappingSyle = null;
String CLASS_NAME = "";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hisrc.jsonix.Model;

public class PropertyInfo {
String CLASS_NAME;
Object name = null;
boolean collection = false;
String targetNamespace = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hisrc.jsonix.Model;

public class TypeInfo {
public class TypeInfo{
String CLASS_NAME;
String name = "";
TypeInfo baseTypeInfo = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class QName
String localPart = null;
String prefix = null;
String string = null;
String CLASS_NAME = "";

}
3,029 changes: 1,627 additions & 1,402 deletions typescript/src/main/resources/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
188 changes: 104 additions & 84 deletions typescript/src/main/typescript/Jsonix.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ interface Unmarshaller { //TODO: <T> @see createUnmarshaller
* @param {string} arg (description)
* @returns {Object} (description)
*/
unmarshalString(arg: string): Object;
unmarshalString(arg:string): Object;

/**
* (description)
*
*
* @param {string} fileName (description)
* @param {(unmarshalled:Object)=> void} callback (description)
* @param {Object} options (description)
*/
unmarshalFile(fileName: string, callback: (unmarshalled: Object) => void, options: Object): void;
unmarshalFile(fileName:string, callback:(unmarshalled:Object) => void, options:Object): void;


/**
* (description)
*
*
* @param {string} url (description)
* @param {(unmarshalled:Object)=> void} callback (description)
* @param {Object} options (description)
*/
unmarshalURL(url: string, callback: (unmarshalled: Object) => void, options: Object): void;
unmarshalURL(url:string, callback:(unmarshalled:Object) => void, options:Object): void;

/**
* (description)
*
*
* @param {Element} doc (description)
* @param {string} scope (description)
* @returns {Object} (description)
*/
unmarshalDocument(doc: Element, scope: string): Object;
unmarshalDocument(doc:Element, scope:string): Object;
}
/**
* (description)
Expand All @@ -48,19 +48,19 @@ interface Unmarshaller { //TODO: <T> @see createUnmarshaller
interface Marshaller { // TODO: generics like marshalString(object:T):string;
/**
* (description)
*
*
* @param {Object} object (description)
* @returns {string} (description)
*/
marshalString(object: Object): string;
marshalString(object:Object): string;

/**
* (description)
*
*
* @param {Object} object (description)
* @returns {Element} (description)
*/
marshalDocument(object: Object): Element;
marshalDocument(object:Object): Element;
}

declare module Jsonix {
Expand All @@ -70,107 +70,107 @@ declare module Jsonix {
*
* @param {any[]} s (description)
*/
constructor(s: any[]);
constructor(s:any[]);

/**
* (description)
*
* @param {string} name (description)
* @returns {TypeInfo} (description)
*/
getTypeInfoByName(name: string): TypeInfo;
getTypeInfoByName(name:string):TypeInfo;

/**
* (description)
*
* @param {string} typeName (description)
* @returns {TypeInfo} (description)
*/
getTypeInfoByTypeName(typeName: string): TypeInfo;
getTypeInfoByTypeName(typeName:string):TypeInfo;

/**
* (description)
*
* @param {string} typeNameKey (description)
* @returns {TypeInfo} (description)
*/
getTypeInfoByTypeNameKey(typeNameKey: string): TypeInfo;
getTypeInfoByTypeNameKey(typeNameKey:string):TypeInfo;

getElementInfo(name: string, scope: string): any;
getElementInfo(name:string, scope:string):any;

getSubstitutionMembers(name: string): any;
getSubstitutionMembers(name:string):any;

createMarshaller(): Marshaller;
createMarshaller():Marshaller;

createUnmarshaller(): Unmarshaller;
createUnmarshaller():Unmarshaller;

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

getNamespaceURI(prefix: string): any;
getNamespaceURI(prefix:string):any;

getPrefix(namespaceURI: string, defaultPrefix: string): any;
getPrefix(namespaceURI:string, defaultPrefix:string):any;

builtinTypeInfos: {
builtinTypeInfos:{
Jsonix: {
Schema: {
XSD: {
AnyType: { INSTANCE: {} },
AnySimpleType: { INSTANCE: {} },
AnyURI: { INSTANCE: {} },
Base64Binary: { INSTANCE: {} },
Boolean: { INSTANCE: {} },
Byte: { INSTANCE: {} },
Calendar: { INSTANCE: {} },
DateAsDate: { INSTANCE: {} },
Date: { INSTANCE: {} },
DateTimeAsDate: { INSTANCE: {} },
DateTime: { INSTANCE: {} },
Decimal: { INSTANCE: {} },
Double: { INSTANCE: {} },
Duration: { INSTANCE: {} },
Float: { INSTANCE: {} },
GDay: { INSTANCE: {} },
GMonth: { INSTANCE: {} },
GMonthDay: { INSTANCE: {} },
GYear: { INSTANCE: {} },
GYearMonth: { INSTANCE: {} },
HexBinary: { INSTANCE: {} },
ID: { INSTANCE: {} },
IDREF: { INSTANCE: {} },
IDREFS: { INSTANCE: {} },
Int: { INSTANCE: {} },
Integer: { INSTANCE: {} },
Language: { INSTANCE: {} },
Long: { INSTANCE: {} },
Name: { INSTANCE: {} },
NCName: { INSTANCE: {} },
NegativeInteger: { INSTANCE: {} },
NMToken: { INSTANCE: {} },
NMTokens: { INSTANCE: {} },
NonNegativeInteger: { INSTANCE: {} },
NonPositiveInteger: { INSTANCE: {} },
NormalizedString: { INSTANCE: {} },
Number: { INSTANCE: {} },
PositiveInteger: { INSTANCE: {} },
QName: { INSTANCE: {} },
Short: { INSTANCE: {} },
String: { INSTANCE: {} },
Strings: { INSTANCE: {} },
TimeAsDate: { INSTANCE: {} },
Time: { INSTANCE: {} },
Token: { INSTANCE: {} },
UnsignedByte: { INSTANCE: {} },
UnsignedInt: { INSTANCE: {} },
UnsignedLong: { INSTANCE: {} },
UnsignedShort: { INSTANCE: {} },
AnyType: { INSTANCE: {} };
AnySimpleType: { INSTANCE: {} };
AnyURI: { INSTANCE: {} };
Base64Binary: { INSTANCE: {} };
Boolean: { INSTANCE: {} };
Byte: { INSTANCE: {} };
Calendar: { INSTANCE: {} };
DateAsDate: { INSTANCE: {} };
Date: { INSTANCE: {} };
DateTimeAsDate: { INSTANCE: {} };
DateTime: { INSTANCE: {} };
Decimal: { INSTANCE: {} };
Double: { INSTANCE: {} };
Duration: { INSTANCE: {} };
Float: { INSTANCE: {} };
GDay: { INSTANCE: {} };
GMonth: { INSTANCE: {} };
GMonthDay: { INSTANCE: {} };
GYear: { INSTANCE: {} };
GYearMonth: { INSTANCE: {} };
HexBinary: { INSTANCE: {} };
ID: { INSTANCE: {} };
IDREF: { INSTANCE: {} };
IDREFS: { INSTANCE: {} };
Int: { INSTANCE: {} };
Integer: { INSTANCE: {} };
Language: { INSTANCE: {} };
Long: { INSTANCE: {} };
Name: { INSTANCE: {} };
NCName: { INSTANCE: {} };
NegativeInteger: { INSTANCE: {} };
NMToken: { INSTANCE: {} };
NMTokens: { INSTANCE: {} };
NonNegativeInteger: { INSTANCE: {} };
NonPositiveInteger: { INSTANCE: {} };
NormalizedString: { INSTANCE: {} };
Number: { INSTANCE: {} };
PositiveInteger: { INSTANCE: {} };
QName: { INSTANCE: {} };
Short: { INSTANCE: {} };
String: { INSTANCE: {} };
Strings: { INSTANCE: {} };
TimeAsDate: { INSTANCE: {} };
Time: { INSTANCE: {} };
Token: { INSTANCE: {} };
UnsignedByte: { INSTANCE: {} };
UnsignedInt: { INSTANCE: {} };
UnsignedLong: { INSTANCE: {} };
UnsignedShort: { INSTANCE: {} };
}
}
}
}[];


// private
elementInfos: ClassInfo[];
elementInfos:ClassInfo[];

}
}
Expand All @@ -182,7 +182,7 @@ declare module Jsonix {
* @interface Styled
*/
interface Styled {
//{ CLASS_NAME: string },
CLASS_NAME: string;
mappingStyle: Object;
}

Expand All @@ -193,6 +193,7 @@ interface Styled {
* @interface QName
*/
interface QName {
CLASS_NAME: string;
key: string;
namespaceURI: string;
localPart: string;
Expand All @@ -207,16 +208,34 @@ interface QName {
* @interface TypeInfo
*/
interface TypeInfo {
name: string,
baseTypeInfo: TypeInfo,
name: string;
baseTypeInfo: TypeInfo;
}

/**
* (description)
*
* @interface EnumLeafInfo
* @extends {TypeInfo}
*/
interface EnumLeafInfo extends TypeInfo {
name: string;
baseTypeInfo: TypeInfo;
entries: { [name: string]: string };
keys: { [index: number]: string };
values: { [index: number]: string };
built: boolean;

}


/**
* (description)
*
* @interface PropertyInfo
*/
interface PropertyInfo {
CLASS_NAME: string;
name: string;
collection: boolean;
targetNamespace: string;
Expand Down Expand Up @@ -246,7 +265,7 @@ interface AbstractElementPropertyInfo extends PropertyInfo {
* @extends {AbstractElementPropertyInfo}
*/
interface ElementPropertyInfo extends AbstractElementPropertyInfo {
typeInfo: ClassInfo | string;
typeInfo: TypeInfo | string;
elementName: QName;
}

Expand All @@ -259,27 +278,28 @@ interface ElementPropertyInfo extends AbstractElementPropertyInfo {
* @extends {Styled}
*/
interface ClassInfo extends TypeInfo, Styled {
CLASS_NAME: string;
localName: string;
typeName: QName;
instanceFactory: {};
properties: { [index: number]: PropertyInfo };
propertiesMap: { [name: string]: PropertyInfo };
//is inner class
structure: {
elements: { [fqn: string]: PropertyInfo },
attributes: {},
anyAttribute: {},
value: {},
elements: { [fqn: string]: PropertyInfo };
attributes: {};
anyAttribute: {};
value: {};
any: {}
};
targetNamespace: string,
defaultElementNamespaceURI: string,
targetNamespace: string;
defaultElementNamespaceURI: string;
defaultAttributeNamespaceURI: string
built: boolean,
built: boolean;
//TODO: confirm this syntax
propertyInfoCreators: {
aa: { aa };
anyAttribute: { aa },
anyAttribute: { aa };
ae: { ae };
anyElement: { ae };
a: { a };
Expand Down