/* neon - Embeddable HTTP Server based on jdk.httpserver Copyright (C) 2024 Ulrich Hilger This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package de.uhilger.neon; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Eine Gruppe aus Ranges * * @author Ulrich Hilger * @version 1, 11.06.2021 */ public class RangeGroup { private List ranges; private long totalSize; /** * Ein neues Objekt der Klasse RangeGroup erzeugen */ public RangeGroup() { ranges = new ArrayList(); } /** * Dieser RangeGroup eine Range hinzufuegen. * * @param range die Range, die dieser RangeGroup hinzugefuegt werden soll */ public void addRange(Range range) { ranges.add(range); totalSize += range.getEnd() - range.getStart(); } /** * Die Gesamtgröße dieser RangeGroup ermitteln, also die Summe * der Anzahl von Bytes aller ihrer Ranges. * * @return die Größe dieser RangeGroup in Bytes */ public long getSize() { return totalSize; } /** * Einen Iterator über die Ranges dieser RangeGroup abrufen * * @return Iterator über die Ranges dieser RangeGroup */ public Iterator getRanges() { return ranges.iterator(); } }