View Javadoc

1   /*
2    * Entagged Audio Tag library
3    * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
4    * 
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *  
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   * 
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18   */
19  package entagged.audioformats.asf.data;
20  
21  import java.math.BigInteger;
22  import java.util.ArrayList;
23  import java.util.Collection;
24  import java.util.Iterator;
25  
26  import entagged.audioformats.asf.util.Utils;
27  
28  /***
29   * This class was intended to store the data of a chunk which contained the
30   * encoding parameters in textual form. <br>
31   * Since the needed parameters were found in other chunks the implementation of
32   * this class was paused. <br>
33   * TODO complete analysis. 
34   * 
35   * @author Christian Laireiter
36   */
37  public class EncodingChunk extends Chunk {
38  
39  	/***
40  	 * The read strings.
41  	 */
42  	private final ArrayList strings;
43  
44  	/***
45  	 * Creates an instance.
46  	 * 
47  	 * @param pos
48  	 *                  Position of the chunk within file or stream
49  	 * @param chunkLen
50  	 *                  Length of current chunk.
51  	 */
52  	public EncodingChunk(long pos, BigInteger chunkLen) {
53  		super(GUID.GUID_ENCODING, pos, chunkLen);
54  		this.strings = new ArrayList();
55  	}
56  
57  	/***
58  	 * This method appends a String.
59  	 * 
60  	 * @param toAdd
61  	 *                  String to add.
62  	 */
63  	public void addString(String toAdd) {
64  		strings.add(toAdd);
65  	}
66  
67  	/***
68  	 * This method returns a collection of all {@link String}s which were addid
69  	 * due {@link #addString(String)}.
70  	 * 
71  	 * @return Inserted Strings.
72  	 */
73  	public Collection getStrings() {
74  		return new ArrayList(strings);
75  	}
76  
77  	/***
78  	 * (overridden)
79  	 * 
80  	 * @see entagged.audioformats.asf.data.Chunk#prettyPrint()
81  	 */
82  	public String prettyPrint() {
83  		StringBuffer result = new StringBuffer(super.prettyPrint());
84  		result.insert(0, Utils.LINE_SEPARATOR + "Encoding:"
85  				+ Utils.LINE_SEPARATOR);
86  		Iterator iterator = this.strings.iterator();
87  		while (iterator.hasNext()) {
88  			result.append("   " + iterator.next() + Utils.LINE_SEPARATOR);
89  		}
90  		return result.toString();
91  	}
92  }