Class EncodingSchemeUtils
java.lang.Object
org.opencastproject.metadata.dublincore.EncodingSchemeUtils
Utility class to facilitate the work with DCMI encoding schemes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic DatedecodeDate(String value) Tries to decode the given value as a W3C-DTF encoded date.static DatedecodeDate(DublinCoreValue value) Tries to decode the given value as a W3C-DTF encoded date.static LongdecodeDuration(String value) Decode a string encoded in the ISO8601 encoding scheme.static LongdecodeDuration(DublinCoreValue value) Decode a string encoded in the ISO8601 encoding scheme.static DatedecodeMandatoryDate(String value) LikedecodeDate(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.static DateLikedecodeDate(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.static LongdecodeMandatoryDuration(String value) static DCMIPerioddecodeMandatoryPeriod(String value) LikedecodePeriod(DublinCoreValue), but throws anIllegalArgumentExceptionif the value cannot be decoded.static DCMIPeriodLikedecodePeriod(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.static TemporalLikedecodeTemporal(DublinCoreValue), but throws anIllegalArgumentExceptionif the value cannot be decoded.static DCMIPerioddecodePeriod(String value) Tries to decode a string in the DCMI period format, using W3C-DTF for the encoding of the individual dates.static DCMIPerioddecodePeriod(DublinCoreValue value) Tries to decode a string in the DCMI period format, using W3C-DTF for the encoding of the individual dates.static TemporaldecodeTemporal(DublinCoreValue value) Tries to decode the value to a temporal object.static DublinCoreValueencodeDate(Date date, Precision precision) Encode a date with the given precision into a Dublin Core string value, using the recommended W3C-DTF scheme.static DublinCoreValueencodeDuration(long duration) Encode a duration measured in milliseconds into a Dublin Core string using theDublinCore.ENC_SCHEME_ISO8601encoding schemePTnHnMnS.static DublinCoreValueencodePeriod(DCMIPeriod period, Precision precision) Encode a period with the given precision into a Dublin Core string value using the recommended DCMI Period scheme.static StringformatDate(Date date, Precision precision)
-
Method Details
-
encodeDate
Encode a date with the given precision into a Dublin Core string value, using the recommended W3C-DTF scheme. The UTC timezone is used for all precisions fromPrecision.MinutetoPrecision.Fraction. For years, months and days the local timezone is used instead to ensure that the given date enters the DublinCore as is. If UTC was used it may happen that you get the previous or next day, month or year respectivelyThe language of the returned value is
DublinCore.LANGUAGE_UNDEFINED.See http://www.w3.org/TR/NOTE-datetime for more information about W3C-DTF.
- Parameters:
date- the date to encodeprecision- the precision to use
-
formatDate
-
encodePeriod
Encode a period with the given precision into a Dublin Core string value using the recommended DCMI Period scheme. For the usage of the UTC timezone please refer toencodeDate(Date, Precision)for further information.One of the dates may be null to create an open interval.
The language of the returned value is
DublinCore.LANGUAGE_UNDEFINED.See http://dublincore.org/documents/dcmi-period/ for more information about DCMI Period.
- Parameters:
period- the periodprecision- the precision
-
encodeDuration
Encode a duration measured in milliseconds into a Dublin Core string using theDublinCore.ENC_SCHEME_ISO8601encoding schemePTnHnMnS.The language of the returned value is
DublinCore.LANGUAGE_UNDEFINED.See ISO8601 Durations for details.
- Parameters:
duration- the duration in milliseconds
-
decodeDuration
Decode a string encoded in the ISO8601 encoding scheme.Also supports the REPLAY legacy format
hh:mm:ss.See ISO8601 Durations for details.
- Parameters:
value- the ISO encoded string- Returns:
- the duration in milliseconds or null, if the value cannot be parsed
-
decodeDuration
Decode a string encoded in the ISO8601 encoding scheme.- Parameters:
value- the Dublin Core value- Returns:
- the duration in milliseconds or null, if the value cannot be parsed or is in a different encoding scheme
-
decodeMandatoryDuration
-
decodeDate
Tries to decode the given value as a W3C-DTF encoded date. If decoding fails, null is returned.- Returns:
- the date or null if decoding fails
-
decodeDate
Tries to decode the given value as a W3C-DTF encoded date. If decoding fails, null is returned.- Returns:
- the date or null if decoding fails
-
decodeMandatoryDate
LikedecodeDate(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.- Parameters:
value- the value- Returns:
- the date
- Throws:
IllegalArgumentException- if the value cannot be decoded
-
decodeMandatoryDate
LikedecodeDate(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.- Returns:
- the date
- Throws:
IllegalArgumentException- if the value cannot be decoded
-
decodePeriod
Tries to decode a string in the DCMI period format, using W3C-DTF for the encoding of the individual dates. If parsing fails at any point, null will be returned.- Returns:
- the period or null if decoding fails
-
decodePeriod
Tries to decode a string in the DCMI period format, using W3C-DTF for the encoding of the individual dates. If parsing fails at any point, null will be returned.- Returns:
- the period or null if decoding fails
-
decodeMandatoryPeriod
LikedecodePeriod(String), but throws anIllegalArgumentExceptionif the value cannot be decoded.- Returns:
- the period
- Throws:
IllegalArgumentException- if the value cannot be decoded
-
decodeMandatoryPeriod
LikedecodePeriod(DublinCoreValue), but throws anIllegalArgumentExceptionif the value cannot be decoded.- Returns:
- the period
- Throws:
IllegalArgumentException- if the value cannot be decoded
-
decodeTemporal
Tries to decode the value to a temporal object. For now, supported types areDate,DCMIPeriodand Long for a duration.- Parameters:
value- the value to decode- Returns:
- a temporal object of the said types or null if decoding fails
-
decodeMandatoryTemporal
LikedecodeTemporal(DublinCoreValue), but throws anIllegalArgumentExceptionif the value cannot be decoded.- Returns:
- the temporal object of type
DateorDCMIPeriod - Throws:
IllegalArgumentException- if the value cannot be decoded
-