163 * @param divisionType the timing division type (PPQ or one of the SMPTE
164 * types)
165 * @param resolution the timing resolution
166 * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if
167 * not known
168 * @param microseconds the duration of the file in microseconds, or
169 * UNKNOWN_LENGTH if not known
170 * @param properties a {@code Map<String,Object>} object with properties
171 * @see #UNKNOWN_LENGTH
172 * @see Sequence#PPQ
173 * @see Sequence#SMPTE_24
174 * @see Sequence#SMPTE_25
175 * @see Sequence#SMPTE_30DROP
176 * @see Sequence#SMPTE_30
177 * @since 1.5
178 */
179 public MidiFileFormat(int type, float divisionType,
180 int resolution, int bytes,
181 long microseconds, Map<String, Object> properties) {
182 this(type, divisionType, resolution, bytes, microseconds);
183 this.properties = new HashMap<String, Object>(properties);
184 }
185
186 /**
187 * Obtains the MIDI file type.
188 *
189 * @return the file's type (0, 1, or 2)
190 */
191 public int getType() {
192 return type;
193 }
194
195 /**
196 * Obtains the timing division type for the MIDI file.
197 *
198 * @return the division type (PPQ or one of the SMPTE types)
199 * @see Sequence#Sequence(float, int)
200 * @see Sequence#PPQ
201 * @see Sequence#SMPTE_24
202 * @see Sequence#SMPTE_25
203 * @see Sequence#SMPTE_30DROP
240 * @see #getByteLength
241 * @see #UNKNOWN_LENGTH
242 */
243 public long getMicrosecondLength() {
244 return microsecondLength;
245 }
246
247 /**
248 * Obtain an unmodifiable map of properties. The concept of properties is
249 * further explained in the {@link MidiFileFormat class description}.
250 *
251 * @return a {@code Map<String,Object>} object containing all properties. If
252 * no properties are recognized, an empty map is returned.
253 * @see #getProperty(String)
254 * @since 1.5
255 */
256 @SuppressWarnings("unchecked") // Cast of result of clone
257 public Map<String,Object> properties() {
258 Map<String,Object> ret;
259 if (properties == null) {
260 ret = new HashMap<String,Object>(0);
261 } else {
262 ret = (Map<String,Object>) (properties.clone());
263 }
264 return Collections.unmodifiableMap(ret);
265 }
266
267 /**
268 * Obtain the property value specified by the key. The concept of properties
269 * is further explained in the {@link MidiFileFormat class description}.
270 * <p>
271 * If the specified property is not defined for a particular file format,
272 * this method returns {@code null}.
273 *
274 * @param key the key of the desired property
275 * @return the value of the property with the specified key, or {@code null}
276 * if the property does not exist
277 * @see #properties()
278 * @since 1.5
279 */
280 public Object getProperty(String key) {
|
163 * @param divisionType the timing division type (PPQ or one of the SMPTE
164 * types)
165 * @param resolution the timing resolution
166 * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if
167 * not known
168 * @param microseconds the duration of the file in microseconds, or
169 * UNKNOWN_LENGTH if not known
170 * @param properties a {@code Map<String,Object>} object with properties
171 * @see #UNKNOWN_LENGTH
172 * @see Sequence#PPQ
173 * @see Sequence#SMPTE_24
174 * @see Sequence#SMPTE_25
175 * @see Sequence#SMPTE_30DROP
176 * @see Sequence#SMPTE_30
177 * @since 1.5
178 */
179 public MidiFileFormat(int type, float divisionType,
180 int resolution, int bytes,
181 long microseconds, Map<String, Object> properties) {
182 this(type, divisionType, resolution, bytes, microseconds);
183 this.properties = new HashMap<>(properties);
184 }
185
186 /**
187 * Obtains the MIDI file type.
188 *
189 * @return the file's type (0, 1, or 2)
190 */
191 public int getType() {
192 return type;
193 }
194
195 /**
196 * Obtains the timing division type for the MIDI file.
197 *
198 * @return the division type (PPQ or one of the SMPTE types)
199 * @see Sequence#Sequence(float, int)
200 * @see Sequence#PPQ
201 * @see Sequence#SMPTE_24
202 * @see Sequence#SMPTE_25
203 * @see Sequence#SMPTE_30DROP
240 * @see #getByteLength
241 * @see #UNKNOWN_LENGTH
242 */
243 public long getMicrosecondLength() {
244 return microsecondLength;
245 }
246
247 /**
248 * Obtain an unmodifiable map of properties. The concept of properties is
249 * further explained in the {@link MidiFileFormat class description}.
250 *
251 * @return a {@code Map<String,Object>} object containing all properties. If
252 * no properties are recognized, an empty map is returned.
253 * @see #getProperty(String)
254 * @since 1.5
255 */
256 @SuppressWarnings("unchecked") // Cast of result of clone
257 public Map<String,Object> properties() {
258 Map<String,Object> ret;
259 if (properties == null) {
260 ret = new HashMap<>(0);
261 } else {
262 ret = (Map<String,Object>) (properties.clone());
263 }
264 return Collections.unmodifiableMap(ret);
265 }
266
267 /**
268 * Obtain the property value specified by the key. The concept of properties
269 * is further explained in the {@link MidiFileFormat class description}.
270 * <p>
271 * If the specified property is not defined for a particular file format,
272 * this method returns {@code null}.
273 *
274 * @param key the key of the desired property
275 * @return the value of the property with the specified key, or {@code null}
276 * if the property does not exist
277 * @see #properties()
278 * @since 1.5
279 */
280 public Object getProperty(String key) {
|