diff options
Diffstat (limited to '')
13 files changed, 63 insertions, 239 deletions
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java index 9bab332..4e0bb5f 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java @@ -33,7 +33,7 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
-import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java index 41c73b5..435c6ef 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java @@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java b/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java deleted file mode 100644 index 04b1c2e..0000000 --- a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.uic.barcode.ticket.api.asn.omv2;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-
-public class DateTimeUtils {
-
- public static Long getDateDifference(Date issuingDate, Date localDate) {
-
- if (issuingDate == null || localDate == null) return null;
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
- issuingCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- issuingCal.set(Calendar.HOUR_OF_DAY, 0);
- issuingCal.set(Calendar.MINUTE, 0);
- issuingCal.set(Calendar.SECOND, 0);
- issuingCal.set(Calendar.MILLISECOND, 0);
-
- Calendar fromCal = Calendar.getInstance();
- fromCal.clear();
- fromCal.setTime(localDate);
- fromCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- fromCal.set(Calendar.HOUR_OF_DAY, 0);
- fromCal.set(Calendar.MINUTE, 0);
- fromCal.set(Calendar.SECOND, 0);
- fromCal.set(Calendar.MILLISECOND, 0);
-
- long diff = localDate.getTime() - issuingDate.getTime();
- long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
-
- return new Long(dayDiff);
-
- }
-
- public static Date getLocalDateFromDifference(Date issuingDate, int diff , Long time ) {
-
- if (issuingDate == null) return null;
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(issuingDate);
- cal.add(Calendar.DAY_OF_YEAR, diff);
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
- return cal.getTime();
-
- }
-
-
- public static void setTime(Calendar cal, Long time){
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
-
- }
-
- public static Long getTime (Calendar cal) {
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Long getTime (Date date) {
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(date);
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Date getDate(Date issuingDate, Long date, Long time){
-
- if (issuingDate == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
-
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- DateTimeUtils.setTime(cal,time);
-
- return cal.getTime();
-
- }
-
-
-
- /**
- * Gets the UTC offset.
- *
- * @param date and time of the issuing date
- * @param date and time of the departure
- * @return the UTC offset in multiples of 15 minutes
- * the offset needs to be added to local time to get the UTC time (UTC = local + offset)
- */
- public static Long getUTCoffset(Date local) {
-
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(local);
-
- /*
- * Returns the amount of time in milliseconds to add to UTC to get standard time in this
- * time zone. Because this value is not affected by daylight saving time, it is called raw offset.
- * If an underlying TimeZone implementation subclass supports historical GMT offset changes, the method
- * returns the raw offset value of the current date. In Honolulu, for example, its raw offset
- * changed from GMT-10:30 to GMT-10:00 in 1947, and this method
- * always returns -36000000 milliseconds (i.e., -10 hours).
- */
- int minuteOffset = - cal.getTimeZone().getRawOffset()/ ( 1000 * 60 * 15 );
-
- return new Long (minuteOffset);
-
- }
-
- public static Date getUTCDate(Date issuingDate, Long date, Long time, Long UTCOffset) {
-
- if (issuingDate == null) return null;
-
- if (UTCOffset == null) return null;
-
- if (time == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
-
- cal.add(Calendar.MINUTE, (int) (UTCOffset * 15) );
-
- cal.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- return cal.getTime();
-
- }
-
-
-}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java index e11a66f..c6a98e4 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java @@ -29,10 +29,15 @@ import org.uic.barcode.asn1.datatypes.Asn1Default; import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
+import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
+@Sequence
+@HasExtensionMarker
public class FIPTicketData extends Object {
public FIPTicketData() {
}
@@ -254,7 +259,7 @@ public class FIPTicketData extends Object { public Date getValidFromDate(Date issuingDate){
- return DateTimeUtils.getDate(issuingDate, this.validFromDay,null);
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay,0L);
}
@@ -271,24 +276,20 @@ public class FIPTicketData extends Object { }
- return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, null);
+ return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, 1439L);
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -307,6 +308,12 @@ public class FIPTicketData extends Object { }
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -315,7 +322,7 @@ public class FIPTicketData extends Object { for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java index dc43d75..cef0b02 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java @@ -31,6 +31,7 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class IncludedOpenTicketType extends Object {
public IncludedOpenTicketType() {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java index 402323e..9900640 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java @@ -35,6 +35,8 @@ import org.uic.barcode.asn1.datatypes.RestrictedString; import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -601,21 +603,16 @@ public class OpenTicketData extends Object { }
-
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -634,6 +631,12 @@ public class OpenTicketData extends Object { }
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -642,7 +645,7 @@ public class OpenTicketData extends Object { for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
@@ -653,6 +656,7 @@ public class OpenTicketData extends Object { return dates;
}
+
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java index 1e14394..4f6f6d8 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java @@ -30,6 +30,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker; import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java index b3b02e7..dbc81c3 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java @@ -34,6 +34,8 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -516,20 +518,16 @@ public class PassData extends Object { }
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
@@ -548,6 +546,12 @@ public class PassData extends Object { }
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -556,7 +560,7 @@ public class PassData extends Object { for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java index a474e7d..31b3fa8 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java @@ -33,6 +33,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString; import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java index 6c6d36d..a378bb7 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java @@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.Sequence; import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java index 7c3de46..f269497 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java @@ -28,6 +28,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder; import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class TrainLinkType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java index 6c36c97..7b08f73 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java +++ b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java @@ -26,6 +26,7 @@ import org.uic.barcode.asn1.datatypes.Asn1Optional; import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class ValidityPeriodType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn index b67ac06..2c2eda7 100644 --- a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn +++ b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn @@ -535,7 +535,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN vatDetail SEQUENCE OF VatDetailType OPTIONAL,
- -- type of supplement - code list from 018.1
+ -- type of supplement - code list from 918.1
typeOfSupplement INTEGER (0..9) DEFAULT 0,
numberOfSupplements INTEGER (0..200) DEFAULT 0,
|