@Test public void testEncodePeriod() { DublinCoreValue a = encodePeriod(new DCMIPeriod(createDate(2007, 2, 10, 12, 0, 0), createDate(2009, 12, 24, 10, 0, 0), "long time"), Precision.Day); assertEquals("start=2007-02-10; end=2009-12-24; name=long time; scheme=W3C-DTF;", a.getValue()); assertEquals(Opt.some(DublinCore.ENC_SCHEME_PERIOD), a.getEncodingScheme()); DublinCoreValue b = encodePeriod(new DCMIPeriod(createDate(2007, 2, 10, 12, 0, 0), null), Precision.Day); assertEquals("start=2007-02-10; scheme=W3C-DTF;", b.getValue()); }
public static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision) { if (period == null) throw new IllegalArgumentException("The period must not be null"); if (precision == null) throw new IllegalArgumentException("The precision must not be null"); StringBuilder b = new StringBuilder(); if (period.hasStart()) { b.append("start=").append(formatDate(period.getStart(), precision)).append(";"); } if (period.hasEnd()) { if (b.length() > 0) b.append(" "); b.append("end=").append(formatDate(period.getEnd(), precision)).append(";"); } if (period.hasName()) { b.append(" ").append("name=").append(period.getName().replace(";", "")).append(";"); } b.append(" ").append("scheme=W3C-DTF;"); return DublinCoreValue.mk(b.toString(), DublinCore.LANGUAGE_UNDEFINED, Opt.some(DublinCore.ENC_SCHEME_PERIOD)); }
EncodingSchemeUtils { public static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision) { if (period == null) throw new IllegalArgumentException("The period must not be null"); if (precision == null) throw new IllegalArgumentException("The precision must not be null"); StringBuilder b = new StringBuilder(); if (period.hasStart()) { b.append("start=").append(formatDate(period.getStart(), precision)).append(";"); } if (period.hasEnd()) { if (b.length() > 0) b.append(" "); b.append("end=").append(formatDate(period.getEnd(), precision)).append(";"); } if (period.hasName()) { b.append(" ").append("name=").append(period.getName().replace(";", "")).append(";"); } b.append(" ").append("scheme=W3C-DTF;"); return DublinCoreValue.mk(b.toString(), DublinCore.LANGUAGE_UNDEFINED, Opt.some(DublinCore.ENC_SCHEME_PERIOD)); } }
EncodingSchemeUtils { public static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision) { if (period == null) throw new IllegalArgumentException("The period must not be null"); if (precision == null) throw new IllegalArgumentException("The precision must not be null"); StringBuilder b = new StringBuilder(); if (period.hasStart()) { b.append("start=").append(formatDate(period.getStart(), precision)).append(";"); } if (period.hasEnd()) { if (b.length() > 0) b.append(" "); b.append("end=").append(formatDate(period.getEnd(), precision)).append(";"); } if (period.hasName()) { b.append(" ").append("name=").append(period.getName().replace(";", "")).append(";"); } b.append(" ").append("scheme=W3C-DTF;"); return DublinCoreValue.mk(b.toString(), DublinCore.LANGUAGE_UNDEFINED, Opt.some(DublinCore.ENC_SCHEME_PERIOD)); } private  EncodingSchemeUtils(); }
EncodingSchemeUtils { public static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision) { if (period == null) throw new IllegalArgumentException("The period must not be null"); if (precision == null) throw new IllegalArgumentException("The precision must not be null"); StringBuilder b = new StringBuilder(); if (period.hasStart()) { b.append("start=").append(formatDate(period.getStart(), precision)).append(";"); } if (period.hasEnd()) { if (b.length() > 0) b.append(" "); b.append("end=").append(formatDate(period.getEnd(), precision)).append(";"); } if (period.hasName()) { b.append(" ").append("name=").append(period.getName().replace(";", "")).append(";"); } b.append(" ").append("scheme=W3C-DTF;"); return DublinCoreValue.mk(b.toString(), DublinCore.LANGUAGE_UNDEFINED, Opt.some(DublinCore.ENC_SCHEME_PERIOD)); } private  EncodingSchemeUtils(); static DublinCoreValue encodeDate(Date date, Precision precision); static String formatDate(Date date, Precision precision); static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision); static DublinCoreValue encodeDuration(long duration); static Long decodeDuration(String value); static Long decodeDuration(DublinCoreValue value); static Long decodeMandatoryDuration(String value); static Date decodeDate(DublinCoreValue value); static Date decodeDate(String value); static Date decodeMandatoryDate(DublinCoreValue value); static Date decodeMandatoryDate(String value); static DCMIPeriod decodePeriod(DublinCoreValue value); static DCMIPeriod decodePeriod(String value); static DCMIPeriod decodeMandatoryPeriod(DublinCoreValue value); static DCMIPeriod decodeMandatoryPeriod(String value); static Temporal decodeTemporal(DublinCoreValue value); static Temporal decodeMandatoryTemporal(DublinCoreValue value); }
EncodingSchemeUtils { public static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision) { if (period == null) throw new IllegalArgumentException("The period must not be null"); if (precision == null) throw new IllegalArgumentException("The precision must not be null"); StringBuilder b = new StringBuilder(); if (period.hasStart()) { b.append("start=").append(formatDate(period.getStart(), precision)).append(";"); } if (period.hasEnd()) { if (b.length() > 0) b.append(" "); b.append("end=").append(formatDate(period.getEnd(), precision)).append(";"); } if (period.hasName()) { b.append(" ").append("name=").append(period.getName().replace(";", "")).append(";"); } b.append(" ").append("scheme=W3C-DTF;"); return DublinCoreValue.mk(b.toString(), DublinCore.LANGUAGE_UNDEFINED, Opt.some(DublinCore.ENC_SCHEME_PERIOD)); } private  EncodingSchemeUtils(); static DublinCoreValue encodeDate(Date date, Precision precision); static String formatDate(Date date, Precision precision); static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision); static DublinCoreValue encodeDuration(long duration); static Long decodeDuration(String value); static Long decodeDuration(DublinCoreValue value); static Long decodeMandatoryDuration(String value); static Date decodeDate(DublinCoreValue value); static Date decodeDate(String value); static Date decodeMandatoryDate(DublinCoreValue value); static Date decodeMandatoryDate(String value); static DCMIPeriod decodePeriod(DublinCoreValue value); static DCMIPeriod decodePeriod(String value); static DCMIPeriod decodeMandatoryPeriod(DublinCoreValue value); static DCMIPeriod decodeMandatoryPeriod(String value); static Temporal decodeTemporal(DublinCoreValue value); static Temporal decodeMandatoryTemporal(DublinCoreValue value);  }