83 * </tr>
84 * <tr>
85 * <td>"comment"</td>
86 * <td>{@link java.lang.String String}</td>
87 * <td>an arbitrary text</td>
88 * </tr>
89 * </table>
90 *
91 *
92 * @author David Rivas
93 * @author Kara Kytle
94 * @author Florian Bomers
95 * @see AudioInputStream
96 * @since 1.3
97 */
98 public class AudioFileFormat {
99
100 /**
101 * File type.
102 */
103 private Type type;
104
105 /**
106 * File length in bytes.
107 */
108 private int byteLength;
109
110 /**
111 * Format of the audio data contained in the file.
112 */
113 private AudioFormat format;
114
115 /**
116 * Audio data length in sample frames.
117 */
118 private int frameLength;
119
120 /**
121 * The set of properties.
122 */
123 private HashMap<String, Object> properties;
124
125 /**
126 * Constructs an audio file format object. This protected constructor is
127 * intended for use by providers of file-reading services when returning
128 * information about an audio file or about supported audio file formats.
129 *
130 * @param type the type of the audio file
131 * @param byteLength the length of the file in bytes, or
132 * {@code AudioSystem.NOT_SPECIFIED}
133 * @param format the format of the audio data contained in the file
134 * @param frameLength the audio data length in sample frames, or
135 * {@code AudioSystem.NOT_SPECIFIED}
136 * @see #getType
137 */
138 protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
159
160 this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
161 }
162
163 /**
164 * Construct an audio file format object with a set of defined properties.
165 * This public constructor may be used by applications to describe the
166 * properties of a requested audio file. The properties map will be copied
167 * to prevent any changes to it.
168 *
169 * @param type the type of the audio file
170 * @param format the format of the audio data contained in the file
171 * @param frameLength the audio data length in sample frames, or
172 * {@code AudioSystem.NOT_SPECIFIED}
173 * @param properties a {@code Map<String, Object>} object with properties
174 * @since 1.5
175 */
176 public AudioFileFormat(Type type, AudioFormat format,
177 int frameLength, Map<String, Object> properties) {
178 this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
179 this.properties = new HashMap<String, Object>(properties);
180 }
181
182 /**
183 * Obtains the audio file type, such as {@code WAVE} or {@code AU}.
184 *
185 * @return the audio file type
186 * @see Type#WAVE
187 * @see Type#AU
188 * @see Type#AIFF
189 * @see Type#AIFC
190 * @see Type#SND
191 */
192 public Type getType() {
193 return type;
194 }
195
196 /**
197 * Obtains the size in bytes of the entire audio file (not just its audio
198 * data).
199 *
|
83 * </tr>
84 * <tr>
85 * <td>"comment"</td>
86 * <td>{@link java.lang.String String}</td>
87 * <td>an arbitrary text</td>
88 * </tr>
89 * </table>
90 *
91 *
92 * @author David Rivas
93 * @author Kara Kytle
94 * @author Florian Bomers
95 * @see AudioInputStream
96 * @since 1.3
97 */
98 public class AudioFileFormat {
99
100 /**
101 * File type.
102 */
103 private final Type type;
104
105 /**
106 * File length in bytes.
107 */
108 private final int byteLength;
109
110 /**
111 * Format of the audio data contained in the file.
112 */
113 private final AudioFormat format;
114
115 /**
116 * Audio data length in sample frames.
117 */
118 private final int frameLength;
119
120 /**
121 * The set of properties.
122 */
123 private HashMap<String, Object> properties;
124
125 /**
126 * Constructs an audio file format object. This protected constructor is
127 * intended for use by providers of file-reading services when returning
128 * information about an audio file or about supported audio file formats.
129 *
130 * @param type the type of the audio file
131 * @param byteLength the length of the file in bytes, or
132 * {@code AudioSystem.NOT_SPECIFIED}
133 * @param format the format of the audio data contained in the file
134 * @param frameLength the audio data length in sample frames, or
135 * {@code AudioSystem.NOT_SPECIFIED}
136 * @see #getType
137 */
138 protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
159
160 this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
161 }
162
163 /**
164 * Construct an audio file format object with a set of defined properties.
165 * This public constructor may be used by applications to describe the
166 * properties of a requested audio file. The properties map will be copied
167 * to prevent any changes to it.
168 *
169 * @param type the type of the audio file
170 * @param format the format of the audio data contained in the file
171 * @param frameLength the audio data length in sample frames, or
172 * {@code AudioSystem.NOT_SPECIFIED}
173 * @param properties a {@code Map<String, Object>} object with properties
174 * @since 1.5
175 */
176 public AudioFileFormat(Type type, AudioFormat format,
177 int frameLength, Map<String, Object> properties) {
178 this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
179 this.properties = new HashMap<>(properties);
180 }
181
182 /**
183 * Obtains the audio file type, such as {@code WAVE} or {@code AU}.
184 *
185 * @return the audio file type
186 * @see Type#WAVE
187 * @see Type#AU
188 * @see Type#AIFF
189 * @see Type#AIFC
190 * @see Type#SND
191 */
192 public Type getType() {
193 return type;
194 }
195
196 /**
197 * Obtains the size in bytes of the entire audio file (not just its audio
198 * data).
199 *
|