< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java

Print this page




  36  * frames of the audio data contained in the file, and the format of the audio
  37  * data.
  38  * <p>
  39  * The {@link AudioSystem} class includes methods for determining the format of
  40  * an audio file, obtaining an audio input stream from an audio file, and
  41  * writing an audio file from an audio input stream.
  42  * <p>
  43  * An {@code AudioFileFormat} object can include a set of properties. A property
  44  * is a pair of key and value: the key is of type {@code String}, the associated
  45  * property value is an arbitrary object. Properties specify additional
  46  * informational meta data (like a author, copyright, or file duration).
  47  * Properties are optional information, and file reader and file writer
  48  * implementations are not required to provide or recognize properties.
  49  * <p>
  50  * The following table lists some common properties that should be used in
  51  * implementations:
  52  *
  53  * <table border=1>
  54  *  <caption>Audio File Format Properties</caption>
  55  *  <tr>
  56  *   <th>Property key</th>
  57  *   <th>Value type</th>
  58  *   <th>Description</th>
  59  *  </tr>
  60  *  <tr>
  61  *   <td>&quot;duration&quot;</td>
  62  *   <td>{@link java.lang.Long Long}</td>
  63  *   <td>playback duration of the file in microseconds</td>
  64  *  </tr>
  65  *  <tr>
  66  *   <td>&quot;author&quot;</td>
  67  *   <td>{@link java.lang.String String}</td>
  68  *   <td>name of the author of this file</td>
  69  *  </tr>
  70  *  <tr>
  71  *   <td>&quot;title&quot;</td>
  72  *   <td>{@link java.lang.String String}</td>
  73  *   <td>title of this file</td>
  74  *  </tr>
  75  *  <tr>
  76  *   <td>&quot;copyright&quot;</td>
  77  *   <td>{@link java.lang.String String}</td>
  78  *   <td>copyright message</td>
  79  *  </tr>
  80  *  <tr>
  81  *   <td>&quot;date&quot;</td>
  82  *   <td>{@link java.util.Date Date}</td>
  83  *   <td>date of the recording or release</td>
  84  *  </tr>
  85  *  <tr>
  86  *   <td>&quot;comment&quot;</td>
  87  *   <td>{@link java.lang.String String}</td>
  88  *   <td>an arbitrary text</td>
  89  *  </tr>
  90  * </table>
  91  *
  92  *
  93  * @author David Rivas
  94  * @author Kara Kytle
  95  * @author Florian Bomers
  96  * @see AudioInputStream
  97  * @since 1.3
  98  */
  99 public class AudioFileFormat {
 100 
 101     /**
 102      * File type.
 103      */
 104     private final Type type;
 105 
 106     /**
 107      * File length in bytes.
 108      */
 109     private final int byteLength;
 110 
 111     /**
 112      * Format of the audio data contained in the file.


 334         private final String name;
 335 
 336         /**
 337          * File type extension.
 338          */
 339         private final String extension;
 340 
 341         /**
 342          * Constructs a file type.
 343          *
 344          * @param  name the string that names the file type
 345          * @param  extension the string that commonly marks the file type
 346          *         without leading dot
 347          */
 348         public Type(final String name, final String extension) {
 349             this.name = name;
 350             this.extension = extension;
 351         }
 352 
 353         /**
 354          * Finalizes the equals method.





 355          */
 356         @Override
 357         public final boolean equals(final Object obj) {
 358             if (this == obj) {
 359                 return true;
 360             }
 361             if (!(obj instanceof Type)) {
 362                 return false;
 363             }
 364             return Objects.equals(name, ((Type) obj).name);
 365         }
 366 
 367         /**
 368          * Finalizes the hashCode method.


 369          */
 370         @Override
 371         public final int hashCode() {
 372             return name != null ? name.hashCode() : 0;
 373         }
 374 
 375         /**
 376          * Provides the file type's name as the {@code String} representation of
 377          * the file type.
 378          *
 379          * @return the file type's name
 380          */
 381         @Override
 382         public final String toString() {
 383             return name;
 384         }
 385 
 386         /**
 387          * Obtains the common file name extension for this file type.
 388          *


  36  * frames of the audio data contained in the file, and the format of the audio
  37  * data.
  38  * <p>
  39  * The {@link AudioSystem} class includes methods for determining the format of
  40  * an audio file, obtaining an audio input stream from an audio file, and
  41  * writing an audio file from an audio input stream.
  42  * <p>
  43  * An {@code AudioFileFormat} object can include a set of properties. A property
  44  * is a pair of key and value: the key is of type {@code String}, the associated
  45  * property value is an arbitrary object. Properties specify additional
  46  * informational meta data (like a author, copyright, or file duration).
  47  * Properties are optional information, and file reader and file writer
  48  * implementations are not required to provide or recognize properties.
  49  * <p>
  50  * The following table lists some common properties that should be used in
  51  * implementations:
  52  *
  53  * <table border=1>
  54  * <caption>Audio File Format Properties</caption>
  55  *   <tr>
  56  *     <th>Property key
  57  *     <th>Value type
  58  *     <th>Description

  59  *   <tr>
  60  *     <td>&quot;duration&quot;
  61  *     <td>{@link Long Long}
  62  *     <td>playback duration of the file in microseconds

  63  *   <tr>
  64  *     <td>&quot;author&quot;
  65  *     <td>{@link String String}
  66  *     <td>name of the author of this file

  67  *   <tr>
  68  *     <td>&quot;title&quot;
  69  *     <td>{@link String String}
  70  *     <td>title of this file

  71  *   <tr>
  72  *     <td>&quot;copyright&quot;
  73  *     <td>{@link String String}
  74  *     <td>copyright message

  75  *   <tr>
  76  *     <td>&quot;date&quot;
  77  *     <td>{@link java.util.Date Date}
  78  *     <td>date of the recording or release

  79  *   <tr>
  80  *     <td>&quot;comment&quot;
  81  *     <td>{@link String String}
  82  *     <td>an arbitrary text

  83  * </table>
  84  *

  85  * @author David Rivas
  86  * @author Kara Kytle
  87  * @author Florian Bomers
  88  * @see AudioInputStream
  89  * @since 1.3
  90  */
  91 public class AudioFileFormat {
  92 
  93     /**
  94      * File type.
  95      */
  96     private final Type type;
  97 
  98     /**
  99      * File length in bytes.
 100      */
 101     private final int byteLength;
 102 
 103     /**
 104      * Format of the audio data contained in the file.


 326         private final String name;
 327 
 328         /**
 329          * File type extension.
 330          */
 331         private final String extension;
 332 
 333         /**
 334          * Constructs a file type.
 335          *
 336          * @param  name the string that names the file type
 337          * @param  extension the string that commonly marks the file type
 338          *         without leading dot
 339          */
 340         public Type(final String name, final String extension) {
 341             this.name = name;
 342             this.extension = extension;
 343         }
 344 
 345         /**
 346          * Indicates whether the specified object is equal to this file type,
 347          * returning {@code true} if the objects are the same.
 348          *
 349          * @param  obj the reference object with which to compare
 350          * @return {@code true} if this file type is the same as the {@code obj}
 351          *         argument; {@code false} otherwise
 352          */
 353         @Override
 354         public final boolean equals(final Object obj) {
 355             if (this == obj) {
 356                 return true;
 357             }
 358             if (!(obj instanceof Type)) {
 359                 return false;
 360             }
 361             return Objects.equals(name, ((Type) obj).name);
 362         }
 363 
 364         /**
 365          * Returns a hash code value for this file type.
 366          *
 367          * @return a hash code value for this file type
 368          */
 369         @Override
 370         public final int hashCode() {
 371             return name != null ? name.hashCode() : 0;
 372         }
 373 
 374         /**
 375          * Provides the file type's name as the {@code String} representation of
 376          * the file type.
 377          *
 378          * @return the file type's name
 379          */
 380         @Override
 381         public final String toString() {
 382             return name;
 383         }
 384 
 385         /**
 386          * Obtains the common file name extension for this file type.
 387          *
< prev index next >