@Override public void emitValue(final JsonGenerator jgen, final Property prop) throws Throwable { final PeriodList pl; if (prop instanceof RDate) { final RDate p = (RDate)prop; pl = p.getPeriods(); } else if (prop instanceof FreeBusy) { final FreeBusy p = (FreeBusy)prop; pl = p.getPeriods(); } else { throw new RuntimeException("Unknown property " + prop); } jgen.writeStartArray(); for (final Object o: pl) { final Period per = (Period)o; final StringBuilder sb = new StringBuilder(XcalUtil.getXmlFormatDateTime( per.getStart().toString())); sb.append("/"); if (per.getDuration() != null) { sb.append(per.getDuration()); } else { sb.append(XcalUtil.getXmlFormatDateTime( per.getEnd().toString())); } jgen.writeString(sb.toString()); } jgen.writeEndArray(); } }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
/** * Compares the specified period with this period. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return new TemporalAmountComparator().compare(getDuration(), arg0.getDuration()); }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return new TemporalAmountComparator().compare(getDuration(), arg0.getDuration()); }