Skip to content

Commit

Permalink
modernize usage of collection templates
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jul 12, 2024
1 parent b715db3 commit 8c8f1d7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion library/src/main/java/de/jarnbjo/flac/FlacStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class FlacStream {
private LogicalOggStream oggStream;

final private List metadataBlocks = new ArrayList();
final private List<MetadataBlock> metadataBlocks = new ArrayList<>();

private StreamInfo streamInfo;
private VorbisComment vorbisComment;
Expand Down
15 changes: 7 additions & 8 deletions library/src/main/java/de/jarnbjo/flac/VorbisComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class VorbisComment extends MetadataBlock {
public static final String ISRC = "ISRC";

final private String vendor;
final private HashMap comments = new HashMap();
final private HashMap<String, ArrayList<String>> comments = new HashMap<>();

public VorbisComment(BitInputStream source) throws IOException {
int length = source.getInt(24);
Expand All @@ -48,9 +48,9 @@ public VorbisComment(BitInputStream source) throws IOException {
private void addComment(String key, String value) {
System.out.println(key + " = " + value);

ArrayList al = (ArrayList) comments.get(key);
ArrayList<String> al = comments.get(key);
if (al == null) {
al = new ArrayList();
al = new ArrayList<>();
comments.put(key, al);
}
al.add(value);
Expand All @@ -61,14 +61,13 @@ public String getVendor() {
}

public String getComment(String key) {
ArrayList al = (ArrayList) comments.get(key);
return al == null ? null : (String) al.get(0);
ArrayList<String> al = comments.get(key);
return al == null ? null : al.get(0);
}

public String[] getComments(String key) {
ArrayList al = (ArrayList) comments.get(key);
return al == null ? new String[0]
: (String[]) al.toArray(new String[al.size()]);
ArrayList<String> al = comments.get(key);
return al == null ? new String[0] : al.toArray(new String[0]);
}

public String getTitle() {
Expand Down
5 changes: 3 additions & 2 deletions library/src/main/java/de/jarnbjo/jmf/OggJmfStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class OggJmfStream implements PhysicalOggStream {
final private PullSourceStream source;
final private long[] pageOffsets;

final private HashMap logicalStreams = new HashMap();
final private HashMap<Integer, LogicalOggStreamImpl> logicalStreams
= new HashMap<>();

/**
* Creates access to the specified {@code PullSourceStream} through the
Expand All @@ -68,7 +69,7 @@ public OggJmfStream(PullSourceStream source)
throw new OggFormatException("The source stream must be seekable.");
}

List po = new ArrayList();
List<Long> po = new ArrayList<>();
int pageNumber = 0;
try {
while (true) {
Expand Down
4 changes: 2 additions & 2 deletions vorbis/src/main/java/de/jarnbjo/ogg/LogicalOggStreamImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class LogicalOggStreamImpl implements LogicalOggStream {
final private PhysicalOggStream source;
final private int serialNumber;

final private ArrayList pageNumberMapping = new ArrayList();
final private ArrayList granulePositions = new ArrayList();
final private ArrayList<Integer> pageNumberMapping = new ArrayList<>();
final private ArrayList<Long> granulePositions = new ArrayList<>();

private int pageIndex = 0;
private OggPage currentPage;
Expand Down
15 changes: 7 additions & 8 deletions vorbis/src/main/java/de/jarnbjo/vorbis/CommentHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class CommentHeader {
= "METADATA_BLOCK_PICTURE";

final private String vendor;
final private HashMap comments = new HashMap();
final private HashMap<String, ArrayList<String>> comments = new HashMap<>();
private boolean framingBit;

private static final long HEADER = 0x736962726f76L; // 'vorbis'
Expand Down Expand Up @@ -101,9 +101,9 @@ public static String byteBufferToString(
}

private void addComment(String key, String value) {
ArrayList al = (ArrayList) comments.get(key);
ArrayList<String> al = comments.get(key);
if (al == null) {
al = new ArrayList();
al = new ArrayList<>();
comments.put(key, al);
}
al.add(value);
Expand All @@ -114,14 +114,13 @@ public String getVendor() {
}

public String getComment(String key) {
ArrayList al = (ArrayList) comments.get(key);
return al == null ? null : (String) al.get(0);
ArrayList<String> al = comments.get(key);
return al == null ? null : al.get(0);
}

public String[] getComments(String key) {
ArrayList al = (ArrayList) comments.get(key);
return al == null ? new String[0]
: (String[]) al.toArray(new String[al.size()]);
ArrayList<String> al = comments.get(key);
return al == null ? new String[0] : al.toArray(new String[0]);
}

public String getTitle() {
Expand Down
2 changes: 1 addition & 1 deletion vorbis/src/main/java/de/jarnbjo/vorbis/Floor1.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected Floor1(BitInputStream source, SetupHeader header)

int floorValues = 0;

List alXList = new ArrayList();
List<Integer> alXList = new ArrayList<>();

alXList.add(0);
alXList.add(1 << rangeBits);
Expand Down
2 changes: 1 addition & 1 deletion vorbis/src/main/java/de/jarnbjo/vorbis/Residue.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class Residue {
protected int classBook; // groupbook
protected int[] cascade; // secondstages
protected int[][] books;
protected HashMap looks = new HashMap();
protected HashMap<Mode, Look> looks = new HashMap<>();

protected Residue() {
}
Expand Down

0 comments on commit 8c8f1d7

Please sign in to comment.