diff --git a/bower.json b/bower.json index 61dcb5d8..3e0d9841 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jsonix", - "version": "2.2.2-SNAPSHOT", + "version": "2.3.0", "homepage": "https://github.com/highsource/jsonix", "authors": [ "Alexey Valikov" diff --git a/dist/Jsonix-all.js b/dist/Jsonix-all.js index 41e93115..c40178e6 100644 --- a/dist/Jsonix-all.js +++ b/dist/Jsonix-all.js @@ -370,6 +370,9 @@ Jsonix.Util.Type = { isRegExp : function(value) { return !!(value && value.test && value.exec && (value.ignoreCase || value.ignoreCase === false)); }, + isNode : function(value) { + return (typeof Node === "object" || typeof Node === "function") ? (value instanceof Node) : (value && (typeof value === "object") && (typeof value.nodeType === "number") && (typeof value.nodeName==="string")); + }, isEqual : function(a, b, report) { var doReport = Jsonix.Util.Type.isFunction(report); // TODO rework @@ -443,12 +446,33 @@ Jsonix.Util.Type = { if (Jsonix.Util.Type.isRegExp(a) && Jsonix.Util.Type.isRegExp(b)) { return a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline; } + + if (Jsonix.Util.Type.isNode(a) && Jsonix.Util.Type.isNode(b)) + { + var aSerialized = Jsonix.DOM.serialize(a); + var bSerialized = Jsonix.DOM.serialize(b); + if (aSerialized !== bSerialized) + { + if (doReport) + { + report('Nodes differ.'); + report('A=' + aSerialized); + report('B=' + bSerialized); + } + return false; + } + else + { + return true; + } + } + // If a is not an object by this point, we can't handle it. if (atype !== 'object') { return false; } // Check for different array lengths before comparing contents. - if (a.length && (a.length !== b.length)) { + if (Jsonix.Util.Type.isArray(a) && (a.length !== b.length)) { if (doReport) { report('Lengths differ.'); report('A.length=' + a.length); @@ -460,7 +484,7 @@ Jsonix.Util.Type = { var aKeys = _keys(a); var bKeys = _keys(b); // Different object sizes? - if (aKeys.length != bKeys.length) { + if (aKeys.length !== bKeys.length) { if (doReport) { report('Different number of properties [' + aKeys.length + '], [' + bKeys.length + '].'); } @@ -909,89 +933,68 @@ Jsonix.XML.Calendar = Jsonix.Class({ second : NaN, fractionalSecond : NaN, timezone : NaN, + date : null, initialize : function(data) { Jsonix.Util.Ensure.ensureObject(data); // Year if (Jsonix.Util.Type.exists(data.year)) { Jsonix.Util.Ensure.ensureInteger(data.year); - if (data.year >= -9999 && data.year <= 9999) { - this.year = data.year; - } else { - throw new Error('Invalid year [' + data.year + '].'); - } - + Jsonix.XML.Calendar.validateYear(data.year); + this.year = data.year; } else { this.year = NaN; } // Month if (Jsonix.Util.Type.exists(data.month)) { Jsonix.Util.Ensure.ensureInteger(data.month); - if (data.month >= 1 && data.month <= 12) { - this.month = data.month; - } else { - throw new Error('Invalid month [' + data.month + '].'); - } - + Jsonix.XML.Calendar.validateMonth(data.month); + this.month = data.month; } else { this.month = NaN; } // Day if (Jsonix.Util.Type.exists(data.day)) { Jsonix.Util.Ensure.ensureInteger(data.day); - if (data.day >= 1 && data.day <= 31) { - this.day = data.day; + if (Jsonix.Util.NumberUtils.isInteger(data.year) && Jsonix.Util.NumberUtils.isInteger(data.month)) { + Jsonix.XML.Calendar.validateYearMonthDay(data.year, data.month, data.day); + } else if (Jsonix.Util.NumberUtils.isInteger(data.month)) { + Jsonix.XML.Calendar.validateMonthDay(data.month, data.day); } else { - throw new Error('Invalid day [' + data.day + '].'); + Jsonix.XML.Calendar.validateDay(data.day); } - + this.day = data.day; } else { this.day = NaN; } // Hour if (Jsonix.Util.Type.exists(data.hour)) { Jsonix.Util.Ensure.ensureInteger(data.hour); - if (data.hour >= 0 && data.hour <= 23) { - this.hour = data.hour; - } else { - throw new Error('Invalid hour [' + data.hour + '].'); - } - + Jsonix.XML.Calendar.validateHour(data.hour); + this.hour = data.hour; } else { this.hour = NaN; } // Minute if (Jsonix.Util.Type.exists(data.minute)) { Jsonix.Util.Ensure.ensureInteger(data.minute); - if (data.minute >= 0 && data.minute <= 59) { - this.minute = data.minute; - } else { - throw new Error('Invalid minute [' + data.minute + '].'); - } - + Jsonix.XML.Calendar.validateMinute(data.minute); + this.minute = data.minute; } else { this.minute = NaN; } // Second if (Jsonix.Util.Type.exists(data.second)) { Jsonix.Util.Ensure.ensureInteger(data.second); - if (data.second >= 0 && data.second <= 59) { - this.second = data.second; - } else { - throw new Error('Invalid second [' + data.second + '].'); - } - + Jsonix.XML.Calendar.validateSecond(data.second); + this.second = data.second; } else { this.second = NaN; } // Fractional second if (Jsonix.Util.Type.exists(data.fractionalSecond)) { Jsonix.Util.Ensure.ensureNumber(data.fractionalSecond); - if (data.fractionalSecond >= 0 && data.fractionalSecond < 1) { - this.fractionalSecond = data.fractionalSecond; - } else { - throw new Error('Invalid fractional second [' + data.fractionalSecond + '].'); - } - + Jsonix.XML.Calendar.validateFractionalSecond(data.fractionalSecond); + this.fractionalSecond = data.fractionalSecond; } else { this.fractionalSecond = NaN; } @@ -1001,18 +1004,29 @@ Jsonix.XML.Calendar = Jsonix.Class({ this.timezone = NaN; } else { Jsonix.Util.Ensure.ensureInteger(data.timezone); - if (data.timezone >= -1440 && data.timezone < 1440) { - this.timezone = data.timezone; - } else { - throw new Error('Invalid timezone [' + data.timezone + '].'); - } + Jsonix.XML.Calendar.validateTimezone(data.timezone); + this.timezone = data.timezone; } } else { this.timezone = NaN; } + + var initialDate = new Date(0); + initialDate.setUTCFullYear(this.year || 1970); + initialDate.setUTCMonth(this.month - 1 || 0); + initialDate.setUTCDate(this.day || 1); + initialDate.setUTCHours(this.hour || 0); + initialDate.setUTCMinutes(this.minute || 0); + initialDate.setUTCSeconds(this.second || 0); + initialDate.setUTCMilliseconds((this.fractionalSecond || 0) * 1000); + var timezoneOffset = -60000 * (this.timezone || 0); + this.date = new Date(initialDate.getTime() + timezoneOffset); }, CLASS_NAME : "Jsonix.XML.Calendar" }); +Jsonix.XML.Calendar.MIN_TIMEZONE = -14 * 60; +Jsonix.XML.Calendar.MAX_TIMEZONE = 14 * 60; +Jsonix.XML.Calendar.DAYS_IN_MONTH = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; Jsonix.XML.Calendar.fromObject = function(object) { Jsonix.Util.Ensure.ensureObject(object); if (Jsonix.Util.Type.isString(object.CLASS_NAME) && object.CLASS_NAME === 'Jsonix.XML.Calendar') { @@ -1020,6 +1034,58 @@ Jsonix.XML.Calendar.fromObject = function(object) { } return new Jsonix.XML.Calendar(object); }; +Jsonix.XML.Calendar.validateYear = function(year) { + if (year === 0) { + throw new Error('Invalid year [' + year + ']. Year must not be [0].'); + } +}; +Jsonix.XML.Calendar.validateMonth = function(month) { + if (month < 1 || month > 12) { + throw new Error('Invalid month [' + month + ']. Month must be in range [1, 12].'); + } +}; +Jsonix.XML.Calendar.validateDay = function(day) { + if (day < 1 || day > 31) { + throw new Error('Invalid day [' + day + ']. Day must be in range [1, 31].'); + } +}; +Jsonix.XML.Calendar.validateMonthDay = function(month, day) { + Jsonix.XML.Calendar.validateMonth(month); + var maxDaysInMonth = Jsonix.XML.Calendar.DAYS_IN_MONTH[month - 1]; + if (day < 1 || day > Jsonix.XML.Calendar.DAYS_IN_MONTH[month - 1]) { + throw new Error('Invalid day [' + day + ']. Day must be in range [1, ' + maxDaysInMonth + '].'); + } +}; +Jsonix.XML.Calendar.validateYearMonthDay = function(year, month, day) { + // #93 TODO proper validation of 28/29 02 + Jsonix.XML.Calendar.validateYear(year); + Jsonix.XML.Calendar.validateMonthDay(month, day); +}; +Jsonix.XML.Calendar.validateHour = function(hour) { + if (hour < 0 || hour > 23) { + throw new Error('Invalid hour [' + hour + ']. Hour must be in range [0, 23].'); + } +}; +Jsonix.XML.Calendar.validateMinute = function(minute) { + if (minute < 0 || minute > 59) { + throw new Error('Invalid minute [' + minute + ']. Minute must be in range [0, 59].'); + } +}; +Jsonix.XML.Calendar.validateSecond = function(second) { + if (second < 0 || second > 59) { + throw new Error('Invalid second [' + second + ']. Second must be in range [0, 59].'); + } +}; +Jsonix.XML.Calendar.validateFractionalSecond = function(fractionalSecond) { + if (fractionalSecond < 0 || fractionalSecond > 59) { + throw new Error('Invalid fractional second [' + fractionalSecond + ']. Fractional second must be in range [0, 1).'); + } +}; +Jsonix.XML.Calendar.validateTimezone = function(timezone) { + if (timezone < Jsonix.XML.Calendar.MIN_TIMEZONE || timezone > Jsonix.XML.Calendar.MAX_TIMEZONE) { + throw new Error('Invalid timezone [' + timezone + ']. Timezone must not be in range [' + Jsonix.XML.Calendar.MIN_TIMEZONE + ', ' + Jsonix.XML.Calendar.MAX_TIMEZONE + '].'); + } +}; Jsonix.XML.Input = Jsonix.Class({ root : null, node : null, @@ -1848,8 +1914,7 @@ Jsonix.Binding.Marshalls.Element.AsElementRef = Jsonix.Class({ } }); -Jsonix.Binding.Unmarshalls = { -}; +Jsonix.Binding.Unmarshalls = {}; Jsonix.Binding.Unmarshalls.WrapperElement = Jsonix.Class({ mixed : false, @@ -1882,19 +1947,24 @@ Jsonix.Binding.Unmarshalls.Element = Jsonix.Class({ var typeInfo = this.getTypeInfoByInputElement(context, input, scope); var name = input.getName(); var elementValue; - if (this.allowTypedObject && Jsonix.Util.Type.exists(typeInfo)) { - var value = typeInfo.unmarshal(context, input, scope); - var typedNamedValue = { - name : name, - value : value, - typeInfo : typeInfo - }; - elementValue = this.convertFromTypedNamedValue(typedNamedValue, context, input, scope); + if (this.allowTypedObject) { + if (Jsonix.Util.Type.exists(typeInfo)) { + var value = typeInfo.unmarshal(context, input, scope); + var typedNamedValue = { + name : name, + value : value, + typeInfo : typeInfo + }; + elementValue = this.convertFromTypedNamedValue(typedNamedValue, context, input, scope); + } else if (this.allowDom) { + elementValue = input.getElement(); + } else { + throw new Error("Element [" + name.toString() + "] could not be unmarshalled as is not known in this context and the property does not allow DOM content."); + } } else if (this.allowDom) { elementValue = input.getElement(); } else { - // TODO better exception - throw new Error("Element [" + name.toString() + "] is not known in this context and property does not allow DOM."); + throw new Error("Element [" + name.toString() + "] could not be unmarshalled as the property neither allows typed objects nor DOM as content. This is a sign of invalid mappings, do not use [allowTypedObject : false] and [allowDom : false] at the same time."); } callback(elementValue); }, @@ -4642,295 +4712,180 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { typeName : Jsonix.Schema.XSD.qname('calendar'), parse : function(text, context, input, scope) { Jsonix.Util.Ensure.ensureString(text); - var negative = (text.charAt(0) === '-'); - var sign = negative ? -1 : 1; - var data = negative ? text.substring(1) : text; - - // Detect pattern - - var result; - if (data.length >= 19 && data.charAt(4) === '-' && data.charAt(7) === '-' && data.charAt(10) === 'T' && data.charAt(13) === ':' && data.charAt(16) === ':') { - return this.parseDateTime(text); - } else if (data.length >= 10 && data.charAt(4) === '-' && data.charAt(7) === '-') { - return this.parseDate(text); - } else if (data.length >= 8 && data.charAt(2) === ':' && data.charAt(5) === ':') { - return this.parseTime(text); - } else { - throw new Error('Value [' + text + '] does not match dateTime, date or time patterns.'); - } - }, - parseDateTime : function(text) { - Jsonix.Util.Ensure.ensureString(text); - var negative = (text.charAt(0) === '-'); - var sign = negative ? -1 : 1; - - var dateTimeWithTimeZone = negative ? text.substring(1) : text; - - if (dateTimeWithTimeZone.length < 19 || dateTimeWithTimeZone.charAt(4) !== '-' || dateTimeWithTimeZone.charAt(7) !== '-' || dateTimeWithTimeZone.charAt(10) !== 'T' || dateTimeWithTimeZone.charAt(13) !== ':' || dateTimeWithTimeZone.charAt(16) !== ':') { - throw new Error('Date time string [' + dateTimeWithTimeZone + '] must be a string in format [\'-\'? yyyy \'-\' mm \'-\' dd \'T\' hh \':\' mm \':\' ss (\'.\' s+)? (zzzzzz)?].'); - } - - var timeZoneIndex; - var plusIndex = dateTimeWithTimeZone.indexOf('+', 19); - if (plusIndex >= 0) { - timeZoneIndex = plusIndex; - } else { - var minusIndex = dateTimeWithTimeZone.indexOf('-', 19); - if (minusIndex >= 0) { - timeZoneIndex = minusIndex; - } else { - var zIndex = dateTimeWithTimeZone.indexOf('Z', 19); - if (zIndex >= 0) { - timeZoneIndex = zIndex; - } else { - timeZoneIndex = dateTimeWithTimeZone.length; - } - } - } - - var validTimeZoneIndex = timeZoneIndex > 0 && timeZoneIndex < dateTimeWithTimeZone.length; - - var dateString = dateTimeWithTimeZone.substring(0, 10); - var timeString = validTimeZoneIndex ? dateTimeWithTimeZone.substring(11, timeZoneIndex) : dateTimeWithTimeZone.substring(11); - var timeZoneString = validTimeZoneIndex ? dateTimeWithTimeZone.substring(timeZoneIndex) : ''; - var date = this.parseDateString(dateString); - var time = this.parseTimeString(timeString); - var timezone = this.parseTimeZoneString(timeZoneString); - - return Jsonix.XML.Calendar.fromObject({ - year : sign * date.year, - month : date.month, - day : date.day, - hour : time.hour, - minute : time.minute, - second : time.second, - fractionalSecond : time.fractionalSecond, - timezone : timezone - }); - - }, - parseDate : function(text) { - Jsonix.Util.Ensure.ensureString(text); - - var negative = (text.charAt(0) === '-'); - var sign = negative ? -1 : 1; - - var dateWithTimeZone = negative ? text.substring(1) : text; - - var timeZoneIndex; - var plusIndex = dateWithTimeZone.indexOf('+', 10); - if (plusIndex >= 0) { - timeZoneIndex = plusIndex; - } else { - var minusIndex = dateWithTimeZone.indexOf('-', 10); - if (minusIndex >= 0) { - timeZoneIndex = minusIndex; - } else { - var zIndex = dateWithTimeZone.indexOf('Z', 10); - if (zIndex >= 0) { - timeZoneIndex = zIndex; - } else { - timeZoneIndex = dateWithTimeZone.length; - } - } - } - var validTimeZoneIndex = timeZoneIndex > 0 && timeZoneIndex < dateWithTimeZone.length; - var dateString = validTimeZoneIndex ? dateWithTimeZone.substring(0, timeZoneIndex) : dateWithTimeZone; - - var date = this.parseDateString(dateString); - var timeZoneString = validTimeZoneIndex ? text.substring(timeZoneIndex) : ''; - var timezone = this.parseTimeZoneString(timeZoneString); - - return Jsonix.XML.Calendar.fromObject({ - year : sign * date.year, - month : date.month, - day : date.day, - timezone : timezone - }); - - }, - parseTime : function(text) { - Jsonix.Util.Ensure.ensureString(text); - var timeZoneIndex; - var plusIndex = text.indexOf('+', 7); - if (plusIndex >= 0) { - timeZoneIndex = plusIndex; + if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN + "$"))) { + return this.parseDateTime(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.DATE_PATTERN + "$"))) { + return this.parseDate(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.TIME_PATTERN + "$"))) { + return this.parseTime(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_MONTH_PATTERN + "$"))) { + return this.parseGYearMonth(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN + "$"))) { + return this.parseGYear(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.GMONTH_DAY_PATTERN + "$"))) { + return this.parseGMonthDay(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.GMONTH_PATTERN + "$"))) { + return this.parseGMonth(text, context, input, scope); + } else if (text.match(new RegExp("^" + Jsonix.Schema.XSD.Calendar.GDAY_PATTERN + "$"))) { + return this.parseGDay(text, context, input, scope); } else { - var minusIndex = text.indexOf('-', 7); - if (minusIndex >= 0) { - timeZoneIndex = minusIndex; - } else { - var zIndex = text.indexOf('Z', 7); - if (zIndex >= 0) { - timeZoneIndex = zIndex; - } else { - timeZoneIndex = text.length; - } - } + throw new Error('Value [' + text + '] does not match xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth or xs:gDay patterns.'); } - - var validTimeZoneIndex = timeZoneIndex > 0 && timeZoneIndex < text.length; - var timeString = validTimeZoneIndex ? text.substring(0, timeZoneIndex) : text; - - var time = this.parseTimeString(timeString); - var timeZoneString = validTimeZoneIndex ? text.substring(timeZoneIndex) : ''; - var timezone = this.parseTimeZoneString(timeZoneString); - - return Jsonix.XML.Calendar.fromObject({ - hour : time.hour, - minute : time.minute, - second : time.second, - fractionalSecond : time.fractionalSecond, - timezone : timezone - }); - }, - parseDateString : function(text) { - Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 10) { - throw new Error('Date string [' + text + '] must be 10 characters long.'); - } - - if (text.charAt(4) !== '-' || text.charAt(7) !== '-') { - throw new Error('Date string [' + text + '] must be a string in format [yyyy \'-\' mm \'-\' ss ].'); + parseGYearMonth : function(value, context, input, scope) { + var gYearMonthExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_MONTH_PATTERN + "$"); + var results = value.match(gYearMonthExpression); + if (results !== null) { + var data = { + year : parseInt(results[1], 10), + month : parseInt(results[5], 10), + timezone : this.parseTimezoneString(results[7]) + }; + return new Jsonix.XML.Calendar(data); } - - var year = this.parseYear(text.substring(0, 4)); - var month = this.parseMonth(text.substring(5, 7)); - var day = this.parseDay(text.substring(8, 10)); - - return { - year : year, - month : month, - day : day - }; - }, - parseTimeString : function(timeString) { - Jsonix.Util.Ensure.ensureString(timeString); - if (timeString.length < 8 || timeString.charAt(2) !== ':' || timeString.charAt(5) !== ':') { - throw new Error('Time string [' + timeString + '] must be a string in format [hh \':\' mm \':\' ss (\'.\' s+)?].'); - } - var hourString = timeString.substring(0, 2); - var minuteString = timeString.substring(3, 5); - var secondString = timeString.substring(6, 8); - var fractionalSecondString = timeString.length >= 9 ? timeString.substring(8) : ''; - var hour = this.parseHour(hourString); - var minute = this.parseHour(minuteString); - var second = this.parseSecond(secondString); - var fractionalSecond = this.parseFractionalSecond(fractionalSecondString); - return { - hour : hour, - minute : minute, - second : second, - fractionalSecond : fractionalSecond - }; - + throw new Error('Value [' + value + '] does not match the xs:gYearMonth pattern.'); }, - parseTimeZoneString : function(text) { - // (('+' | '-') hh ':' mm) | 'Z' - Jsonix.Util.Ensure.ensureString(text); - if (text === '') { - return NaN; - } else if (text === 'Z') { - return 0; - } else { - if (text.length !== 6) { - throw new Error('Time zone must be an empty string, \'Z\' or a string in format [(\'+\' | \'-\') hh \':\' mm].'); - } - var signString = text.charAt(0); - var sign; - if (signString === '+') { - sign = 1; - } else if (signString === '-') { - sign = -1; - } else { - throw new Error('First character of the time zone [' + text + '] must be \'+\' or \'-\'.'); - } - var hour = this.parseHour(text.substring(1, 3)); - var minute = this.parseMinute(text.substring(4, 6)); - return -1 * sign * (hour * 60 + minute); + parseGYear : function(value, context, input, scope) { + var gYearExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN + "$"); + var results = value.match(gYearExpression); + if (results !== null) { + var data = { + year : parseInt(results[1], 10), + timezone : this.parseTimezoneString(results[5]) + }; + return new Jsonix.XML.Calendar(data); } - + throw new Error('Value [' + value + '] does not match the xs:gYear pattern.'); }, - parseYear : function(text) { - Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 4) { - throw new Error('Year [' + text + '] must be a four-digit number.'); + parseGMonthDay : function(value, context, input, scope) { + var gMonthDayExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GMONTH_DAY_PATTERN + "$"); + var results = value.match(gMonthDayExpression); + if (results !== null) { + var data = { + month : parseInt(results[2], 10), + day : parseInt(results[3], 10), + timezone : this.parseTimezoneString(results[5]) + }; + return new Jsonix.XML.Calendar(data); } - var year = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureInteger(year); - return year; + throw new Error('Value [' + value + '] does not match the xs:gMonthDay pattern.'); }, - parseMonth : function(text) { - Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 2) { - throw new Error('Month [' + text + '] must be a two-digit number.'); + parseGMonth : function(value, context, input, scope) { + var gMonthExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GMONTH_PATTERN + "$"); + var results = value.match(gMonthExpression); + if (results !== null) { + var data = { + month : parseInt(results[2], 10), + timezone : this.parseTimezoneString(results[3]) + }; + return new Jsonix.XML.Calendar(data); } - var month = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureInteger(month); - return month; + throw new Error('Value [' + value + '] does not match the xs:gMonth pattern.'); }, - parseDay : function(text) { - Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 2) { - throw new Error('Day [' + text + '] must be a two-digit number.'); + parseGDay : function(value, context, input, scope) { + var gDayExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GDAY_PATTERN + "$"); + var results = value.match(gDayExpression); + if (results !== null) { + var data = { + day : parseInt(results[2], 10), + timezone : this.parseTimezoneString(results[3]) + }; + return new Jsonix.XML.Calendar(data); } - var day = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureInteger(day); - return day; + throw new Error('Value [' + value + '] does not match the xs:gDay pattern.'); }, - parseHour : function(text) { + parseDateTime : function(text, context, input, scope) { Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 2) { - throw new Error('Hour [' + text + '] must be a two-digit number.'); + var expression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN + "$"); + var results = text.match(expression); + if (results !== null) { + var data = { + year : parseInt(results[1], 10), + month : parseInt(results[5], 10), + day : parseInt(results[7], 10), + hour : parseInt(results[9], 10), + minute : parseInt(results[10], 10), + second : parseInt(results[11], 10), + fractionalSecond : (results[12] ? parseFloat(results[12]) : 0), + timezone : this.parseTimezoneString(results[14]) + }; + return new Jsonix.XML.Calendar(data); } - var hour = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureInteger(hour); - return hour; + throw new Error('Value [' + value + '] does not match the xs:date pattern.'); }, - parseMinute : function(text) { + parseDate : function(text, context, input, scope) { Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 2) { - throw new Error('Minute [' + text + '] must be a two-digit number.'); + var expression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.DATE_PATTERN + "$"); + var results = text.match(expression); + if (results !== null) { + var data = { + year : parseInt(results[1], 10), + month : parseInt(results[5], 10), + day : parseInt(results[7], 10), + timezone : this.parseTimezoneString(results[9]) + }; + return new Jsonix.XML.Calendar(data); } - var minute = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureInteger(minute); - return minute; + throw new Error('Value [' + value + '] does not match the xs:date pattern.'); }, - parseSecond : function(text) { + parseTime : function(text, context, input, scope) { Jsonix.Util.Ensure.ensureString(text); - if (text.length !== 2) { - throw new Error('Second [' + text + '] must be a two-digit number.'); + var expression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.TIME_PATTERN + "$"); + var results = text.match(expression); + if (results !== null) { + var data = { + hour : parseInt(results[1], 10), + minute : parseInt(results[2], 10), + second : parseInt(results[3], 10), + fractionalSecond : (results[4] ? parseFloat(results[4]) : 0), + timezone : this.parseTimezoneString(results[6]) + }; + return new Jsonix.XML.Calendar(data); } - var second = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureNumber(second); - return second; + throw new Error('Value [' + value + '] does not match the xs:time pattern.'); }, - parseFractionalSecond : function(text) { - Jsonix.Util.Ensure.ensureString(text); - if (text === '') { + parseTimezoneString : function(text) { + // (('+' | '-') hh ':' mm) | 'Z' + if (!Jsonix.Util.Type.isString(text)) { + return NaN; + } else if (text === '') { + return NaN; + } else if (text === 'Z') { return 0; + } else if (text === '+14:00') { + return 14 * 60; + } else if (text === '-14:00') { + return -14 * 60; } else { - var fractionalSecond = Number(text); - // TODO message - Jsonix.Util.Ensure.ensureNumber(fractionalSecond); - return fractionalSecond; + var expression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + "$"); + var results = text.match(expression); + if (results !== null) { + var sign = results[1] === '+' ? 1 : -1; + var hour = parseInt(results[4], 10); + var minute = parseInt(results[5], 10); + return sign * (hour * 60 + minute); + } + throw new Error('Value [' + value + '] does not match the timezone pattern.'); } }, print : function(value, context, output, scope) { Jsonix.Util.Ensure.ensureObject(value); - if (Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day) && Jsonix.Util.NumberUtils.isInteger(value.hour) && Jsonix.Util.NumberUtils.isInteger(value.minute) && Jsonix.Util.NumberUtils.isInteger(value.second)) { + if (Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day) && Jsonix.Util.NumberUtils.isInteger(value.hour) && Jsonix.Util.NumberUtils.isInteger(value.minute) && Jsonix.Util.NumberUtils.isInteger(value.second)) { return this.printDateTime(value); } else if (Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day)) { return this.printDate(value); } else if (Jsonix.Util.NumberUtils.isInteger(value.hour) && Jsonix.Util.NumberUtils.isInteger(value.minute) && Jsonix.Util.NumberUtils.isInteger(value.second)) { return this.printTime(value); + } else if (Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month)) { + return this.printGYearMonth(value); + } else if (Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day)) { + return this.printGMonthDay(value); + } else if (Jsonix.Util.NumberUtils.isInteger(value.year)) { + return this.printGYear(value); + } else if (Jsonix.Util.NumberUtils.isInteger(value.month)) { + return this.printGMonth(value); + } else if (Jsonix.Util.NumberUtils.isInteger(value.day)) { + return this.printGDay(value); } else { throw new Error('Value [' + value + '] is not recognized as dateTime, date or time.'); } @@ -4953,7 +4908,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { result = result + 'T'; result = result + this.printTimeString(value); if (Jsonix.Util.Type.exists(value.timezone)) { - result = result + this.printTimeZoneString(value.timezone); + result = result + this.printTimezoneString(value.timezone); } return result; }, @@ -4967,7 +4922,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { } var result = this.printDateString(value); if (Jsonix.Util.Type.exists(value.timezone)) { - result = result + this.printTimeZoneString(value.timezone); + result = result + this.printTimezoneString(value.timezone); } return result; }, @@ -4985,7 +4940,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { var result = this.printTimeString(value); if (Jsonix.Util.Type.exists(value.timezone)) { - result = result + this.printTimeZoneString(value.timezone); + result = result + this.printTimezoneString(value.timezone); } return result; }, @@ -5014,7 +4969,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { } return result; }, - printTimeZoneString : function(value) { + printTimezoneString : function(value) { if (!Jsonix.Util.Type.exists(value) || Jsonix.Util.Type.isNaN(value)) { return ''; } else { @@ -5030,9 +4985,9 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { return 'Z'; } else { if (sign > 0) { - result = '-'; - } else if (sign < 0) { result = '+'; + } else if (sign < 0) { + result = '-'; } result = result + this.printHour(hour); result = result + ':'; @@ -5041,6 +4996,97 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { } } }, + printGDay : function(value, context, output, scope) { + Jsonix.Util.Ensure.ensureObject(value); + var day = undefined; + var timezone = undefined; + + if (value instanceof Date) { + day = value.getDate(); + } else { + Jsonix.Util.Ensure.ensureInteger(value.day); + day = value.day; + timezone = value.timezone; + } + Jsonix.XML.Calendar.validateDay(day); + Jsonix.XML.Calendar.validateTimezone(timezone); + return "---" + this.printDay(day) + this.printTimezoneString(timezone); + }, + printGMonth : function(value, context, output, scope) { + Jsonix.Util.Ensure.ensureObject(value); + var month = undefined; + var timezone = undefined; + + if (value instanceof Date) { + month = value.getMonth() + 1; + } else { + Jsonix.Util.Ensure.ensureInteger(value.month); + month = value.month; + timezone = value.timezone; + } + Jsonix.XML.Calendar.validateMonth(month); + Jsonix.XML.Calendar.validateTimezone(timezone); + return "--" + this.printMonth(month) + this.printTimezoneString(timezone); + }, + printGMonthDay : function(value, context, output, scope) { + Jsonix.Util.Ensure.ensureObject(value); + var month = undefined; + var day = undefined; + var timezone = undefined; + + if (value instanceof Date) { + month = value.getMonth() + 1; + day = value.getDate(); + } else { + Jsonix.Util.Ensure.ensureInteger(value.month); + Jsonix.Util.Ensure.ensureInteger(value.day); + month = value.month; + day = value.day; + timezone = value.timezone; + } + Jsonix.XML.Calendar.validateMonthDay(month, day); + Jsonix.XML.Calendar.validateTimezone(timezone); + return "--" + this.printMonth(month) + "-" + this.printDay(day) + this.printTimezoneString(timezone); + }, + printGYear : function(value, context, output, scope) { + Jsonix.Util.Ensure.ensureObject(value); + var year = undefined; + var timezone = undefined; + + if (value instanceof Date) { + year = value.getFullYear(); + } else { + Jsonix.Util.Ensure.ensureInteger(value.year); + year = value.year; + timezone = value.timezone; + } + Jsonix.XML.Calendar.validateYear(year); + Jsonix.XML.Calendar.validateTimezone(timezone); + return this.printSignedYear(year) + this.printTimezoneString(timezone); + }, + printGYearMonth : function(value, context, output, scope) { + Jsonix.Util.Ensure.ensureObject(value); + var year = undefined; + var month = undefined; + var timezone = undefined; + + if (value instanceof Date) { + year = value.getFullYear(); + month = value.getMonth() + 1; + } else { + Jsonix.Util.Ensure.ensureInteger(value.year); + year = value.year; + month = value.month; + timezone = value.timezone; + } + Jsonix.XML.Calendar.validateYear(year); + Jsonix.XML.Calendar.validateMonth(month); + Jsonix.XML.Calendar.validateTimezone(timezone); + return this.printSignedYear(year) + "-" + this.printMonth(month) + this.printTimezoneString(timezone); + }, + printSignedYear : function(value) { + return value < 0 ? ("-" + this.printYear(value * -1)) : (this.printYear(value)); + }, printYear : function(value) { return this.printInteger(value, 4); }, @@ -5084,9 +5130,6 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { if (value < 0) { throw new Error('Value [' + value + '] must not be negative.'); } - if (value >= Math.pow(10, length)) { - throw new Error('Value [' + value + '] must be less than [' + Math.pow(10, length) + '].'); - } var result = String(value); for (var i = result.length; i < length; i++) { result = '0' + result; @@ -5094,25 +5137,137 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { return result; }, isInstance : function(value, context, scope) { - return Jsonix.Util.Type.isObject(value) && ((Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day)) || (Jsonix.Util.NumberUtils.isInteger(value.hour) && Jsonix.Util.NumberUtils.isInteger(value.minute) && Jsonix.Util.NumberUtils.isInteger(value.second))); + return Jsonix.Util.Type.isObject(value) && ((Jsonix.Util.NumberUtils.isInteger(value.year) && Jsonix.Util.NumberUtils.isInteger(value.month) && Jsonix.Util.NumberUtils.isInteger(value.day)) || (Jsonix.Util.NumberUtils.isInteger(value.hour) && Jsonix.Util.NumberUtils.isInteger(value.minute) && Jsonix.Util.NumberUtils.isInteger(value.second))); }, CLASS_NAME : 'Jsonix.Schema.XSD.Calendar' }); Jsonix.Schema.XSD.Calendar.YEAR_PATTERN = "-?([1-9][0-9]*)?((?!(0000))[0-9]{4})"; -Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN = "Z|[\\-\\+][0-9][0-9]:[0-5][0-9]"; +Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN = "Z|([\\-\\+])(((0[0-9]|1[0-3]):([0-5][0-9]))|(14:00))"; +Jsonix.Schema.XSD.Calendar.MONTH_PATTERN = "(0[1-9]|1[0-2])"; +Jsonix.Schema.XSD.Calendar.SINGLE_MONTH_PATTERN = "\\-\\-" + Jsonix.Schema.XSD.Calendar.MONTH_PATTERN; +Jsonix.Schema.XSD.Calendar.DAY_PATTERN = "(0[1-9]|[12][0-9]|3[01])"; +Jsonix.Schema.XSD.Calendar.SINGLE_DAY_PATTERN = "\\-\\-\\-" + Jsonix.Schema.XSD.Calendar.DAY_PATTERN; Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.YEAR_PATTERN + ")" + "(" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ")?"; - +Jsonix.Schema.XSD.Calendar.GMONTH_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.SINGLE_MONTH_PATTERN + ")" + "(" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ")?"; +Jsonix.Schema.XSD.Calendar.GDAY_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.SINGLE_DAY_PATTERN + ")" + "(" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ")?"; +Jsonix.Schema.XSD.Calendar.GYEAR_MONTH_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.YEAR_PATTERN + ")" + "-" + "(" + Jsonix.Schema.XSD.Calendar.DAY_PATTERN + ")" + "(" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ")?"; +Jsonix.Schema.XSD.Calendar.GMONTH_DAY_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.SINGLE_MONTH_PATTERN + ")" + "-" + "(" + Jsonix.Schema.XSD.Calendar.DAY_PATTERN + ")" + "(" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ")?"; +Jsonix.Schema.XSD.Calendar.DATE_PART_PATTERN = "(" + Jsonix.Schema.XSD.Calendar.YEAR_PATTERN + ")" + "-" + "(" + Jsonix.Schema.XSD.Calendar.MONTH_PATTERN + ")" + "-" + "(" + Jsonix.Schema.XSD.Calendar.DAY_PATTERN + ")"; +Jsonix.Schema.XSD.Calendar.TIME_PART_PATTERN = "([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\\.([0-9]+))?"; +Jsonix.Schema.XSD.Calendar.TIME_PATTERN = Jsonix.Schema.XSD.Calendar.TIME_PART_PATTERN + '(' + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ')?'; +Jsonix.Schema.XSD.Calendar.DATE_PATTERN = Jsonix.Schema.XSD.Calendar.DATE_PART_PATTERN + '(' + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ')?'; +Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN = Jsonix.Schema.XSD.Calendar.DATE_PART_PATTERN + 'T' + Jsonix.Schema.XSD.Calendar.TIME_PART_PATTERN + '(' + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + ')?'; Jsonix.Schema.XSD.Calendar.INSTANCE = new Jsonix.Schema.XSD.Calendar(); Jsonix.Schema.XSD.Calendar.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Calendar.INSTANCE); Jsonix.Schema.XSD.Duration = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { name : 'Duration', typeName : Jsonix.Schema.XSD.qname('duration'), + isInstance : function(value, context, scope) { + return Jsonix.Util.Type.isObject(value) && ( + (Jsonix.Util.Type.exists(value.sign) ? (value.sign === -1 || value.sign === 1) : true) + (Jsonix.Util.NumberUtils.isInteger(value.years) && value.years >=0) || + (Jsonix.Util.NumberUtils.isInteger(value.months) && value.months >=0) || + (Jsonix.Util.NumberUtils.isInteger(value.days) && value.days >= 0) || + (Jsonix.Util.NumberUtils.isInteger(value.hours) && value.hours >= 0) || + (Jsonix.Util.NumberUtils.isInteger(value.minutes) && value.minutes >= 0) || + (Jsonix.Util.Type.isNumber(value.seconds) && value.seconds >= 0) ); + }, + validate : function(value) { + Jsonix.Util.Ensure.ensureObject(value); + if (Jsonix.Util.Type.exists(value.sign)) { + if (!(value.sign === 1 || value.sign === -1)) { + throw new Error("Sign of the duration [" + value.sign + "] must be either [1] or [-1]."); + } + } + var empty = true; + var ifExistsEnsureUnsignedInteger = function(v, message) { + if (Jsonix.Util.Type.exists(v)) { + if (!(Jsonix.Util.NumberUtils.isInteger(v) && v >= 0)) { + throw new Error(message.replace("{0}", v)); + } else { + return true; + } + } else { + return false; + } + }; + var ifExistsEnsureUnsignedNumber = function(v, message) { + if (Jsonix.Util.Type.exists(v)) { + if (!(Jsonix.Util.Type.isNumber(v) && v >= 0)) { + throw new Error(message.replace("{0}", v)); + } else { + return true; + } + } else { + return false; + } + }; + empty = empty && !ifExistsEnsureUnsignedInteger(value.years, "Number of years [{0}] must be an unsigned integer."); + empty = empty && !ifExistsEnsureUnsignedInteger(value.months, "Number of months [{0}] must be an unsigned integer."); + empty = empty && !ifExistsEnsureUnsignedInteger(value.days, "Number of days [{0}] must be an unsigned integer."); + empty = empty && !ifExistsEnsureUnsignedInteger(value.hours, "Number of hours [{0}] must be an unsigned integer."); + empty = empty && !ifExistsEnsureUnsignedInteger(value.minutes, "Number of minutes [{0}] must be an unsigned integer."); + empty = empty && !ifExistsEnsureUnsignedNumber(value.seconds, "Number of seconds [{0}] must be an unsigned number."); + if (empty) { + throw new Error("At least one of the components (years, months, days, hours, minutes, seconds) must be set."); + } + }, + print : function(value, context, output, scope) { + this.validate(value); + var result = ''; + if (value.sign === -1) + { + result += '-'; + } + result += 'P'; + if (value.years) { + result += (value.years + 'Y'); + } + if (value.months) { + result += (value.months + 'M'); + } + if (value.days) { + result += (value.days + 'D'); + } + if (value.hours || value.minutes || value.seconds) + { + result += 'T'; + if (value.hours) { + result += (value.hours + 'H'); + } + if (value.minutes) { + result += (value.minutes + 'M'); + } + if (value.seconds) { + result += (value.seconds + 'S'); + } + } + return result; + }, + parse : function(value, context, input, scope) { + var durationExpression = new RegExp("^" + Jsonix.Schema.XSD.Duration.PATTERN + "$"); + var results = value.match(durationExpression); + if (results !== null) { + var empty = true; + var duration = {}; + if (results[1]) { duration.sign = -1; } + if (results[3]) { duration.years = parseInt(results[3], 10); empty = false; } + if (results[5]) { duration.months = parseInt(results[5], 10); empty = false; } + if (results[7]) { duration.days = parseInt(results[7], 10); empty = false; } + if (results[10]) { duration.hours = parseInt(results[10], 10); empty = false; } + if (results[12]) { duration.minutes = parseInt(results[12], 10); empty = false; } + if (results[14]) { duration.seconds = Number(results[14]); empty = false; } + return duration; + } else { + throw new Error('Value [' + value + '] does not match the duration pattern.'); + } + }, CLASS_NAME : 'Jsonix.Schema.XSD.Duration' }); +Jsonix.Schema.XSD.Duration.PATTERN = '(-)?P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?(T(([0-9]+)H)?(([0-9]+)M)?(([0-9]+(\\.[0-9]+)?)S)?)?'; Jsonix.Schema.XSD.Duration.INSTANCE = new Jsonix.Schema.XSD.Duration(); -Jsonix.Schema.XSD.Duration.INSTANCE.LIST = new Jsonix.Schema.XSD.List( - Jsonix.Schema.XSD.Duration.INSTANCE); +Jsonix.Schema.XSD.Duration.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Duration.INSTANCE); Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'DateTime', typeName : Jsonix.Schema.XSD.qname('dateTime'), @@ -5128,22 +5283,22 @@ Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { if (Jsonix.Util.Type.isNumber(calendar.fractionalSecond)) { date.setMilliseconds(Math.floor(1000 * calendar.fractionalSecond)); } - var timezoneOffset; + var timezone; var unknownTimezone; - var localTimezoneOffset = date.getTimezoneOffset(); + var localTimezone = - date.getTimezoneOffset(); if (Jsonix.Util.NumberUtils.isInteger(calendar.timezone)) { - timezoneOffset = calendar.timezone; + timezone = calendar.timezone; unknownTimezone = false; } else { // Unknown timezone - timezoneOffset = localTimezoneOffset; + timezone = localTimezone; unknownTimezone = true; } // - var result = new Date(date.getTime() + (60000 * (timezoneOffset - localTimezoneOffset))); + var result = new Date(date.getTime() + (60000 * (- timezone + localTimezone))); if (unknownTimezone) { // null denotes "unknown timezone" @@ -5151,14 +5306,14 @@ Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { } else { - result.originalTimezone = timezoneOffset; + result.originalTimezone = calendar.timezone; } return result; }, print : function(value, context, output, scope) { Jsonix.Util.Ensure.ensureDate(value); - var timezoneOffset; - var localTimezoneOffset = value.getTimezoneOffset(); + var timezone; + var localTimezone = - value.getTimezoneOffset(); var correctedValue; // If original time zone was unknown, print the given value without // the timezone @@ -5179,16 +5334,16 @@ Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { // If original timezone was known, correct and print the value with the timezone if (Jsonix.Util.NumberUtils.isInteger(value.originalTimezone)) { - timezoneOffset = value.originalTimezone; - correctedValue = new Date(value.getTime() - (60000 * (timezoneOffset - localTimezoneOffset))); + timezone = value.originalTimezone; + correctedValue = new Date(value.getTime() - (60000 * ( - timezone + localTimezone))); } // If original timezone was not specified, do not correct and use the local time zone else { - timezoneOffset = localTimezoneOffset; + timezone = localTimezone; correctedValue = value; } - return this.printDateTime(new Jsonix.XML.Calendar({ + var x = this.printDateTime(new Jsonix.XML.Calendar({ year : correctedValue.getFullYear(), month : correctedValue.getMonth() + 1, day : correctedValue.getDate(), @@ -5196,8 +5351,9 @@ Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { minute : correctedValue.getMinutes(), second : correctedValue.getSeconds(), fractionalSecond : (correctedValue.getMilliseconds() / 1000), - timezone: timezoneOffset + timezone: timezone })); + return x; } }, isInstance : function(value, context, scope) { @@ -5223,22 +5379,22 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { if (Jsonix.Util.Type.isNumber(calendar.fractionalSecond)) { date.setMilliseconds(Math.floor(1000 * calendar.fractionalSecond)); } - var timezoneOffset; + var timezone; var unknownTimezone; - var localTimezoneOffset = date.getTimezoneOffset(); + var localTimezone = - date.getTimezoneOffset(); if (Jsonix.Util.NumberUtils.isInteger(calendar.timezone)) { - timezoneOffset = calendar.timezone; + timezone = calendar.timezone; unknownTimezone = false; } else { // Unknown timezone - timezoneOffset = localTimezoneOffset; + timezone = localTimezone; unknownTimezone = true; } // - var result = new Date(date.getTime() + (60000 * (timezoneOffset - localTimezoneOffset))); + var result = new Date(date.getTime() + (60000 * ( - timezone + localTimezone))); if (unknownTimezone) { // null denotes "unknown timezone" @@ -5246,7 +5402,7 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { } else { - result.originalTimezone = timezoneOffset; + result.originalTimezone = timezone; } return result; }, @@ -5269,16 +5425,16 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { else { var correctedValue; - var timezoneOffset; - var localTimezoneOffset = value.getTimezoneOffset(); + var timezone; + var localTimezone = - value.getTimezoneOffset(); if (Jsonix.Util.NumberUtils.isInteger(value.originalTimezone)) { - timezoneOffset = value.originalTimezone; - correctedValue = new Date(value.getTime() - (60000 * (timezoneOffset - localTimezoneOffset))); + timezone = value.originalTimezone; + correctedValue = new Date(value.getTime() - (60000 * ( - timezone + localTimezone))); } else { - timezoneOffset = localTimezoneOffset; + timezone = localTimezone; correctedValue = value; } var correctedTime = correctedValue.getTime(); @@ -5288,16 +5444,16 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { minute : correctedValue.getMinutes(), second : correctedValue.getSeconds(), fractionalSecond : (correctedValue.getMilliseconds() / 1000), - timezone: timezoneOffset + timezone: timezone })); } else { - var timezoneOffsetHours = Math.ceil(-correctedTime / 3600000); + var timezoneHours = Math.ceil(-correctedTime / 3600000); return this.printTime(new Jsonix.XML.Calendar({ - hour : (correctedValue.getHours() + timezoneOffsetHours + timezoneOffset / 60 ) % 24, + hour : (correctedValue.getHours() + timezoneHours - timezone / 60 ) % 24, minute : correctedValue.getMinutes(), second : correctedValue.getSeconds(), fractionalSecond : (correctedValue.getMilliseconds() / 1000), - timezone : - timezoneOffsetHours * 60 + timezone : timezoneHours * 60 })); } } @@ -5325,22 +5481,22 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { if (Jsonix.Util.Type.isNumber(calendar.fractionalSecond)) { date.setMilliseconds(Math.floor(1000 * calendar.fractionalSecond)); } - var timezoneOffset; + var timezone; var unknownTimezone; - var localTimezoneOffset = date.getTimezoneOffset(); + var localTimezone = - date.getTimezoneOffset(); if (Jsonix.Util.NumberUtils.isInteger(calendar.timezone)) { - timezoneOffset = calendar.timezone; + timezone = calendar.timezone; unknownTimezone = false; } else { // Unknown timezone - timezoneOffset = localTimezoneOffset; + timezone = localTimezone; unknownTimezone = true; } // - var result = new Date(date.getTime() + (60000 * (timezoneOffset - localTimezoneOffset))); + var result = new Date(date.getTime() + (60000 * ( - timezone + localTimezone))); if (unknownTimezone) { // null denotes "unknown timezone" @@ -5348,7 +5504,7 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { } else { - result.originalTimezone = timezoneOffset; + result.originalTimezone = timezone; } return result; }, @@ -5374,7 +5530,7 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { // If original timezone was known, correct and print the value with the timezone if (Jsonix.Util.NumberUtils.isInteger(value.originalTimezone)) { - var correctedValue = new Date(value.getTime() - (60000 * (value.originalTimezone - value.getTimezoneOffset()))); + var correctedValue = new Date(value.getTime() - (60000 * (- value.originalTimezone - value.getTimezoneOffset()))); return this.printDate(new Jsonix.XML.Calendar({ year : correctedValue.getFullYear(), month : correctedValue.getMonth() + 1, @@ -5388,21 +5544,21 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { // We assume that the difference between the date value and local midnight // should be interpreted as a timezone offset. // In case there's no difference, we assume default/unknown timezone - var localTimezoneOffset = value.getTime() - localDate.getTime(); - if (localTimezoneOffset === 0) { + var localTimezone = - value.getTime() + localDate.getTime(); + if (localTimezone === 0) { return this.printDate(new Jsonix.XML.Calendar({ year : value.getFullYear(), month : value.getMonth() + 1, day : value.getDate() })); } else { - var timezoneOffset = localTimezoneOffset + (60000 * value.getTimezoneOffset()); - if (timezoneOffset <= 43200000) { + var timezone = localTimezone - (60000 * value.getTimezoneOffset()); + if (timezone >= -43200000) { return this.printDate(new Jsonix.XML.Calendar({ year : value.getFullYear(), month : value.getMonth() + 1, day : value.getDate(), - timezone : Math.floor(timezoneOffset / 60000) + timezone : Math.floor(timezone / 60000) })); } else { var nextDay = new Date(value.getTime() + 86400000); @@ -5410,7 +5566,7 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { year : nextDay.getFullYear(), month : nextDay.getMonth() + 1, day : nextDay.getDate(), - timezone : (Math.floor(timezoneOffset / 60000) - 1440) + timezone : (Math.floor(timezone / 60000) + 1440) })); } } @@ -5424,126 +5580,81 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { }); Jsonix.Schema.XSD.Date.INSTANCE = new Jsonix.Schema.XSD.Date(); Jsonix.Schema.XSD.Date.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Date.INSTANCE); -Jsonix.Schema.XSD.GYearMonth = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { +Jsonix.Schema.XSD.GYearMonth = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'GYearMonth', typeName : Jsonix.Schema.XSD.qname('gYearMonth'), - CLASS_NAME : 'Jsonix.Schema.XSD.GYearMonth' + CLASS_NAME : 'Jsonix.Schema.XSD.GYearMonth', + + parse : function(value, context, input, scope) { + return this.parseGYearMonth(value, context, input, scope); + }, + + print : function(value, context, output, scope) { + return this.printGYearMonth(value, context, output, scope); + } + }); Jsonix.Schema.XSD.GYearMonth.INSTANCE = new Jsonix.Schema.XSD.GYearMonth(); -Jsonix.Schema.XSD.GYearMonth.INSTANCE.LIST = new Jsonix.Schema.XSD.List( - Jsonix.Schema.XSD.GYearMonth.INSTANCE); -// REVIEW AV: GYear extends Calendar +Jsonix.Schema.XSD.GYearMonth.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GYearMonth.INSTANCE); Jsonix.Schema.XSD.GYear = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'GYear', typeName : Jsonix.Schema.XSD.qname('gYear'), - // TODO: find appropriate place for the regex (e.g. - // Jsonix.XML.Calendar.regex ?) - // REVIEW AV: I've first moved as constants to the Calendar + CLASS_NAME : 'Jsonix.Schema.XSD.GYear', parse : function(value, context, input, scope) { - var returnValue = this.splitGYear(value); - returnValue.toString = function() { - return "EmptyXMLElement. Call embedded 'year' or 'timezone' property"; - }; - - return returnValue; - }, - - /** - * @param {string} - * year datetype in ISO 8601 format - * @returns {object} pair of date, timestamp properties as a number - * @throws {Error} - * if the datetype is not valid - * - */ - splitGYear : function(value) { - - var gYearExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN + "$"); - var results = value.match(gYearExpression); - - // TODO: underscored functions and properties are for testing proposes - // only. Must be vanished in the min.js - - if (results !== null) { - var splitedGYear = { - // REVIEW AV: Decimal radix - year : parseInt(results[1], 10), - _timezone : results[5], - timezone : this.parseTimeZoneString(results[5]) - // TODO: parseTimeZoneString() function exists also in CALENDAR - // but inverts the sign, why? - }; - - return splitedGYear; - } - - throw new Error('Value [' + value + '] doesn\'t match the gYear pattern.'); - }, - - parseTimeZoneString : function(text) { - if (text === "Z" || !Jsonix.Util.Type.exists(text)) { - return 0; - } - - var splittedTimeZoneChunks = text.split(":"); - return - (parseInt(splittedTimeZoneChunks[0], 10) * 60 + parseInt(splittedTimeZoneChunks[1], 10)); - }, - - // TODO: underscored functions and properties are for testing proposes only. - // Must be vanished in the min.js - - _validateGYear : function(value) { - var gYearExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN + "$"); - - if (!gYearExpression.test(value)) { - throw new Error('Value [' + value + '] doesn\'t match the gYear pattern.'); - } - }, - - _validateYear : function(value) { - var yearExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.YEAR_PATTERN + "$"); - - if (!yearExpression.test(value)) { - throw new Error('Value [' + value + '] doesn\'t match the year pattern.'); - } + return this.parseGYear(value, context, input, scope); }, - _validateTimeZone : function(value) { - var timeZoneExpression = new RegExp("^" + Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN + "$"); - - if (!timeZoneExpression.test(value)) { - throw new Error('Value [' + value + '] doesn\'t match the time zone pattern.'); - } - }, - CLASS_NAME : 'Jsonix.Schema.XSD.GYear' + print : function(value, context, output, scope) { + return this.printGYear(value, context, output, scope); + } }); Jsonix.Schema.XSD.GYear.INSTANCE = new Jsonix.Schema.XSD.GYear(); Jsonix.Schema.XSD.GYear.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GYear.INSTANCE); -Jsonix.Schema.XSD.GMonthDay = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { +Jsonix.Schema.XSD.GMonthDay = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'GMonthDay', typeName : Jsonix.Schema.XSD.qname('gMonthDay'), - CLASS_NAME : 'Jsonix.Schema.XSD.GMonthDay' + CLASS_NAME : 'Jsonix.Schema.XSD.GMonthDay', + + parse : function(value, context, input, scope) { + return this.parseGMonthDay(value, context, input, scope); + }, + + print : function(value, context, output, scope) { + return this.printGMonthDay(value, context, output, scope); + } }); Jsonix.Schema.XSD.GMonthDay.INSTANCE = new Jsonix.Schema.XSD.GMonthDay(); -Jsonix.Schema.XSD.GMonthDay.INSTANCE.LIST = new Jsonix.Schema.XSD.List( - Jsonix.Schema.XSD.GMonthDay.INSTANCE); -Jsonix.Schema.XSD.GDay = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { +Jsonix.Schema.XSD.GMonthDay.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GMonthDay.INSTANCE); +Jsonix.Schema.XSD.GDay = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'GDay', typeName : Jsonix.Schema.XSD.qname('gDay'), - CLASS_NAME : 'Jsonix.Schema.XSD.GDay' + CLASS_NAME : 'Jsonix.Schema.XSD.GDay', + + parse : function(value, context, input, scope) { + return this.parseGDay(value, context, input, scope); + }, + + print : function(value, context, output, scope) { + return this.printGDay(value, context, output, scope); + } + }); Jsonix.Schema.XSD.GDay.INSTANCE = new Jsonix.Schema.XSD.GDay(); -Jsonix.Schema.XSD.GDay.INSTANCE.LIST = new Jsonix.Schema.XSD.List( - Jsonix.Schema.XSD.GDay.INSTANCE); -Jsonix.Schema.XSD.GMonth = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, { +Jsonix.Schema.XSD.GDay.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GDay.INSTANCE); +Jsonix.Schema.XSD.GMonth = Jsonix.Class(Jsonix.Schema.XSD.Calendar, { name : 'GMonth', typeName : Jsonix.Schema.XSD.qname('gMonth'), - CLASS_NAME : 'Jsonix.Schema.XSD.GMonth' + CLASS_NAME : 'Jsonix.Schema.XSD.GMonth', + parse : function(value, context, input, scope) { + return this.parseGMonth(value, context, input, scope); + }, + print : function(value, context, output, scope) { + return this.printGMonth(value, context, output, scope); + } }); Jsonix.Schema.XSD.GMonth.INSTANCE = new Jsonix.Schema.XSD.GMonth(); -Jsonix.Schema.XSD.GMonth.INSTANCE.LIST = new Jsonix.Schema.XSD.List( - Jsonix.Schema.XSD.GMonth.INSTANCE); +Jsonix.Schema.XSD.GMonth.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GMonth.INSTANCE); Jsonix.Schema.XSD.ID = Jsonix.Class(Jsonix.Schema.XSD.String, { name : 'ID', typeName : Jsonix.Schema.XSD.qname('ID'), diff --git a/dist/Jsonix-min.js b/dist/Jsonix-min.js index 75908641..50433bf8 100644 --- a/dist/Jsonix-min.js +++ b/dist/Jsonix-min.js @@ -133,58 +133,66 @@ Jsonix.Util.Type={exists:function(b){return(typeof b!=="undefined"&&b!==null) },isArray:function(b){return !!(b&&b.concat&&b.unshift&&!b.callee) },isDate:function(b){return !!(b&&b.getTimezoneOffset&&b.setUTCFullYear) },isRegExp:function(b){return !!(b&&b.test&&b.exec&&(b.ignoreCase||b.ignoreCase===false)) -},isEqual:function(r,t,w){var a=Jsonix.Util.Type.isFunction(w); -var v=function(g,i,d){var k=slice.call(arguments); -var j=k.length<=1; -var f=j?0:k[0]; -var h=j?k[0]:k[1]; -var l=k[2]||1; -var m=Math.max(Math.ceil((h-f)/l),0); -var e=0; -var c=new Array(m); -while(e0&&d=-9999&&b.year<=9999){this.year=b.year -}else{throw new Error("Invalid year ["+b.year+"].") -}}else{this.year=NaN -}if(Jsonix.Util.Type.exists(b.month)){Jsonix.Util.Ensure.ensureInteger(b.month); -if(b.month>=1&&b.month<=12){this.month=b.month -}else{throw new Error("Invalid month ["+b.month+"].") -}}else{this.month=NaN -}if(Jsonix.Util.Type.exists(b.day)){Jsonix.Util.Ensure.ensureInteger(b.day); -if(b.day>=1&&b.day<=31){this.day=b.day -}else{throw new Error("Invalid day ["+b.day+"].") -}}else{this.day=NaN -}if(Jsonix.Util.Type.exists(b.hour)){Jsonix.Util.Ensure.ensureInteger(b.hour); -if(b.hour>=0&&b.hour<=23){this.hour=b.hour -}else{throw new Error("Invalid hour ["+b.hour+"].") -}}else{this.hour=NaN -}if(Jsonix.Util.Type.exists(b.minute)){Jsonix.Util.Ensure.ensureInteger(b.minute); -if(b.minute>=0&&b.minute<=59){this.minute=b.minute -}else{throw new Error("Invalid minute ["+b.minute+"].") -}}else{this.minute=NaN -}if(Jsonix.Util.Type.exists(b.second)){Jsonix.Util.Ensure.ensureInteger(b.second); -if(b.second>=0&&b.second<=59){this.second=b.second -}else{throw new Error("Invalid second ["+b.second+"].") -}}else{this.second=NaN -}if(Jsonix.Util.Type.exists(b.fractionalSecond)){Jsonix.Util.Ensure.ensureNumber(b.fractionalSecond); -if(b.fractionalSecond>=0&&b.fractionalSecond<1){this.fractionalSecond=b.fractionalSecond -}else{throw new Error("Invalid fractional second ["+b.fractionalSecond+"].") -}}else{this.fractionalSecond=NaN -}if(Jsonix.Util.Type.exists(b.timezone)){if(Jsonix.Util.Type.isNaN(b.timezone)){this.timezone=NaN -}else{Jsonix.Util.Ensure.ensureInteger(b.timezone); -if(b.timezone>=-1440&&b.timezone<1440){this.timezone=b.timezone -}else{throw new Error("Invalid timezone ["+b.timezone+"].") -}}}else{this.timezone=NaN -}},CLASS_NAME:"Jsonix.XML.Calendar"}); +Jsonix.XML.Calendar=Jsonix.Class({year:NaN,month:NaN,day:NaN,hour:NaN,minute:NaN,second:NaN,fractionalSecond:NaN,timezone:NaN,date:null,initialize:function(f){Jsonix.Util.Ensure.ensureObject(f); +if(Jsonix.Util.Type.exists(f.year)){Jsonix.Util.Ensure.ensureInteger(f.year); +Jsonix.XML.Calendar.validateYear(f.year); +this.year=f.year +}else{this.year=NaN +}if(Jsonix.Util.Type.exists(f.month)){Jsonix.Util.Ensure.ensureInteger(f.month); +Jsonix.XML.Calendar.validateMonth(f.month); +this.month=f.month +}else{this.month=NaN +}if(Jsonix.Util.Type.exists(f.day)){Jsonix.Util.Ensure.ensureInteger(f.day); +if(Jsonix.Util.NumberUtils.isInteger(f.year)&&Jsonix.Util.NumberUtils.isInteger(f.month)){Jsonix.XML.Calendar.validateYearMonthDay(f.year,f.month,f.day) +}else{if(Jsonix.Util.NumberUtils.isInteger(f.month)){Jsonix.XML.Calendar.validateMonthDay(f.month,f.day) +}else{Jsonix.XML.Calendar.validateDay(f.day) +}}this.day=f.day +}else{this.day=NaN +}if(Jsonix.Util.Type.exists(f.hour)){Jsonix.Util.Ensure.ensureInteger(f.hour); +Jsonix.XML.Calendar.validateHour(f.hour); +this.hour=f.hour +}else{this.hour=NaN +}if(Jsonix.Util.Type.exists(f.minute)){Jsonix.Util.Ensure.ensureInteger(f.minute); +Jsonix.XML.Calendar.validateMinute(f.minute); +this.minute=f.minute +}else{this.minute=NaN +}if(Jsonix.Util.Type.exists(f.second)){Jsonix.Util.Ensure.ensureInteger(f.second); +Jsonix.XML.Calendar.validateSecond(f.second); +this.second=f.second +}else{this.second=NaN +}if(Jsonix.Util.Type.exists(f.fractionalSecond)){Jsonix.Util.Ensure.ensureNumber(f.fractionalSecond); +Jsonix.XML.Calendar.validateFractionalSecond(f.fractionalSecond); +this.fractionalSecond=f.fractionalSecond +}else{this.fractionalSecond=NaN +}if(Jsonix.Util.Type.exists(f.timezone)){if(Jsonix.Util.Type.isNaN(f.timezone)){this.timezone=NaN +}else{Jsonix.Util.Ensure.ensureInteger(f.timezone); +Jsonix.XML.Calendar.validateTimezone(f.timezone); +this.timezone=f.timezone +}}else{this.timezone=NaN +}var d=new Date(0); +d.setUTCFullYear(this.year||1970); +d.setUTCMonth(this.month-1||0); +d.setUTCDate(this.day||1); +d.setUTCHours(this.hour||0); +d.setUTCMinutes(this.minute||0); +d.setUTCSeconds(this.second||0); +d.setUTCMilliseconds((this.fractionalSecond||0)*1000); +var e=-60000*(this.timezone||0); +this.date=new Date(d.getTime()+e) +},CLASS_NAME:"Jsonix.XML.Calendar"}); +Jsonix.XML.Calendar.MIN_TIMEZONE=-14*60; +Jsonix.XML.Calendar.MAX_TIMEZONE=14*60; +Jsonix.XML.Calendar.DAYS_IN_MONTH=[31,29,31,30,31,30,31,31,30,31,30,31]; Jsonix.XML.Calendar.fromObject=function(b){Jsonix.Util.Ensure.ensureObject(b); if(Jsonix.Util.Type.isString(b.CLASS_NAME)&&b.CLASS_NAME==="Jsonix.XML.Calendar"){return b }return new Jsonix.XML.Calendar(b) }; +Jsonix.XML.Calendar.validateYear=function(b){if(b===0){throw new Error("Invalid year ["+b+"]. Year must not be [0].") +}}; +Jsonix.XML.Calendar.validateMonth=function(b){if(b<1||b>12){throw new Error("Invalid month ["+b+"]. Month must be in range [1, 12].") +}}; +Jsonix.XML.Calendar.validateDay=function(b){if(b<1||b>31){throw new Error("Invalid day ["+b+"]. Day must be in range [1, 31].") +}}; +Jsonix.XML.Calendar.validateMonthDay=function(f,d){Jsonix.XML.Calendar.validateMonth(f); +var e=Jsonix.XML.Calendar.DAYS_IN_MONTH[f-1]; +if(d<1||d>Jsonix.XML.Calendar.DAYS_IN_MONTH[f-1]){throw new Error("Invalid day ["+d+"]. Day must be in range [1, "+e+"].") +}}; +Jsonix.XML.Calendar.validateYearMonthDay=function(d,f,e){Jsonix.XML.Calendar.validateYear(d); +Jsonix.XML.Calendar.validateMonthDay(f,e) +}; +Jsonix.XML.Calendar.validateHour=function(b){if(b<0||b>23){throw new Error("Invalid hour ["+b+"]. Hour must be in range [0, 23].") +}}; +Jsonix.XML.Calendar.validateMinute=function(b){if(b<0||b>59){throw new Error("Invalid minute ["+b+"]. Minute must be in range [0, 59].") +}}; +Jsonix.XML.Calendar.validateSecond=function(b){if(b<0||b>59){throw new Error("Invalid second ["+b+"]. Second must be in range [0, 59].") +}}; +Jsonix.XML.Calendar.validateFractionalSecond=function(b){if(b<0||b>59){throw new Error("Invalid fractional second ["+b+"]. Fractional second must be in range [0, 1).") +}}; +Jsonix.XML.Calendar.validateTimezone=function(b){if(bJsonix.XML.Calendar.MAX_TIMEZONE){throw new Error("Invalid timezone ["+b+"]. Timezone must not be in range ["+Jsonix.XML.Calendar.MIN_TIMEZONE+", "+Jsonix.XML.Calendar.MAX_TIMEZONE+"].") +}}; Jsonix.XML.Input=Jsonix.Class({root:null,node:null,attributes:null,eventType:null,pns:null,initialize:function(c){Jsonix.Util.Ensure.ensureExists(c); this.root=c; var d={"":""}; @@ -733,11 +779,13 @@ Jsonix.Binding.Unmarshalls.Element=Jsonix.Class({allowTypedObject:true,allowDom: }var k=this.getTypeInfoByInputElement(q,o,j); var r=o.getName(); var p; -if(this.allowTypedObject&&Jsonix.Util.Type.exists(k)){var n=k.unmarshal(q,o,j); +if(this.allowTypedObject){if(Jsonix.Util.Type.exists(k)){var n=k.unmarshal(q,o,j); var m={name:r,value:n,typeInfo:k}; p=this.convertFromTypedNamedValue(m,q,o,j) }else{if(this.allowDom){p=o.getElement() -}else{throw new Error("Element ["+r.toString()+"] is not known in this context and property does not allow DOM.") +}else{throw new Error("Element ["+r.toString()+"] could not be unmarshalled as is not known in this context and the property does not allow DOM content.") +}}}else{if(this.allowDom){p=o.getElement() +}else{throw new Error("Element ["+r.toString()+"] could not be unmarshalled as the property neither allows typed objects nor DOM as content. This is a sign of invalid mappings, do not use [allowTypedObject : false] and [allowDom : false] at the same time.") }}l(p) },getTypeInfoByInputElement:function(n,p,m){var i=null; if(n.supportXsiType){var j=p.getAttributeValueNS(Jsonix.Schema.XSI.NAMESPACE_URI,Jsonix.Schema.XSI.TYPE); @@ -1808,140 +1856,82 @@ if(Jsonix.Util.Type.isString(q)){return new Jsonix.XML.QName(q,n,m) },CLASS_NAME:"Jsonix.Schema.XSD.QName"}); Jsonix.Schema.XSD.QName.INSTANCE=new Jsonix.Schema.XSD.QName(); Jsonix.Schema.XSD.QName.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.QName.INSTANCE); -Jsonix.Schema.XSD.Calendar=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"Calendar",typeName:Jsonix.Schema.XSD.qname("calendar"),parse:function(k,n,p,m){Jsonix.Util.Ensure.ensureString(k); -var o=(k.charAt(0)==="-"); -var i=o?-1:1; -var l=o?k.substring(1):k; -var j; -if(l.length>=19&&l.charAt(4)==="-"&&l.charAt(7)==="-"&&l.charAt(10)==="T"&&l.charAt(13)===":"&&l.charAt(16)===":"){return this.parseDateTime(k) -}else{if(l.length>=10&&l.charAt(4)==="-"&&l.charAt(7)==="-"){return this.parseDate(k) -}else{if(l.length>=8&&l.charAt(2)===":"&&l.charAt(5)===":"){return this.parseTime(k) -}else{throw new Error("Value ["+k+"] does not match dateTime, date or time patterns.") -}}}},parseDateTime:function(p){Jsonix.Util.Ensure.ensureString(p); -var w=(p.charAt(0)==="-"); -var B=w?-1:1; -var v=w?p.substring(1):p; -if(v.length<19||v.charAt(4)!=="-"||v.charAt(7)!=="-"||v.charAt(10)!=="T"||v.charAt(13)!==":"||v.charAt(16)!==":"){throw new Error("Date time string ["+v+"] must be a string in format ['-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?].") -}var x; -var A=v.indexOf("+",19); -if(A>=0){x=A -}else{var u=v.indexOf("-",19); -if(u>=0){x=u -}else{var s=v.indexOf("Z",19); -if(s>=0){x=s -}else{x=v.length -}}}var C=x>0&&x=0){v=x -}else{var t=r.indexOf("-",10); -if(t>=0){v=t -}else{var q=r.indexOf("Z",10); -if(q>=0){v=q -}else{v=r.length -}}}var z=v>0&&v=0){p=r -}else{var o=k.indexOf("-",7); -if(o>=0){p=o -}else{var m=k.indexOf("Z",7); -if(m>=0){p=m -}else{p=k.length -}}}var s=p>0&&p=9?r.substring(8):""; -var m=this.parseHour(n); -var o=this.parseHour(k); -var q=this.parseSecond(p); -var l=this.parseFractionalSecond(j); -return{hour:m,minute:o,second:q,fractionalSecond:l} -},parseTimeZoneString:function(i){Jsonix.Util.Ensure.ensureString(i); -if(i===""){return NaN +Jsonix.Schema.XSD.Calendar=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"Calendar",typeName:Jsonix.Schema.XSD.qname("calendar"),parse:function(g,e,f,h){Jsonix.Util.Ensure.ensureString(g); +if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN+"$"))){return this.parseDateTime(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATE_PATTERN+"$"))){return this.parseDate(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIME_PATTERN+"$"))){return this.parseTime(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_MONTH_PATTERN+"$"))){return this.parseGYearMonth(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN+"$"))){return this.parseGYear(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.GMONTH_DAY_PATTERN+"$"))){return this.parseGMonthDay(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.GMONTH_PATTERN+"$"))){return this.parseGMonth(g,e,f,h) +}else{if(g.match(new RegExp("^"+Jsonix.Schema.XSD.Calendar.GDAY_PATTERN+"$"))){return this.parseGDay(g,e,f,h) +}else{throw new Error("Value ["+g+"] does not match xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth or xs:gDay patterns.") +}}}}}}}}},parseGYearMonth:function(j,n,i,m){var l=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_MONTH_PATTERN+"$"); +var h=j.match(l); +if(h!==null){var k={year:parseInt(h[1],10),month:parseInt(h[5],10),timezone:this.parseTimezoneString(h[7])}; +return new Jsonix.XML.Calendar(k) +}throw new Error("Value ["+j+"] does not match the xs:gYearMonth pattern.") +},parseGYear:function(j,n,i,m){var l=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN+"$"); +var h=j.match(l); +if(h!==null){var k={year:parseInt(h[1],10),timezone:this.parseTimezoneString(h[5])}; +return new Jsonix.XML.Calendar(k) +}throw new Error("Value ["+j+"] does not match the xs:gYear pattern.") +},parseGMonthDay:function(j,n,i,m){var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GMONTH_DAY_PATTERN+"$"); +var h=j.match(k); +if(h!==null){var l={month:parseInt(h[2],10),day:parseInt(h[3],10),timezone:this.parseTimezoneString(h[5])}; +return new Jsonix.XML.Calendar(l) +}throw new Error("Value ["+j+"] does not match the xs:gMonthDay pattern.") +},parseGMonth:function(k,n,i,m){var j=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GMONTH_PATTERN+"$"); +var h=k.match(j); +if(h!==null){var l={month:parseInt(h[2],10),timezone:this.parseTimezoneString(h[3])}; +return new Jsonix.XML.Calendar(l) +}throw new Error("Value ["+k+"] does not match the xs:gMonth pattern.") +},parseGDay:function(j,n,i,m){var l=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GDAY_PATTERN+"$"); +var h=j.match(l); +if(h!==null){var k={day:parseInt(h[2],10),timezone:this.parseTimezoneString(h[3])}; +return new Jsonix.XML.Calendar(k) +}throw new Error("Value ["+j+"] does not match the xs:gDay pattern.") +},parseDateTime:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j); +var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN+"$"); +var h=j.match(k); +if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),hour:parseInt(h[9],10),minute:parseInt(h[10],10),second:parseInt(h[11],10),fractionalSecond:(h[12]?parseFloat(h[12]):0),timezone:this.parseTimezoneString(h[14])}; +return new Jsonix.XML.Calendar(l) +}throw new Error("Value ["+value+"] does not match the xs:date pattern.") +},parseDate:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j); +var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATE_PATTERN+"$"); +var h=j.match(k); +if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),timezone:this.parseTimezoneString(h[9])}; +return new Jsonix.XML.Calendar(l) +}throw new Error("Value ["+value+"] does not match the xs:date pattern.") +},parseTime:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j); +var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIME_PATTERN+"$"); +var h=j.match(k); +if(h!==null){var l={hour:parseInt(h[1],10),minute:parseInt(h[2],10),second:parseInt(h[3],10),fractionalSecond:(h[4]?parseFloat(h[4]):0),timezone:this.parseTimezoneString(h[6])}; +return new Jsonix.XML.Calendar(l) +}throw new Error("Value ["+value+"] does not match the xs:time pattern.") +},parseTimezoneString:function(i){if(!Jsonix.Util.Type.isString(i)){return NaN +}else{if(i===""){return NaN }else{if(i==="Z"){return 0 -}else{if(i.length!==6){throw new Error("Time zone must be an empty string, 'Z' or a string in format [('+' | '-') hh ':' mm].") -}var h=i.charAt(0); -var f; -if(h==="+"){f=1 -}else{if(h==="-"){f=-1 -}else{throw new Error("First character of the time zone ["+i+"] must be '+' or '-'.") -}}var g=this.parseHour(i.substring(1,3)); -var j=this.parseMinute(i.substring(4,6)); -return -1*f*(g*60+j) -}}},parseYear:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==4){throw new Error("Year ["+c+"] must be a four-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureInteger(d); -return d -},parseMonth:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==2){throw new Error("Month ["+c+"] must be a two-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureInteger(d); -return d -},parseDay:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==2){throw new Error("Day ["+c+"] must be a two-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureInteger(d); -return d -},parseHour:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==2){throw new Error("Hour ["+c+"] must be a two-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureInteger(d); -return d -},parseMinute:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==2){throw new Error("Minute ["+c+"] must be a two-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureInteger(d); -return d -},parseSecond:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c.length!==2){throw new Error("Second ["+c+"] must be a two-digit number.") -}var d=Number(c); -Jsonix.Util.Ensure.ensureNumber(d); -return d -},parseFractionalSecond:function(c){Jsonix.Util.Ensure.ensureString(c); -if(c===""){return 0 -}else{var d=Number(c); -Jsonix.Util.Ensure.ensureNumber(d); -return d -}},print:function(g,e,f,h){Jsonix.Util.Ensure.ensureObject(g); +}else{if(i==="+14:00"){return 14*60 +}else{if(i==="-14:00"){return -14*60 +}else{var j=new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN+"$"); +var l=i.match(j); +if(l!==null){var g=l[1]==="+"?1:-1; +var h=parseInt(l[4],10); +var k=parseInt(l[5],10); +return g*(h*60+k) +}throw new Error("Value ["+value+"] does not match the timezone pattern.") +}}}}}},print:function(g,e,f,h){Jsonix.Util.Ensure.ensureObject(g); if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)&&Jsonix.Util.NumberUtils.isInteger(g.hour)&&Jsonix.Util.NumberUtils.isInteger(g.minute)&&Jsonix.Util.NumberUtils.isInteger(g.second)){return this.printDateTime(g) }else{if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)){return this.printDate(g) }else{if(Jsonix.Util.NumberUtils.isInteger(g.hour)&&Jsonix.Util.NumberUtils.isInteger(g.minute)&&Jsonix.Util.NumberUtils.isInteger(g.second)){return this.printTime(g) +}else{if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)){return this.printGYearMonth(g) +}else{if(Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)){return this.printGMonthDay(g) +}else{if(Jsonix.Util.NumberUtils.isInteger(g.year)){return this.printGYear(g) +}else{if(Jsonix.Util.NumberUtils.isInteger(g.month)){return this.printGMonth(g) +}else{if(Jsonix.Util.NumberUtils.isInteger(g.day)){return this.printGDay(g) }else{throw new Error("Value ["+g+"] is not recognized as dateTime, date or time.") -}}}},printDateTime:function(c){Jsonix.Util.Ensure.ensureObject(c); +}}}}}}}}},printDateTime:function(c){Jsonix.Util.Ensure.ensureObject(c); Jsonix.Util.Ensure.ensureInteger(c.year); Jsonix.Util.Ensure.ensureInteger(c.month); Jsonix.Util.Ensure.ensureInteger(c.day); @@ -1953,7 +1943,7 @@ if(Jsonix.Util.Type.exists(c.fractionalString)){Jsonix.Util.Ensure.ensureNumber( }var d=this.printDateString(c); d=d+"T"; d=d+this.printTimeString(c); -if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimeZoneString(c.timezone) +if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimezoneString(c.timezone) }return d },printDate:function(c){Jsonix.Util.Ensure.ensureObject(c); Jsonix.Util.Ensure.ensureNumber(c.year); @@ -1961,7 +1951,7 @@ Jsonix.Util.Ensure.ensureNumber(c.month); Jsonix.Util.Ensure.ensureNumber(c.day); if(Jsonix.Util.Type.exists(c.timezone)&&!Jsonix.Util.Type.isNaN(c.timezone)){Jsonix.Util.Ensure.ensureInteger(c.timezone) }var d=this.printDateString(c); -if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimeZoneString(c.timezone) +if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimezoneString(c.timezone) }return d },printTime:function(c){Jsonix.Util.Ensure.ensureObject(c); Jsonix.Util.Ensure.ensureNumber(c.hour); @@ -1970,7 +1960,7 @@ Jsonix.Util.Ensure.ensureNumber(c.second); if(Jsonix.Util.Type.exists(c.fractionalString)){Jsonix.Util.Ensure.ensureNumber(c.fractionalString) }if(Jsonix.Util.Type.exists(c.timezone)&&!Jsonix.Util.Type.isNaN(c.timezone)){Jsonix.Util.Ensure.ensureInteger(c.timezone) }var d=this.printTimeString(c); -if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimeZoneString(c.timezone) +if(Jsonix.Util.Type.exists(c.timezone)){d=d+this.printTimezoneString(c.timezone) }return d },printDateString:function(b){Jsonix.Util.Ensure.ensureObject(b); Jsonix.Util.Ensure.ensureInteger(b.year); @@ -1989,7 +1979,7 @@ d=d+":"; d=d+this.printSecond(c.second); if(Jsonix.Util.Type.exists(c.fractionalSecond)){d=d+this.printFractionalSecond(c.fractionalSecond) }return d -},printTimeZoneString:function(j){if(!Jsonix.Util.Type.exists(j)||Jsonix.Util.Type.isNaN(j)){return"" +},printTimezoneString:function(j){if(!Jsonix.Util.Type.exists(j)||Jsonix.Util.Type.isNaN(j)){return"" }else{Jsonix.Util.Ensure.ensureInteger(j); var l=j<0?-1:(j>0?1:0); var k=j*l; @@ -1997,13 +1987,72 @@ var i=k%60; var g=Math.floor(k/60); var h; if(l===0){return"Z" -}else{if(l>0){h="-" -}else{if(l<0){h="+" +}else{if(l>0){h="+" +}else{if(l<0){h="-" }}h=h+this.printHour(g); h=h+":"; h=h+this.printMinute(i); return h -}}},printYear:function(b){return this.printInteger(b,4) +}}},printGDay:function(i,l,g,k){Jsonix.Util.Ensure.ensureObject(i); +var h=undefined; +var j=undefined; +if(i instanceof Date){h=i.getDate() +}else{Jsonix.Util.Ensure.ensureInteger(i.day); +h=i.day; +j=i.timezone +}Jsonix.XML.Calendar.validateDay(h); +Jsonix.XML.Calendar.validateTimezone(j); +return"---"+this.printDay(h)+this.printTimezoneString(j) +},printGMonth:function(j,g,h,l){Jsonix.Util.Ensure.ensureObject(j); +var i=undefined; +var k=undefined; +if(j instanceof Date){i=j.getMonth()+1 +}else{Jsonix.Util.Ensure.ensureInteger(j.month); +i=j.month; +k=j.timezone +}Jsonix.XML.Calendar.validateMonth(i); +Jsonix.XML.Calendar.validateTimezone(k); +return"--"+this.printMonth(i)+this.printTimezoneString(k) +},printGMonthDay:function(k,n,h,m){Jsonix.Util.Ensure.ensureObject(k); +var j=undefined; +var i=undefined; +var l=undefined; +if(k instanceof Date){j=k.getMonth()+1; +i=k.getDate() +}else{Jsonix.Util.Ensure.ensureInteger(k.month); +Jsonix.Util.Ensure.ensureInteger(k.day); +j=k.month; +i=k.day; +l=k.timezone +}Jsonix.XML.Calendar.validateMonthDay(j,i); +Jsonix.XML.Calendar.validateTimezone(l); +return"--"+this.printMonth(j)+"-"+this.printDay(i)+this.printTimezoneString(l) +},printGYear:function(i,g,h,k){Jsonix.Util.Ensure.ensureObject(i); +var l=undefined; +var j=undefined; +if(i instanceof Date){l=i.getFullYear() +}else{Jsonix.Util.Ensure.ensureInteger(i.year); +l=i.year; +j=i.timezone +}Jsonix.XML.Calendar.validateYear(l); +Jsonix.XML.Calendar.validateTimezone(j); +return this.printSignedYear(l)+this.printTimezoneString(j) +},printGYearMonth:function(k,h,i,m){Jsonix.Util.Ensure.ensureObject(k); +var n=undefined; +var j=undefined; +var l=undefined; +if(k instanceof Date){n=k.getFullYear(); +j=k.getMonth()+1 +}else{Jsonix.Util.Ensure.ensureInteger(k.year); +n=k.year; +j=k.month; +l=k.timezone +}Jsonix.XML.Calendar.validateYear(n); +Jsonix.XML.Calendar.validateMonth(j); +Jsonix.XML.Calendar.validateTimezone(l); +return this.printSignedYear(n)+"-"+this.printMonth(j)+this.printTimezoneString(l) +},printSignedYear:function(b){return b<0?("-"+this.printYear(b*-1)):(this.printYear(b)) +},printYear:function(b){return this.printInteger(b,4) },printMonth:function(b){return this.printInteger(b,2) },printDay:function(b){return this.printInteger(b,2) },printHour:function(b){return this.printInteger(b,2) @@ -2020,7 +2069,6 @@ if(d<0){return"" Jsonix.Util.Ensure.ensureInteger(h); if(h<=0){throw new Error("Length ["+g+"] must be positive.") }if(g<0){throw new Error("Value ["+g+"] must not be negative.") -}if(g>=Math.pow(10,h)){throw new Error("Value ["+g+"] must be less than ["+Math.pow(10,h)+"].") }var f=String(g); for(var e=f.length; e=0)||(Jsonix.Util.NumberUtils.isInteger(f.months)&&f.months>=0)||(Jsonix.Util.NumberUtils.isInteger(f.days)&&f.days>=0)||(Jsonix.Util.NumberUtils.isInteger(f.hours)&&f.hours>=0)||(Jsonix.Util.NumberUtils.isInteger(f.minutes)&&f.minutes>=0)||(Jsonix.Util.Type.isNumber(f.seconds)&&f.seconds>=0)) +},validate:function(h){Jsonix.Util.Ensure.ensureObject(h); +if(Jsonix.Util.Type.exists(h.sign)){if(!(h.sign===1||h.sign===-1)){throw new Error("Sign of the duration ["+h.sign+"] must be either [1] or [-1].") +}}var e=true; +var g=function(b,a){if(Jsonix.Util.Type.exists(b)){if(!(Jsonix.Util.NumberUtils.isInteger(b)&&b>=0)){throw new Error(a.replace("{0}",b)) +}else{return true +}}else{return false +}}; +var f=function(b,a){if(Jsonix.Util.Type.exists(b)){if(!(Jsonix.Util.Type.isNumber(b)&&b>=0)){throw new Error(a.replace("{0}",b)) +}else{return true +}}else{return false +}}; +e=e&&!g(h.years,"Number of years [{0}] must be an unsigned integer."); +e=e&&!g(h.months,"Number of months [{0}] must be an unsigned integer."); +e=e&&!g(h.days,"Number of days [{0}] must be an unsigned integer."); +e=e&&!g(h.hours,"Number of hours [{0}] must be an unsigned integer."); +e=e&&!g(h.minutes,"Number of minutes [{0}] must be an unsigned integer."); +e=e&&!f(h.seconds,"Number of seconds [{0}] must be an unsigned number."); +if(e){throw new Error("At least one of the components (years, months, days, hours, minutes, seconds) must be set.") +}},print:function(h,j,f,i){this.validate(h); +var g=""; +if(h.sign===-1){g+="-" +}g+="P"; +if(h.years){g+=(h.years+"Y") +}if(h.months){g+=(h.months+"M") +}if(h.days){g+=(h.days+"D") +}if(h.hours||h.minutes||h.seconds){g+="T"; +if(h.hours){g+=(h.hours+"H") +}if(h.minutes){g+=(h.minutes+"M") +}if(h.seconds){g+=(h.seconds+"S") +}}return g +},parse:function(m,p,j,o){var k=new RegExp("^"+Jsonix.Schema.XSD.Duration.PATTERN+"$"); +var i=m.match(k); +if(i!==null){var n=true; +var l={}; +if(i[1]){l.sign=-1 +}if(i[3]){l.years=parseInt(i[3],10); +n=false +}if(i[5]){l.months=parseInt(i[5],10); +n=false +}if(i[7]){l.days=parseInt(i[7],10); +n=false +}if(i[10]){l.hours=parseInt(i[10],10); +n=false +}if(i[12]){l.minutes=parseInt(i[12],10); +n=false +}if(i[14]){l.seconds=Number(i[14]); +n=false +}return l +}else{throw new Error("Value ["+m+"] does not match the duration pattern.") +}},CLASS_NAME:"Jsonix.Schema.XSD.Duration"}); +Jsonix.Schema.XSD.Duration.PATTERN="(-)?P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?(T(([0-9]+)H)?(([0-9]+)M)?(([0-9]+(\\.[0-9]+)?)S)?)?"; Jsonix.Schema.XSD.Duration.INSTANCE=new Jsonix.Schema.XSD.Duration(); Jsonix.Schema.XSD.Duration.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Duration.INSTANCE); -Jsonix.Schema.XSD.DateTime=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"DateTime",typeName:Jsonix.Schema.XSD.qname("dateTime"),parse:function(o,t,p,l){var q=this.parseDateTime(o); +Jsonix.Schema.XSD.DateTime=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"DateTime",typeName:Jsonix.Schema.XSD.qname("dateTime"),parse:function(n,t,o,l){var q=this.parseDateTime(n); var s=new Date(); s.setFullYear(q.year); s.setMonth(q.month-1); @@ -2045,32 +2157,33 @@ s.setHours(q.hour); s.setMinutes(q.minute); s.setSeconds(q.second); if(Jsonix.Util.Type.isNumber(q.fractionalSecond)){s.setMilliseconds(Math.floor(1000*q.fractionalSecond)) -}var n; +}var p; var r; -var m=s.getTimezoneOffset(); -if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){n=q.timezone; +var m=-s.getTimezoneOffset(); +if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){p=q.timezone; r=false -}else{n=m; +}else{p=m; r=true -}var k=new Date(s.getTime()+(60000*(n-m))); +}var k=new Date(s.getTime()+(60000*(-p+m))); if(r){k.originalTimezone=null -}else{k.originalTimezone=n +}else{k.originalTimezone=q.timezone }return k -},print:function(k,n,i,m){Jsonix.Util.Ensure.ensureDate(k); -var l; -var j=k.getTimezoneOffset(); -var h; +},print:function(k,o,i,n){Jsonix.Util.Ensure.ensureDate(k); +var m; +var l=-k.getTimezoneOffset(); +var p; if(k.originalTimezone===null){return this.printDateTime(new Jsonix.XML.Calendar({year:k.getFullYear(),month:k.getMonth()+1,day:k.getDate(),hour:k.getHours(),minute:k.getMinutes(),second:k.getSeconds(),fractionalSecond:(k.getMilliseconds()/1000)})) -}else{if(Jsonix.Util.NumberUtils.isInteger(k.originalTimezone)){l=k.originalTimezone; -h=new Date(k.getTime()-(60000*(l-j))) -}else{l=j; -h=k -}return this.printDateTime(new Jsonix.XML.Calendar({year:h.getFullYear(),month:h.getMonth()+1,day:h.getDate(),hour:h.getHours(),minute:h.getMinutes(),second:h.getSeconds(),fractionalSecond:(h.getMilliseconds()/1000),timezone:l})) +}else{if(Jsonix.Util.NumberUtils.isInteger(k.originalTimezone)){m=k.originalTimezone; +p=new Date(k.getTime()-(60000*(-m+l))) +}else{m=l; +p=k +}var j=this.printDateTime(new Jsonix.XML.Calendar({year:p.getFullYear(),month:p.getMonth()+1,day:p.getDate(),hour:p.getHours(),minute:p.getMinutes(),second:p.getSeconds(),fractionalSecond:(p.getMilliseconds()/1000),timezone:m})); +return j }},isInstance:function(f,e,d){return Jsonix.Util.Type.isDate(f) },CLASS_NAME:"Jsonix.Schema.XSD.DateTime"}); Jsonix.Schema.XSD.DateTime.INSTANCE=new Jsonix.Schema.XSD.DateTime(); Jsonix.Schema.XSD.DateTime.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.DateTime.INSTANCE); -Jsonix.Schema.XSD.Time=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"Time",typeName:Jsonix.Schema.XSD.qname("time"),parse:function(o,t,p,l){var q=this.parseTime(o); +Jsonix.Schema.XSD.Time=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"Time",typeName:Jsonix.Schema.XSD.qname("time"),parse:function(n,t,o,l){var q=this.parseTime(n); var s=new Date(); s.setFullYear(1970); s.setMonth(0); @@ -2079,37 +2192,37 @@ s.setHours(q.hour); s.setMinutes(q.minute); s.setSeconds(q.second); if(Jsonix.Util.Type.isNumber(q.fractionalSecond)){s.setMilliseconds(Math.floor(1000*q.fractionalSecond)) -}var n; +}var p; var r; -var m=s.getTimezoneOffset(); -if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){n=q.timezone; +var m=-s.getTimezoneOffset(); +if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){p=q.timezone; r=false -}else{n=m; +}else{p=m; r=true -}var k=new Date(s.getTime()+(60000*(n-m))); +}var k=new Date(s.getTime()+(60000*(-p+m))); if(r){k.originalTimezone=null -}else{k.originalTimezone=n +}else{k.originalTimezone=p }return k -},print:function(n,t,r,k){Jsonix.Util.Ensure.ensureDate(n); -var q=n.getTime(); -if(q<=-86400000&&q>=86400000){throw new Error("Invalid time ["+n+"].") -}if(n.originalTimezone===null){return this.printTime(new Jsonix.XML.Calendar({hour:n.getHours(),minute:n.getMinutes(),second:n.getSeconds(),fractionalSecond:(n.getMilliseconds()/1000)})) +},print:function(m,t,r,k){Jsonix.Util.Ensure.ensureDate(m); +var q=m.getTime(); +if(q<=-86400000&&q>=86400000){throw new Error("Invalid time ["+m+"].") +}if(m.originalTimezone===null){return this.printTime(new Jsonix.XML.Calendar({hour:m.getHours(),minute:m.getMinutes(),second:m.getSeconds(),fractionalSecond:(m.getMilliseconds()/1000)})) }else{var s; -var m; -var l=n.getTimezoneOffset(); -if(Jsonix.Util.NumberUtils.isInteger(n.originalTimezone)){m=n.originalTimezone; -s=new Date(n.getTime()-(60000*(m-l))) -}else{m=l; -s=n -}var o=s.getTime(); -if(o>=0){return this.printTime(new Jsonix.XML.Calendar({hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),fractionalSecond:(s.getMilliseconds()/1000),timezone:m})) -}else{var p=Math.ceil(-o/3600000); -return this.printTime(new Jsonix.XML.Calendar({hour:(s.getHours()+p+m/60)%24,minute:s.getMinutes(),second:s.getSeconds(),fractionalSecond:(s.getMilliseconds()/1000),timezone:-p*60})) +var o; +var l=-m.getTimezoneOffset(); +if(Jsonix.Util.NumberUtils.isInteger(m.originalTimezone)){o=m.originalTimezone; +s=new Date(m.getTime()-(60000*(-o+l))) +}else{o=l; +s=m +}var n=s.getTime(); +if(n>=0){return this.printTime(new Jsonix.XML.Calendar({hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),fractionalSecond:(s.getMilliseconds()/1000),timezone:o})) +}else{var p=Math.ceil(-n/3600000); +return this.printTime(new Jsonix.XML.Calendar({hour:(s.getHours()+p-o/60)%24,minute:s.getMinutes(),second:s.getSeconds(),fractionalSecond:(s.getMilliseconds()/1000),timezone:p*60})) }}},isInstance:function(f,e,d){return Jsonix.Util.Type.isDate(f)&&f.getTime()>-86400000&&f.getTime()<86400000 },CLASS_NAME:"Jsonix.Schema.XSD.Time"}); Jsonix.Schema.XSD.Time.INSTANCE=new Jsonix.Schema.XSD.Time(); Jsonix.Schema.XSD.Time.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Time.INSTANCE); -Jsonix.Schema.XSD.Date=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"Date",typeName:Jsonix.Schema.XSD.qname("date"),parse:function(o,t,p,l){var q=this.parseDate(o); +Jsonix.Schema.XSD.Date=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"Date",typeName:Jsonix.Schema.XSD.qname("date"),parse:function(n,t,o,l){var q=this.parseDate(n); var s=new Date(); s.setFullYear(q.year); s.setMonth(q.month-1); @@ -2119,67 +2232,59 @@ s.setMinutes(0); s.setSeconds(0); s.setMilliseconds(0); if(Jsonix.Util.Type.isNumber(q.fractionalSecond)){s.setMilliseconds(Math.floor(1000*q.fractionalSecond)) -}var n; +}var p; var r; -var m=s.getTimezoneOffset(); -if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){n=q.timezone; +var m=-s.getTimezoneOffset(); +if(Jsonix.Util.NumberUtils.isInteger(q.timezone)){p=q.timezone; r=false -}else{n=m; +}else{p=m; r=true -}var k=new Date(s.getTime()+(60000*(n-m))); +}var k=new Date(s.getTime()+(60000*(-p+m))); if(r){k.originalTimezone=null -}else{k.originalTimezone=n +}else{k.originalTimezone=p }return k -},print:function(m,r,p,j){Jsonix.Util.Ensure.ensureDate(m); -var o=new Date(m.getTime()); +},print:function(l,r,p,j){Jsonix.Util.Ensure.ensureDate(l); +var o=new Date(l.getTime()); o.setHours(0); o.setMinutes(0); o.setSeconds(0); o.setMilliseconds(0); -if(m.originalTimezone===null){return this.printDate(new Jsonix.XML.Calendar({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate()})) -}else{if(Jsonix.Util.NumberUtils.isInteger(m.originalTimezone)){var q=new Date(m.getTime()-(60000*(m.originalTimezone-m.getTimezoneOffset()))); -return this.printDate(new Jsonix.XML.Calendar({year:q.getFullYear(),month:q.getMonth()+1,day:q.getDate(),timezone:m.originalTimezone})) -}else{var k=m.getTime()-o.getTime(); -if(k===0){return this.printDate(new Jsonix.XML.Calendar({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate()})) -}else{var l=k+(60000*m.getTimezoneOffset()); -if(l<=43200000){return this.printDate(new Jsonix.XML.Calendar({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate(),timezone:Math.floor(l/60000)})) -}else{var n=new Date(m.getTime()+86400000); -return this.printDate(new Jsonix.XML.Calendar({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),timezone:(Math.floor(l/60000)-1440)})) +if(l.originalTimezone===null){return this.printDate(new Jsonix.XML.Calendar({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()})) +}else{if(Jsonix.Util.NumberUtils.isInteger(l.originalTimezone)){var q=new Date(l.getTime()-(60000*(-l.originalTimezone-l.getTimezoneOffset()))); +return this.printDate(new Jsonix.XML.Calendar({year:q.getFullYear(),month:q.getMonth()+1,day:q.getDate(),timezone:l.originalTimezone})) +}else{var k=-l.getTime()+o.getTime(); +if(k===0){return this.printDate(new Jsonix.XML.Calendar({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()})) +}else{var n=k-(60000*l.getTimezoneOffset()); +if(n>=-43200000){return this.printDate(new Jsonix.XML.Calendar({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate(),timezone:Math.floor(n/60000)})) +}else{var m=new Date(l.getTime()+86400000); +return this.printDate(new Jsonix.XML.Calendar({year:m.getFullYear(),month:m.getMonth()+1,day:m.getDate(),timezone:(Math.floor(n/60000)+1440)})) }}}}},isInstance:function(f,e,d){return Jsonix.Util.Type.isDate(f) },CLASS_NAME:"Jsonix.Schema.XSD.Date"}); Jsonix.Schema.XSD.Date.INSTANCE=new Jsonix.Schema.XSD.Date(); Jsonix.Schema.XSD.Date.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.Date.INSTANCE); -Jsonix.Schema.XSD.GYearMonth=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"GYearMonth",typeName:Jsonix.Schema.XSD.qname("gYearMonth"),CLASS_NAME:"Jsonix.Schema.XSD.GYearMonth"}); +Jsonix.Schema.XSD.GYearMonth=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GYearMonth",typeName:Jsonix.Schema.XSD.qname("gYearMonth"),CLASS_NAME:"Jsonix.Schema.XSD.GYearMonth",parse:function(g,e,f,h){return this.parseGYearMonth(g,e,f,h) +},print:function(g,e,f,h){return this.printGYearMonth(g,e,f,h) +}}); Jsonix.Schema.XSD.GYearMonth.INSTANCE=new Jsonix.Schema.XSD.GYearMonth(); Jsonix.Schema.XSD.GYearMonth.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GYearMonth.INSTANCE); -Jsonix.Schema.XSD.GYear=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GYear",typeName:Jsonix.Schema.XSD.qname("gYear"),parse:function(h,f,g,i){var j=this.splitGYear(h); -j.toString=function(){return"EmptyXMLElement. Call embedded 'year' or 'timezone' property" -}; -return j -},splitGYear:function(g){var h=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN+"$"); -var f=g.match(h); -if(f!==null){var e={year:parseInt(f[1],10),_timezone:f[5],timezone:this.parseTimeZoneString(f[5])}; -return e -}throw new Error("Value ["+g+"] doesn't match the gYear pattern.") -},parseTimeZoneString:function(c){if(c==="Z"||!Jsonix.Util.Type.exists(c)){return 0 -}var d=c.split(":"); -return -(parseInt(d[0],10)*60+parseInt(d[1],10)) -},_validateGYear:function(c){var d=new RegExp("^"+Jsonix.Schema.XSD.Calendar.GYEAR_PATTERN+"$"); -if(!d.test(c)){throw new Error("Value ["+c+"] doesn't match the gYear pattern.") -}},_validateYear:function(d){var c=new RegExp("^"+Jsonix.Schema.XSD.Calendar.YEAR_PATTERN+"$"); -if(!c.test(d)){throw new Error("Value ["+d+"] doesn't match the year pattern.") -}},_validateTimeZone:function(c){var d=new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIMEZONE_PATTERN+"$"); -if(!d.test(c)){throw new Error("Value ["+c+"] doesn't match the time zone pattern.") -}},CLASS_NAME:"Jsonix.Schema.XSD.GYear"}); +Jsonix.Schema.XSD.GYear=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GYear",typeName:Jsonix.Schema.XSD.qname("gYear"),CLASS_NAME:"Jsonix.Schema.XSD.GYear",parse:function(g,e,f,h){return this.parseGYear(g,e,f,h) +},print:function(g,e,f,h){return this.printGYear(g,e,f,h) +}}); Jsonix.Schema.XSD.GYear.INSTANCE=new Jsonix.Schema.XSD.GYear(); Jsonix.Schema.XSD.GYear.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GYear.INSTANCE); -Jsonix.Schema.XSD.GMonthDay=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"GMonthDay",typeName:Jsonix.Schema.XSD.qname("gMonthDay"),CLASS_NAME:"Jsonix.Schema.XSD.GMonthDay"}); +Jsonix.Schema.XSD.GMonthDay=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GMonthDay",typeName:Jsonix.Schema.XSD.qname("gMonthDay"),CLASS_NAME:"Jsonix.Schema.XSD.GMonthDay",parse:function(g,e,f,h){return this.parseGMonthDay(g,e,f,h) +},print:function(g,e,f,h){return this.printGMonthDay(g,e,f,h) +}}); Jsonix.Schema.XSD.GMonthDay.INSTANCE=new Jsonix.Schema.XSD.GMonthDay(); Jsonix.Schema.XSD.GMonthDay.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GMonthDay.INSTANCE); -Jsonix.Schema.XSD.GDay=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"GDay",typeName:Jsonix.Schema.XSD.qname("gDay"),CLASS_NAME:"Jsonix.Schema.XSD.GDay"}); +Jsonix.Schema.XSD.GDay=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GDay",typeName:Jsonix.Schema.XSD.qname("gDay"),CLASS_NAME:"Jsonix.Schema.XSD.GDay",parse:function(g,e,f,h){return this.parseGDay(g,e,f,h) +},print:function(g,e,f,h){return this.printGDay(g,e,f,h) +}}); Jsonix.Schema.XSD.GDay.INSTANCE=new Jsonix.Schema.XSD.GDay(); Jsonix.Schema.XSD.GDay.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GDay.INSTANCE); -Jsonix.Schema.XSD.GMonth=Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType,{name:"GMonth",typeName:Jsonix.Schema.XSD.qname("gMonth"),CLASS_NAME:"Jsonix.Schema.XSD.GMonth"}); +Jsonix.Schema.XSD.GMonth=Jsonix.Class(Jsonix.Schema.XSD.Calendar,{name:"GMonth",typeName:Jsonix.Schema.XSD.qname("gMonth"),CLASS_NAME:"Jsonix.Schema.XSD.GMonth",parse:function(g,e,f,h){return this.parseGMonth(g,e,f,h) +},print:function(g,e,f,h){return this.printGMonth(g,e,f,h) +}}); Jsonix.Schema.XSD.GMonth.INSTANCE=new Jsonix.Schema.XSD.GMonth(); Jsonix.Schema.XSD.GMonth.INSTANCE.LIST=new Jsonix.Schema.XSD.List(Jsonix.Schema.XSD.GMonth.INSTANCE); Jsonix.Schema.XSD.ID=Jsonix.Class(Jsonix.Schema.XSD.String,{name:"ID",typeName:Jsonix.Schema.XSD.qname("ID"),CLASS_NAME:"Jsonix.Schema.XSD.ID"}); diff --git a/dist/pom.xml b/dist/pom.xml index 40091bc2..1c911fd8 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -8,7 +8,7 @@ org.hisrc.jsonix jsonix-project - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/pom.xml b/nodejs/pom.xml index 7eacc50c..5097ab0b 100644 --- a/nodejs/pom.xml +++ b/nodejs/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-project - 2.2.2-SNAPSHOT + 2.3.0 scripts diff --git a/nodejs/scripts/package.json b/nodejs/scripts/package.json index b292940e..a593b650 100644 --- a/nodejs/scripts/package.json +++ b/nodejs/scripts/package.json @@ -1,6 +1,6 @@ { "name" : "jsonix", - "version" : "2.2.2-SNAPSHOT", + "version" : "2.3.0", "description" : "Jsonix (JSON interfaces for XML) is a JavaScript library which allows converting between XML and JSON structures.", "keywords" : [ "json", "xml", "unmarshal", "unmarshalling", "marshal", "marshalling", "parse", "parsing", "serialize", "serializing", diff --git a/nodejs/scripts/pom.xml b/nodejs/scripts/pom.xml index 1f6d05ff..d1e95cf3 100644 --- a/nodejs/scripts/pom.xml +++ b/nodejs/scripts/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/tests/ar/pom.xml b/nodejs/tests/ar/pom.xml index 691b8b87..f7f9ea61 100644 --- a/nodejs/tests/ar/pom.xml +++ b/nodejs/tests/ar/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs-tests - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/tests/basic/pom.xml b/nodejs/tests/basic/pom.xml index 46e56864..1993ce11 100644 --- a/nodejs/tests/basic/pom.xml +++ b/nodejs/tests/basic/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs-tests - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/tests/browserify/pom.xml b/nodejs/tests/browserify/pom.xml index af1de66d..72c3b1a1 100644 --- a/nodejs/tests/browserify/pom.xml +++ b/nodejs/tests/browserify/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs-tests - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/tests/po/pom.xml b/nodejs/tests/po/pom.xml index bf50d7c1..5c537238 100644 --- a/nodejs/tests/po/pom.xml +++ b/nodejs/tests/po/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs-tests - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/nodejs/tests/pom.xml b/nodejs/tests/pom.xml index 8a9dcfd1..bc04761b 100644 --- a/nodejs/tests/pom.xml +++ b/nodejs/tests/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs - 2.2.2-SNAPSHOT + 2.3.0 basic diff --git a/nodejs/tests/wps/pom.xml b/nodejs/tests/wps/pom.xml index 2638a4e6..92f36696 100644 --- a/nodejs/tests/wps/pom.xml +++ b/nodejs/tests/wps/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-nodejs-tests - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/pom.xml b/pom.xml index a206bea0..2ca9b15f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.hisrc.jsonix jsonix-project pom - 2.2.2-SNAPSHOT + 2.3.0 Jsonix Jsonix is a JavaScript library which allows you to convert between XML and JSON structures based on mappings. https://github.com/highsource/jsonix diff --git a/scripts/pom.xml b/scripts/pom.xml index 252863f0..e6d43544 100644 --- a/scripts/pom.xml +++ b/scripts/pom.xml @@ -6,7 +6,7 @@ org.hisrc.jsonix jsonix-project - 2.2.2-SNAPSHOT + 2.3.0