| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ModificationResult |
|
| 1.2;1.2 |
| 1 | package org.jaudiotagger.audio.asf.io; | |
| 2 | ||
| 3 | import org.jaudiotagger.audio.asf.data.GUID; | |
| 4 | ||
| 5 | import java.util.Arrays; | |
| 6 | import java.util.HashSet; | |
| 7 | import java.util.Set; | |
| 8 | ||
| 9 | /** | |
| 10 | * Structure to tell the differences occurred by altering a chunk. | |
| 11 | * | |
| 12 | * @author Christian Laireiter | |
| 13 | */ | |
| 14 | 4 | final class ModificationResult { |
| 15 | ||
| 16 | /** | |
| 17 | * Stores the difference of bytes.<br> | |
| 18 | */ | |
| 19 | private final long byteDifference; | |
| 20 | ||
| 21 | /** | |
| 22 | * Stores the difference of the amount of chunks.<br> | |
| 23 | * "-1" if the chunk disappeared upon modification.<br> | |
| 24 | * "0" if the chunk was just modified.<br> | |
| 25 | * "1" if a chunk has been created.<br> | |
| 26 | */ | |
| 27 | private final int chunkDifference; | |
| 28 | ||
| 29 | /** | |
| 30 | * Stores all GUIDs, which have been read.<br> | |
| 31 | */ | |
| 32 | 846 | private final Set<GUID> occuredGUIDs = new HashSet<GUID>(); |
| 33 | ||
| 34 | /** | |
| 35 | * Creates an instance.<br> | |
| 36 | * | |
| 37 | * @param chunkCountDiff | |
| 38 | * amount of chunks appeared, disappeared | |
| 39 | * @param bytesDiffer | |
| 40 | * amount of bytes added or removed. | |
| 41 | * @param occurred | |
| 42 | * all GUIDs which have been occurred, during processing | |
| 43 | */ | |
| 44 | public ModificationResult(final int chunkCountDiff, final long bytesDiffer, | |
| 45 | 697 | final GUID... occurred) { |
| 46 | 697 | assert occurred != null && occurred.length > 0; |
| 47 | 697 | this.chunkDifference = chunkCountDiff; |
| 48 | 697 | this.byteDifference = bytesDiffer; |
| 49 | 697 | this.occuredGUIDs.addAll(Arrays.asList(occurred)); |
| 50 | 697 | } |
| 51 | ||
| 52 | /** | |
| 53 | * Creates an instance.<br> | |
| 54 | * | |
| 55 | * @param chunkCountDiff | |
| 56 | * amount of chunks appeared, disappeared | |
| 57 | * @param bytesDiffer | |
| 58 | * amount of bytes added or removed. | |
| 59 | * @param occurred | |
| 60 | * all GUIDs which have been occurred, during processing | |
| 61 | */ | |
| 62 | public ModificationResult(final int chunkCountDiff, final long bytesDiffer, | |
| 63 | 149 | final Set<GUID> occurred) { |
| 64 | 149 | this.chunkDifference = chunkCountDiff; |
| 65 | 149 | this.byteDifference = bytesDiffer; |
| 66 | 149 | this.occuredGUIDs.addAll(occurred); |
| 67 | 149 | } |
| 68 | ||
| 69 | /** | |
| 70 | * Returns the difference of bytes. | |
| 71 | * | |
| 72 | * @return the byte difference | |
| 73 | */ | |
| 74 | public long getByteDifference() { | |
| 75 | 846 | return this.byteDifference; |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Returns the difference of the amount of chunks. | |
| 80 | * | |
| 81 | * @return the chunk count difference | |
| 82 | */ | |
| 83 | public int getChunkCountDifference() { | |
| 84 | 564 | return this.chunkDifference; |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Returns all GUIDs which have been occurred during processing. | |
| 89 | * | |
| 90 | * @return see description.s | |
| 91 | */ | |
| 92 | public Set<GUID> getOccuredGUIDs() { | |
| 93 | 282 | return new HashSet<GUID>(this.occuredGUIDs); |
| 94 | } | |
| 95 | ||
| 96 | } |