255 * @return the value of the property with the specified key, or {@code null}
256 * if the property does not exist
257 * @see #properties()
258 * @since 1.5
259 */
260 public Object getProperty(String key) {
261 if (properties == null) {
262 return null;
263 }
264 return properties.get(key);
265 }
266
267 /**
268 * Provides a string representation of the file format.
269 *
270 * @return the file format as a string
271 */
272 @Override
273 public String toString() {
274
275 StringBuffer buf = new StringBuffer();
276
277 //$$fb2002-11-01: fix for 4672864: AudioFileFormat.toString() throws unexpected NullPointerException
278 if (type != null) {
279 buf.append(type.toString() + " (." + type.getExtension() + ") file");
280 } else {
281 buf.append("unknown file format");
282 }
283
284 if (byteLength != AudioSystem.NOT_SPECIFIED) {
285 buf.append(", byte length: " + byteLength);
286 }
287
288 buf.append(", data format: " + format);
289
290 if (frameLength != AudioSystem.NOT_SPECIFIED) {
291 buf.append(", frame length: " + frameLength);
292 }
293
294 return new String(buf);
295 }
296
297 /**
298 * An instance of the {@code Type} class represents one of the standard
299 * types of audio file. Static instances are provided for the common types.
300 */
301 public static class Type {
302
303 // FILE FORMAT TYPE DEFINES
304
305 /**
306 * Specifies a WAVE file.
307 */
308 public static final Type WAVE = new Type("WAVE", "wav");
309
310 /**
311 * Specifies an AU file.
312 */
313 public static final Type AU = new Type("AU", "au");
314
|
255 * @return the value of the property with the specified key, or {@code null}
256 * if the property does not exist
257 * @see #properties()
258 * @since 1.5
259 */
260 public Object getProperty(String key) {
261 if (properties == null) {
262 return null;
263 }
264 return properties.get(key);
265 }
266
267 /**
268 * Provides a string representation of the file format.
269 *
270 * @return the file format as a string
271 */
272 @Override
273 public String toString() {
274
275 StringBuilder sb = new StringBuilder();
276
277 //$$fb2002-11-01: fix for 4672864: AudioFileFormat.toString() throws unexpected NullPointerException
278 if (type != null) {
279 sb.append(type).append(" (.").append(type.getExtension()).append(") file");
280 } else {
281 sb.append("unknown file format");
282 }
283
284 if (byteLength != AudioSystem.NOT_SPECIFIED) {
285 sb.append(", byte length: ").append(byteLength);
286 }
287
288 sb.append(", data format: ").append(format);
289
290 if (frameLength != AudioSystem.NOT_SPECIFIED) {
291 sb.append(", frame length: ").append(frameLength);
292 }
293 return sb.toString();
294 }
295
296 /**
297 * An instance of the {@code Type} class represents one of the standard
298 * types of audio file. Static instances are provided for the common types.
299 */
300 public static class Type {
301
302 // FILE FORMAT TYPE DEFINES
303
304 /**
305 * Specifies a WAVE file.
306 */
307 public static final Type WAVE = new Type("WAVE", "wav");
308
309 /**
310 * Specifies an AU file.
311 */
312 public static final Type AU = new Type("AU", "au");
313
|