From f42a18875b8a115fb6c43a44847e5e594c58cf4d Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 2 Jan 2024 14:13:35 +0100 Subject: [PATCH] Improve documentation --- .../kitodo/api/dataformat/MediaPartialView.java | 17 +++++++++++++++++ .../helper/metadata/MediaPartialHelper.java | 9 +++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaPartialView.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaPartialView.java index b78d1bdbfb1..6502040fe26 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaPartialView.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaPartialView.java @@ -19,10 +19,27 @@ public class MediaPartialView extends View { private String extent; + /** + * Constructs a media partial view object. + * + * @param begin + * The begin as formatted time in form of + * {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN} + */ public MediaPartialView(String begin) { this.begin = begin; } + /** + * Constructs a media partial view object. + * + * @param begin + * The begin as formatted time in form of + * {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN} + * @param extent + * The extent as formatted time in form of + * {@link org.kitodo.production.helper.metadata.MediaPartialHelper#FORMATTED_TIME_PATTERN} + */ public MediaPartialView(String begin, String extent) { this(begin); this.extent = extent; diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/MediaPartialHelper.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/MediaPartialHelper.java index 7918667e658..4d0d02fbc3a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/MediaPartialHelper.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/MediaPartialHelper.java @@ -29,7 +29,7 @@ public class MediaPartialHelper { public static final Pattern FORMATTED_TIME_PATTERN = Pattern.compile("([0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}"); - private static final MediaPartialLogicalDivisionComparator mediaPartialLogicalDivisionComparator = new MediaPartialLogicalDivisionComparator(); + private static final MediaPartialLogicalDivisionComparator logicalDivisionComparator = new MediaPartialLogicalDivisionComparator(); /** * Convert formatted time to milliseconds. @@ -65,7 +65,7 @@ public static String convertMillisecondsToFormattedTime(Long milliseconds) { */ public static void calculateExtentAndSortMediaPartials(List logicalDivisions, Long mediaDuration) { calculateExtentForMediaPartials(logicalDivisions, mediaDuration); - logicalDivisions.sort(mediaPartialLogicalDivisionComparator); + logicalDivisions.sort(logicalDivisionComparator); } /** @@ -81,7 +81,7 @@ public static void calculateExtentAndSortMediaPartials(List log */ private static void calculateExtentForMediaPartials(List logicalDivisions, Long mediaDuration) { // sorting reverse by begin - logicalDivisions.sort(mediaPartialLogicalDivisionComparator.reversed()); + logicalDivisions.sort(logicalDivisionComparator.reversed()); ListIterator iterator = logicalDivisions.listIterator(); LogicalDivision previousLogicalDivision = null; @@ -97,7 +97,8 @@ private static void calculateExtentForMediaPartials(List logica long previousBegin = convertFormattedTimeToMilliseconds( previousPhysicalDivision.getMediaPartialView().getBegin()); long currentBegin = convertFormattedTimeToMilliseconds(mediaPartialView.getBegin()); - mediaPartialView.setExtent(convertMillisecondsToFormattedTime(previousBegin - currentBegin)); + String extent = convertMillisecondsToFormattedTime(previousBegin - currentBegin); + mediaPartialView.setExtent(extent); } } else { // calculate the duration of media partial to the end of media