2626package com .sandflow .smpte .mxf ;
2727
2828import com .sandflow .smpte .klv .KLVInputStream ;
29- import com .sandflow .smpte .klv .adapters .TripletValueAdapter ;
3029import com .sandflow .smpte .klv .exceptions .KLVException ;
31- import com .sandflow .smpte .util .AUID ;
3230import com .sandflow .smpte .util .IDAU ;
3331import com .sandflow .smpte .util .UMID ;
3432import com .sandflow .smpte .util .UUID ;
3735import java .io .InputStream ;
3836import java .util .ArrayList ;
3937import java .util .Collection ;
38+ import java .util .function .Function ;
4039
4140/**
4241 * MXFInputStream allows MXF data structures to be read from an InputStream
@@ -125,8 +124,8 @@ public UMID readUMID() throws IOException, EOFException {
125124 * @throws KLVException
126125 * @throws IOException
127126 */
128- public <T , W extends TripletValueAdapter > Collection <T > readArray () throws KLVException , IOException {
129- return readBatch ();
127+ public <T > Collection <T > readArray (Function < byte [], T > converter ) throws KLVException , IOException {
128+ return readBatch (converter );
130129 }
131130
132131 /**
@@ -138,7 +137,7 @@ public <T, W extends TripletValueAdapter> Collection<T> readArray() throws KLVEx
138137 * @throws KLVException
139138 * @throws IOException
140139 */
141- public <T , W extends TripletValueAdapter > Collection <T > readBatch () throws KLVException , IOException {
140+ public <T > Collection <T > readBatch (Function < byte [], T > converter ) throws KLVException , IOException {
142141 ArrayList <T > batch = new ArrayList <>();
143142 long itemcount = readUnsignedInt ();
144143 long itemlength = readUnsignedInt ();
@@ -148,7 +147,7 @@ public <T, W extends TripletValueAdapter> Collection<T> readBatch() throws KLVEx
148147 for (int i = 0 ; i < itemcount ; i ++) {
149148 byte [] value = new byte [(int ) itemlength ];
150149 read (value );
151- batch .add (W .< T > fromValue (value ));
150+ batch .add (converter . apply (value ));
152151 }
153152 return batch ;
154153 }
0 commit comments