View Javadoc

1   /**
2    * JSpiff
3    * -----------------
4    * Copyright (c) 2005-2006 Emil A. Lefkof III
5    *
6    * I always give it my best shot to make a program useful and solid, but
7    * remeber that there is absolutely no warranty for using this program as
8    * stated in the following terms:
9    *
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   *
14   *     http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   */
22  package com.melloware.jspiff.jaxp;
23  
24  import java.io.File;
25  import java.io.IOException;
26  import java.io.InputStream;
27  import java.io.PrintWriter;
28  import java.io.Reader;
29  import java.io.Writer;
30  import java.net.URL;
31  
32  import javax.xml.parsers.ParserConfigurationException;
33  
34  import org.w3c.dom.Document;
35  import org.w3c.dom.Element;
36  import org.w3c.dom.Node;
37  import org.xml.sax.InputSource;
38  import org.xml.sax.SAXException;
39  
40  /**
41   * <b>XspfTrack</b> is generated from xspf.rng by Relaxer.
42   * This class is derived from:
43   *
44   * <!-- for programmer
45   * <element name="track">
46   *             <zeroOrMore>
47   *                 <element name="location">
48   *                     <data type="anyURI"/>
49   *                 </element>
50   *             </zeroOrMore>
51   *             <zeroOrMore>
52   *                 <element name="identifier">
53   *                     <data type="anyURI"/>
54   *                 </element>
55   *             </zeroOrMore>
56   *
57   *             <optional>
58   *                 <element name="title">
59   *                     <text/>
60   *                 </element>
61   *             </optional>
62   *             <optional>
63   *                 <element name="creator">
64   *                     <text/>
65   *                 </element>
66   *             </optional>
67   *             <optional>
68   *                 <element name="annotation">
69   *                     <text/>
70   *                 </element>
71   *             </optional>
72   *             <optional>
73   *                 <element name="info">
74   *                     <text/>
75   *                 </element>
76   *             </optional>
77   *             <optional>
78   *                 <element name="image">
79   *                     <data type="anyURI"/>
80   *                 </element>
81   *             </optional>
82   *             <optional>
83   *                 <element name="album">
84   *                     <text/>
85   *                 </element>
86   *             </optional>
87   *             <optional>
88   *                 <element name="trackNum">
89   *                     <data type="nonNegativeInteger"/>
90   *                 </element>
91   *             </optional>
92   *             <optional>
93   *                 <element name="duration">
94   *                     <data type="nonNegativeInteger"/>
95   *                 </element>
96   *             </optional>
97   *
98   *             <zeroOrMore>
99   *                 <ref name="link"/>
100  *             </zeroOrMore>
101  *             <zeroOrMore>
102  *                 <ref name="meta"/>
103  *             </zeroOrMore>
104  *             <zeroOrMore>
105  *                 <ref name="extension"/>
106  *             </zeroOrMore>
107  *         </element>-->
108  * <!-- for javadoc -->
109  * <pre> &lt;element name="track"&gt;
110  *             &lt;zeroOrMore&gt;
111  *                 &lt;element name="location"&gt;
112  *                     &lt;data type="anyURI"/&gt;
113  *                 &lt;/element&gt;
114  *             &lt;/zeroOrMore&gt;
115  *             &lt;zeroOrMore&gt;
116  *                 &lt;element name="identifier"&gt;
117  *                     &lt;data type="anyURI"/&gt;
118  *                 &lt;/element&gt;
119  *             &lt;/zeroOrMore&gt;
120  *
121  *             &lt;optional&gt;
122  *                 &lt;element name="title"&gt;
123  *                     &lt;text/&gt;
124  *                 &lt;/element&gt;
125  *             &lt;/optional&gt;
126  *             &lt;optional&gt;
127  *                 &lt;element name="creator"&gt;
128  *                     &lt;text/&gt;
129  *                 &lt;/element&gt;
130  *             &lt;/optional&gt;
131  *             &lt;optional&gt;
132  *                 &lt;element name="annotation"&gt;
133  *                     &lt;text/&gt;
134  *                 &lt;/element&gt;
135  *             &lt;/optional&gt;
136  *             &lt;optional&gt;
137  *                 &lt;element name="info"&gt;
138  *                     &lt;text/&gt;
139  *                 &lt;/element&gt;
140  *             &lt;/optional&gt;
141  *             &lt;optional&gt;
142  *                 &lt;element name="image"&gt;
143  *                     &lt;data type="anyURI"/&gt;
144  *                 &lt;/element&gt;
145  *             &lt;/optional&gt;
146  *             &lt;optional&gt;
147  *                 &lt;element name="album"&gt;
148  *                     &lt;text/&gt;
149  *                 &lt;/element&gt;
150  *             &lt;/optional&gt;
151  *             &lt;optional&gt;
152  *                 &lt;element name="trackNum"&gt;
153  *                     &lt;data type="nonNegativeInteger"/&gt;
154  *                 &lt;/element&gt;
155  *             &lt;/optional&gt;
156  *             &lt;optional&gt;
157  *                 &lt;element name="duration"&gt;
158  *                     &lt;data type="nonNegativeInteger"/&gt;
159  *                 &lt;/element&gt;
160  *             &lt;/optional&gt;
161  *
162  *             &lt;zeroOrMore&gt;
163  *                 &lt;ref name="link"/&gt;
164  *             &lt;/zeroOrMore&gt;
165  *             &lt;zeroOrMore&gt;
166  *                 &lt;ref name="meta"/&gt;
167  *             &lt;/zeroOrMore&gt;
168  *             &lt;zeroOrMore&gt;
169  *                 &lt;ref name="extension"/&gt;
170  *             &lt;/zeroOrMore&gt;
171  *         &lt;/element&gt;</pre>
172  *
173  * @version xspf.rng (Wed Sep 27 17:36:25 EDT 2006)
174  * @author  Relaxer 1.1b (http://www.relaxer.org)
175  * @author Emil A. Lefkof III <info@melloware.com>
176  */
177 public class XspfTrack
178     implements java.io.Serializable,
179                Cloneable {
180 	
181     private java.math.BigInteger duration_;
182     private java.math.BigInteger trackNum_;
183     // List<XspfExtension>
184     private java.util.List extension_ = new java.util.ArrayList();
185     // List<String>
186     private java.util.List identifier_ = new java.util.ArrayList();
187     // List<XspfLink>
188     private java.util.List link_ = new java.util.ArrayList();
189     // List<String>
190     private java.util.List location_ = new java.util.ArrayList();
191     // List<XspfMeta>
192     private java.util.List meta_ = new java.util.ArrayList();
193     private String album_;
194     private String annotation_;
195     private String creator_;
196     private String image_;
197     private String info_;
198     private String title_;
199 
200     /**
201      * Creates a <code>XspfTrack</code>.
202      *
203      */
204     public XspfTrack() {
205     }
206 
207     /**
208      * Creates a <code>XspfTrack</code>.
209      *
210      * @param source
211      */
212     public XspfTrack(XspfTrack source) {
213         setup(source);
214     }
215 
216     /**
217      * Creates a <code>XspfTrack</code> by the Stack <code>stack</code>
218      * that contains Elements.
219      * This constructor is supposed to be used internally
220      * by the Relaxer system.
221      *
222      * @param stack
223      */
224     public XspfTrack(RStack stack) {
225         setup(stack);
226     }
227 
228     /**
229      * Creates a <code>XspfTrack</code> by the Document <code>doc</code>.
230      *
231      * @param doc
232      */
233     public XspfTrack(Document doc) {
234         setup(doc.getDocumentElement());
235     }
236 
237     /**
238      * Creates a <code>XspfTrack</code> by the Element <code>element</code>.
239      *
240      * @param element
241      */
242     public XspfTrack(Element element) {
243         setup(element);
244     }
245 
246     /**
247      * Creates a <code>XspfTrack</code> by the File <code>file</code>.
248      *
249      * @param file
250      * @exception IOException
251      * @exception SAXException
252      * @exception ParserConfigurationException
253      */
254     public XspfTrack(File file)
255               throws IOException, SAXException, ParserConfigurationException {
256         setup(file);
257     }
258 
259     /**
260      * Creates a <code>XspfTrack</code>
261      * by the String representation of URI <code>uri</code>.
262      *
263      * @param uri
264      * @exception IOException
265      * @exception SAXException
266      * @exception ParserConfigurationException
267      */
268     public XspfTrack(String uri)
269               throws IOException, SAXException, ParserConfigurationException {
270         setup(uri);
271     }
272 
273     /**
274      * Creates a <code>XspfTrack</code> by the URL <code>url</code>.
275      *
276      * @param url
277      * @exception IOException
278      * @exception SAXException
279      * @exception ParserConfigurationException
280      */
281     public XspfTrack(URL url)
282               throws IOException, SAXException, ParserConfigurationException {
283         setup(url);
284     }
285 
286     /**
287      * Creates a <code>XspfTrack</code> by the InputStream <code>in</code>.
288      *
289      * @param in
290      * @exception IOException
291      * @exception SAXException
292      * @exception ParserConfigurationException
293      */
294     public XspfTrack(InputStream in)
295               throws IOException, SAXException, ParserConfigurationException {
296         setup(in);
297     }
298 
299     /**
300      * Creates a <code>XspfTrack</code> by the InputSource <code>is</code>.
301      *
302      * @param is
303      * @exception IOException
304      * @exception SAXException
305      * @exception ParserConfigurationException
306      */
307     public XspfTrack(InputSource is)
308               throws IOException, SAXException, ParserConfigurationException {
309         setup(is);
310     }
311 
312     /**
313      * Creates a <code>XspfTrack</code> by the Reader <code>reader</code>.
314      *
315      * @param reader
316      * @exception IOException
317      * @exception SAXException
318      * @exception ParserConfigurationException
319      */
320     public XspfTrack(Reader reader)
321               throws IOException, SAXException, ParserConfigurationException {
322         setup(reader);
323     }
324 
325     /**
326      * Tests if a Element <code>element</code> is valid
327      * for the <code>XspfTrack</code>.
328      *
329      * @param element
330      * @return boolean
331      */
332     public static boolean isMatch(Element element) {
333     	if (!URelaxer.isTargetElement(element, "track")) {
334             return (false);
335         }
336         RStack target = new RStack(element);
337         Element child;
338         while ((child = target.peekElement()) != null) {
339             if (!URelaxer.isTargetElement(child, "location")) {
340                 break;
341             }
342             target.popElement();
343         }
344         while ((child = target.peekElement()) != null) {
345             if (!URelaxer.isTargetElement(child, "identifier")) {
346                 break;
347             }
348             target.popElement();
349         }
350         child = target.peekElement();
351         if (child != null) {
352             if (URelaxer.isTargetElement(child, "title")) {
353                 target.popElement();
354             }
355         }
356         child = target.peekElement();
357         if (child != null) {
358             if (URelaxer.isTargetElement(child, "creator")) {
359                 target.popElement();
360             }
361         }
362         child = target.peekElement();
363         if (child != null) {
364             if (URelaxer.isTargetElement(child, "annotation")) {
365                 target.popElement();
366             }
367         }
368         child = target.peekElement();
369         if (child != null) {
370             if (URelaxer.isTargetElement(child, "info")) {
371                 target.popElement();
372             }
373         }
374         child = target.peekElement();
375         if (child != null) {
376             if (URelaxer.isTargetElement(child, "image")) {
377                 target.popElement();
378             }
379         }
380         child = target.peekElement();
381         if (child != null) {
382             if (URelaxer.isTargetElement(child, "album")) {
383                 target.popElement();
384             }
385         }
386         child = target.peekElement();
387         if (child != null) {
388             if (URelaxer.isTargetElement(child, "trackNum")) {
389                 target.popElement();
390             }
391         }
392         child = target.peekElement();
393         if (child != null) {
394             if (URelaxer.isTargetElement(child, "duration")) {
395                 target.popElement();
396             }
397         }
398         while (true) {
399             if (!XspfLink.isMatchHungry(target)) {
400                 break;
401             }
402         }
403         while (true) {
404             if (!XspfMeta.isMatchHungry(target)) {
405                 break;
406             }
407         }
408         while (true) {
409             if (!XspfExtension.isMatchHungry(target)) {
410                 break;
411             }
412         }
413         if (!target.isEmptyElement()) {
414             return (false);
415         }
416         return (true);
417     }
418 
419     /**
420      * Tests if elements contained in a Stack <code>stack</code>
421      * is valid for the <code>XspfTrack</code>.
422      * This mehtod is supposed to be used internally
423      * by the Relaxer system.
424      *
425      * @param stack
426      * @return boolean
427      */
428     public static boolean isMatch(RStack stack) {
429         Element element = stack.peekElement();
430         if (element == null) {
431             return (false);
432         }
433         return (isMatch(element));
434     }
435 
436     /**
437      * Tests if elements contained in a Stack <code>stack</code>
438      * is valid for the <code>XspfTrack</code>.
439      * This method consumes the stack contents during matching operation.
440      * This mehtod is supposed to be used internally
441      * by the Relaxer system.
442      *
443      * @param stack
444      * @return boolean
445      */
446     public static boolean isMatchHungry(RStack stack) {
447         Element element = stack.peekElement();
448         if (element == null) {
449             return (false);
450         }
451         if (isMatch(element)) {
452             stack.popElement();
453             return (true);
454         } else {
455             return (false);
456         }
457     }
458 
459     /**
460      * Gets the String property <b>album</b>.
461      *
462      * @return String
463      */
464     public String getAlbum() {
465         return (album_);
466     }
467 
468     /**
469      * Gets the property value as String.
470      *
471      * @return String
472      */
473     public String getAlbumAsString() {
474         return (URelaxer.getString(getAlbum()));
475     }
476 
477     /**
478      * Gets the String property <b>annotation</b>.
479      *
480      * @return String
481      */
482     public String getAnnotation() {
483         return (annotation_);
484     }
485 
486     /**
487      * Gets the property value as String.
488      *
489      * @return String
490      */
491     public String getAnnotationAsString() {
492         return (URelaxer.getString(getAnnotation()));
493     }
494 
495     /**
496      * Gets the String property <b>creator</b>.
497      *
498      * @return String
499      */
500     public String getCreator() {
501         return (creator_);
502     }
503 
504     /**
505      * Gets the property value as String.
506      *
507      * @return String
508      */
509     public String getCreatorAsString() {
510         return (URelaxer.getString(getCreator()));
511     }
512 
513     /**
514      * Gets the java.math.BigInteger property <b>duration</b>.
515      *
516      * @return java.math.BigInteger
517      */
518     public java.math.BigInteger getDuration() {
519         return (duration_);
520     }
521 
522     /**
523      * Gets the property value as String.
524      *
525      * @return String
526      */
527     public String getDurationAsString() {
528         return (URelaxer.getString(getDuration()));
529     }
530 
531     /**
532      * Gets the XspfExtension property <b>extension</b>.
533      *
534      * @return XspfExtension[]
535      */
536     public XspfExtension[] getExtension() {
537         XspfExtension[] array = new XspfExtension[extension_.size()];
538         return ((XspfExtension[])extension_.toArray(array));
539     }
540 
541     /**
542      * Gets the XspfExtension property <b>extension</b> by index.
543      *
544      * @param index
545      * @return XspfExtension
546      */
547     public XspfExtension getExtension(int index) {
548         return ((XspfExtension)extension_.get(index));
549     }
550 
551     /**
552      * Gets the String property <b>identifier</b>.
553      *
554      * @return String[]
555      */
556     public String[] getIdentifier() {
557         String[] array = new String[identifier_.size()];
558         return ((String[])identifier_.toArray(array));
559     }
560 
561     /**
562      * Gets the String property <b>identifier</b> by index.
563      *
564      * @param index
565      * @return String
566      */
567     public String getIdentifier(int index) {
568         return ((String)identifier_.get(index));
569     }
570 
571     /**
572      * Gets the property value as String array.
573      *
574      * @return String[]
575      */
576     public String[] getIdentifierAsString() {
577         int size = sizeIdentifier();
578         String[] array = new String[size];
579         for (int i = 0; i < size; i++) {
580             array[i] = URelaxer.getString(getIdentifier(i));
581         }
582         return (array);
583     }
584 
585     /**
586      * Gets the property value by index as String.
587      *
588      * @param index
589      * @return String
590      */
591     public String getIdentifierAsString(int index) {
592         return (URelaxer.getString(getIdentifier(index)));
593     }
594 
595     /**
596      * Gets the String property <b>image</b>.
597      *
598      * @return String
599      */
600     public String getImage() {
601         return (image_);
602     }
603 
604     /**
605      * Gets the property value as String.
606      *
607      * @return String
608      */
609     public String getImageAsString() {
610         return (URelaxer.getString(getImage()));
611     }
612 
613     /**
614      * Gets the String property <b>info</b>.
615      *
616      * @return String
617      */
618     public String getInfo() {
619         return (info_);
620     }
621 
622     /**
623      * Gets the property value as String.
624      *
625      * @return String
626      */
627     public String getInfoAsString() {
628         return (URelaxer.getString(getInfo()));
629     }
630 
631     /**
632      * Gets the XspfLink property <b>link</b>.
633      *
634      * @return XspfLink[]
635      */
636     public XspfLink[] getLink() {
637         XspfLink[] array = new XspfLink[link_.size()];
638         return ((XspfLink[])link_.toArray(array));
639     }
640 
641     /**
642      * Gets the XspfLink property <b>link</b> by index.
643      *
644      * @param index
645      * @return XspfLink
646      */
647     public XspfLink getLink(int index) {
648         return ((XspfLink)link_.get(index));
649     }
650 
651     /**
652      * Gets the String property <b>location</b>.
653      *
654      * @return String[]
655      */
656     public String[] getLocation() {
657         String[] array = new String[location_.size()];
658         return ((String[])location_.toArray(array));
659     }
660 
661     /**
662      * Gets the String property <b>location</b> by index.
663      *
664      * @param index
665      * @return String
666      */
667     public String getLocation(int index) {
668         return ((String)location_.get(index));
669     }
670 
671     /**
672      * Gets the property value as String array.
673      *
674      * @return String[]
675      */
676     public String[] getLocationAsString() {
677         int size = sizeLocation();
678         String[] array = new String[size];
679         for (int i = 0; i < size; i++) {
680             array[i] = URelaxer.getString(getLocation(i));
681         }
682         return (array);
683     }
684 
685     /**
686      * Gets the property value by index as String.
687      *
688      * @param index
689      * @return String
690      */
691     public String getLocationAsString(int index) {
692         return (URelaxer.getString(getLocation(index)));
693     }
694 
695     /**
696      * Gets the XspfMeta property <b>meta</b>.
697      *
698      * @return XspfMeta[]
699      */
700     public XspfMeta[] getMeta() {
701         XspfMeta[] array = new XspfMeta[meta_.size()];
702         return ((XspfMeta[])meta_.toArray(array));
703     }
704 
705     /**
706      * Gets the XspfMeta property <b>meta</b> by index.
707      *
708      * @param index
709      * @return XspfMeta
710      */
711     public XspfMeta getMeta(int index) {
712         return ((XspfMeta)meta_.get(index));
713     }
714 
715     /**
716      * Gets the String property <b>title</b>.
717      *
718      * @return String
719      */
720     public String getTitle() {
721         return (title_);
722     }
723 
724     /**
725      * Gets the property value as String.
726      *
727      * @return String
728      */
729     public String getTitleAsString() {
730         return (URelaxer.getString(getTitle()));
731     }
732 
733     /**
734      * Gets the java.math.BigInteger property <b>trackNum</b>.
735      *
736      * @return java.math.BigInteger
737      */
738     public java.math.BigInteger getTrackNum() {
739         return (trackNum_);
740     }
741 
742     /**
743      * Gets the property value as String.
744      *
745      * @return String
746      */
747     public String getTrackNumAsString() {
748         return (URelaxer.getString(getTrackNum()));
749     }
750 
751     /**
752      * Sets the String property <b>album</b>.
753      *
754      * @param album
755      */
756     public void setAlbum(String album) {
757         this.album_ = album;
758     }
759 
760     /**
761      * Sets the property value by String.
762      *
763      * @param string
764      */
765     public void setAlbumByString(String string) {
766         setAlbum(string);
767     }
768 
769     /**
770      * Sets the String property <b>annotation</b>.
771      *
772      * @param annotation
773      */
774     public void setAnnotation(String annotation) {
775         this.annotation_ = annotation;
776     }
777 
778     /**
779      * Sets the property value by String.
780      *
781      * @param string
782      */
783     public void setAnnotationByString(String string) {
784         setAnnotation(string);
785     }
786 
787     /**
788      * Sets the String property <b>creator</b>.
789      *
790      * @param creator
791      */
792     public void setCreator(String creator) {
793         this.creator_ = creator;
794     }
795 
796     /**
797      * Sets the property value by String.
798      *
799      * @param string
800      */
801     public void setCreatorByString(String string) {
802         setCreator(string);
803     }
804 
805     /**
806      * Sets the java.math.BigInteger property <b>duration</b>.
807      *
808      * @param duration
809      */
810     public void setDuration(java.math.BigInteger duration) {
811         this.duration_ = duration;
812     }
813 
814     /**
815      * Sets the property value by String.
816      *
817      * @param string
818      */
819     public void setDurationByString(String string) {
820         setDuration(new java.math.BigInteger(string));
821     }
822 
823     /**
824      * Sets the XspfExtension property <b>extension</b>.
825      *
826      * @param extension
827      */
828     public void setExtension(XspfExtension[] extension) {
829         this.extension_.clear();
830         for (int i = 0; i < extension.length; i++) {
831             addExtension(extension[i]);
832         }
833     }
834 
835     /**
836      * Sets the XspfExtension property <b>extension</b>.
837      *
838      * @param extension
839      */
840     public void setExtension(XspfExtension extension) {
841         this.extension_.clear();
842         addExtension(extension);
843     }
844 
845     /**
846      * Sets the XspfExtension property <b>extension</b> by index.
847      *
848      * @param index
849      * @param extension
850      */
851     public void setExtension(int index, XspfExtension extension) {
852         this.extension_.set(index, extension);
853     }
854 
855     /**
856      * Sets the String property <b>identifier</b>.
857      *
858      * @param identifier
859      */
860     public void setIdentifier(String[] identifier) {
861         this.identifier_.clear();
862         for (int i = 0; i < identifier.length; i++) {
863             addIdentifier(identifier[i]);
864         }
865     }
866 
867     /**
868      * Sets the String property <b>identifier</b>.
869      *
870      * @param identifier
871      */
872     public void setIdentifier(String identifier) {
873         this.identifier_.clear();
874         addIdentifier(identifier);
875     }
876 
877     /**
878      * Sets the String property <b>identifier</b> by index.
879      *
880      * @param index
881      * @param identifier
882      */
883     public void setIdentifier(int index, String identifier) {
884         this.identifier_.set(index, identifier);
885     }
886 
887     /**
888      * Sets the property value by String array.
889      *
890      * @param strings
891      */
892     public void setIdentifierByString(String[] strings) {
893         if (strings.length > 0) {
894             String string = strings[0];
895             setIdentifier(URelaxer.getString(string));
896             for (int i = 1; i < strings.length; i++) {
897                 string = strings[i];
898                 addIdentifier(string);
899             }
900         }
901     }
902 
903     /**
904      * Sets the property value by String via index.
905      *
906      * @param index
907      * @param value
908      */
909     public void setIdentifierByString(int index, String value) {
910         setIdentifier(index, URelaxer.getString(value));
911     }
912 
913     /**
914      * Sets the String property <b>image</b>.
915      *
916      * @param image
917      */
918     public void setImage(String image) {
919         this.image_ = image;
920     }
921 
922     /**
923      * Sets the property value by String.
924      *
925      * @param string
926      */
927     public void setImageByString(String string) {
928         setImage(URelaxer.getString(string));
929     }
930 
931     /**
932      * Sets the String property <b>info</b>.
933      *
934      * @param info
935      */
936     public void setInfo(String info) {
937         this.info_ = info;
938     }
939 
940     /**
941      * Sets the property value by String.
942      *
943      * @param string
944      */
945     public void setInfoByString(String string) {
946         setInfo(string);
947     }
948 
949     /**
950      * Sets the XspfLink property <b>link</b>.
951      *
952      * @param link
953      */
954     public void setLink(XspfLink[] link) {
955         this.link_.clear();
956         for (int i = 0; i < link.length; i++) {
957             addLink(link[i]);
958         }
959     }
960 
961     /**
962      * Sets the XspfLink property <b>link</b>.
963      *
964      * @param link
965      */
966     public void setLink(XspfLink link) {
967         this.link_.clear();
968         addLink(link);
969     }
970 
971     /**
972      * Sets the XspfLink property <b>link</b> by index.
973      *
974      * @param index
975      * @param link
976      */
977     public void setLink(int index, XspfLink link) {
978         this.link_.set(index, link);
979     }
980 
981     /**
982      * Sets the String property <b>location</b>.
983      *
984      * @param location
985      */
986     public void setLocation(String[] location) {
987         this.location_.clear();
988         for (int i = 0; i < location.length; i++) {
989             addLocation(location[i]);
990         }
991     }
992 
993     /**
994      * Sets the String property <b>location</b>.
995      *
996      * @param location
997      */
998     public void setLocation(String location) {
999         this.location_.clear();
1000         addLocation(location);
1001     }
1002 
1003     /**
1004      * Sets the String property <b>location</b> by index.
1005      *
1006      * @param index
1007      * @param location
1008      */
1009     public void setLocation(int index, String location) {
1010         this.location_.set(index, location);
1011     }
1012 
1013     /**
1014      * Sets the property value by String array.
1015      *
1016      * @param strings
1017      */
1018     public void setLocationByString(String[] strings) {
1019         if (strings.length > 0) {
1020             String string = strings[0];
1021             setLocation(URelaxer.getString(string));
1022             for (int i = 1; i < strings.length; i++) {
1023                 string = strings[i];
1024                 addLocation(string);
1025             }
1026         }
1027     }
1028 
1029     /**
1030      * Sets the property value by String via index.
1031      *
1032      * @param index
1033      * @param value
1034      */
1035     public void setLocationByString(int index, String value) {
1036         setLocation(index, URelaxer.getString(value));
1037     }
1038 
1039     /**
1040      * Sets the XspfMeta property <b>meta</b>.
1041      *
1042      * @param meta
1043      */
1044     public void setMeta(XspfMeta[] meta) {
1045         this.meta_.clear();
1046         for (int i = 0; i < meta.length; i++) {
1047             addMeta(meta[i]);
1048         }
1049     }
1050 
1051     /**
1052      * Sets the XspfMeta property <b>meta</b>.
1053      *
1054      * @param meta
1055      */
1056     public void setMeta(XspfMeta meta) {
1057         this.meta_.clear();
1058         addMeta(meta);
1059     }
1060 
1061     /**
1062      * Sets the XspfMeta property <b>meta</b> by index.
1063      *
1064      * @param index
1065      * @param meta
1066      */
1067     public void setMeta(int index, XspfMeta meta) {
1068         this.meta_.set(index, meta);
1069     }
1070 
1071     /**
1072      * Sets the String property <b>title</b>.
1073      *
1074      * @param title
1075      */
1076     public void setTitle(String title) {
1077         this.title_ = title;
1078     }
1079 
1080     /**
1081      * Sets the property value by String.
1082      *
1083      * @param string
1084      */
1085     public void setTitleByString(String string) {
1086         setTitle(string);
1087     }
1088 
1089     /**
1090      * Sets the java.math.BigInteger property <b>trackNum</b>.
1091      *
1092      * @param trackNum
1093      */
1094     public void setTrackNum(java.math.BigInteger trackNum) {
1095         this.trackNum_ = trackNum;
1096     }
1097 
1098     /**
1099      * Sets the property value by String.
1100      *
1101      * @param string
1102      */
1103     public void setTrackNumByString(String string) {
1104         setTrackNum(new java.math.BigInteger(string));
1105     }
1106 
1107     /**
1108      * Adds the XspfExtension property <b>extension</b>.
1109      *
1110      * @param extension
1111      */
1112     public void addExtension(XspfExtension extension) {
1113         this.extension_.add(extension);
1114     }
1115 
1116     /**
1117      * Adds the XspfExtension property <b>extension</b>.
1118      *
1119      * @param extension
1120      */
1121     public void addExtension(XspfExtension[] extension) {
1122         for (int i = 0; i < extension.length; i++) {
1123             addExtension(extension[i]);
1124         }
1125     }
1126 
1127     /**
1128      * Adds the XspfExtension property <b>extension</b> by index.
1129      *
1130      * @param index
1131      * @param extension
1132      */
1133     public void addExtension(int index, XspfExtension extension) {
1134         this.extension_.add(index, extension);
1135     }
1136 
1137     /**
1138      * Adds the String property <b>identifier</b>.
1139      *
1140      * @param identifier
1141      */
1142     public void addIdentifier(String identifier) {
1143         this.identifier_.add(identifier);
1144     }
1145 
1146     /**
1147      * Adds the String property <b>identifier</b>.
1148      *
1149      * @param identifier
1150      */
1151     public void addIdentifier(String[] identifier) {
1152         for (int i = 0; i < identifier.length; i++) {
1153             addIdentifier(identifier[i]);
1154         }
1155     }
1156 
1157     /**
1158      * Adds the String property <b>identifier</b> by index.
1159      *
1160      * @param index
1161      * @param identifier
1162      */
1163     public void addIdentifier(int index, String identifier) {
1164         this.identifier_.add(index, identifier);
1165     }
1166 
1167     /**
1168      * Adds the property value by String.
1169      *
1170      * @param string
1171      */
1172     public void addIdentifierByString(String string) {
1173         addIdentifier(string);
1174     }
1175 
1176     /**
1177      * Adds the XspfLink property <b>link</b>.
1178      *
1179      * @param link
1180      */
1181     public void addLink(XspfLink link) {
1182         this.link_.add(link);
1183     }
1184 
1185     /**
1186      * Adds the XspfLink property <b>link</b>.
1187      *
1188      * @param link
1189      */
1190     public void addLink(XspfLink[] link) {
1191         for (int i = 0; i < link.length; i++) {
1192             addLink(link[i]);
1193         }
1194     }
1195 
1196     /**
1197      * Adds the XspfLink property <b>link</b> by index.
1198      *
1199      * @param index
1200      * @param link
1201      */
1202     public void addLink(int index, XspfLink link) {
1203         this.link_.add(index, link);
1204     }
1205 
1206     /**
1207      * Adds the String property <b>location</b>.
1208      *
1209      * @param location
1210      */
1211     public void addLocation(String location) {
1212         this.location_.add(location);
1213     }
1214 
1215     /**
1216      * Adds the String property <b>location</b>.
1217      *
1218      * @param location
1219      */
1220     public void addLocation(String[] location) {
1221         for (int i = 0; i < location.length; i++) {
1222             addLocation(location[i]);
1223         }
1224     }
1225 
1226     /**
1227      * Adds the String property <b>location</b> by index.
1228      *
1229      * @param index
1230      * @param location
1231      */
1232     public void addLocation(int index, String location) {
1233         this.location_.add(index, location);
1234     }
1235 
1236     /**
1237      * Adds the property value by String.
1238      *
1239      * @param string
1240      */
1241     public void addLocationByString(String string) {
1242         addLocation(string);
1243     }
1244 
1245     /**
1246      * Adds the XspfMeta property <b>meta</b>.
1247      *
1248      * @param meta
1249      */
1250     public void addMeta(XspfMeta meta) {
1251         this.meta_.add(meta);
1252     }
1253 
1254     /**
1255      * Adds the XspfMeta property <b>meta</b>.
1256      *
1257      * @param meta
1258      */
1259     public void addMeta(XspfMeta[] meta) {
1260         for (int i = 0; i < meta.length; i++) {
1261             addMeta(meta[i]);
1262         }
1263     }
1264 
1265     /**
1266      * Adds the XspfMeta property <b>meta</b> by index.
1267      *
1268      * @param index
1269      * @param meta
1270      */
1271     public void addMeta(int index, XspfMeta meta) {
1272         this.meta_.add(index, meta);
1273     }
1274 
1275     /**
1276      * Clear the XspfExtension property <b>extension</b>.
1277      *
1278      */
1279     public void clearExtension() {
1280         this.extension_.clear();
1281     }
1282 
1283     /**
1284      * Clear the String property <b>identifier</b>.
1285      *
1286      */
1287     public void clearIdentifier() {
1288         this.identifier_.clear();
1289     }
1290 
1291     /**
1292      * Clear the XspfLink property <b>link</b>.
1293      *
1294      */
1295     public void clearLink() {
1296         this.link_.clear();
1297     }
1298 
1299     /**
1300      * Clear the String property <b>location</b>.
1301      *
1302      */
1303     public void clearLocation() {
1304         this.location_.clear();
1305     }
1306 
1307     /**
1308      * Clear the XspfMeta property <b>meta</b>.
1309      *
1310      */
1311     public void clearMeta() {
1312         this.meta_.clear();
1313     }
1314 
1315     /**
1316      * @return Object
1317      */
1318     public Object clone() {
1319         return (new XspfTrack((XspfTrack)this));
1320     }
1321 
1322     /**
1323      * Creates a DOM document representation of the object.
1324      *
1325      * @exception ParserConfigurationException
1326      * @return Document
1327      */
1328     public Document makeDocument()
1329                           throws ParserConfigurationException {
1330         Document doc = UJAXP.makeDocument();
1331         makeElement(doc);
1332         return (doc);
1333     }
1334 
1335     /**
1336      * Creates a DOM representation of the object.
1337      * Result is appended to the Node <code>parent</code>.
1338      *
1339      * @param parent
1340      */
1341     public void makeElement(Node parent) {
1342         Document doc;
1343         if (parent instanceof Document) {
1344             doc = (Document)parent;
1345         } else {
1346             doc = parent.getOwnerDocument();
1347         }
1348         Element element = doc.createElement("track");
1349         if (parent instanceof Document) {
1350             element.setAttribute("xmlns", "http://xspf.org/ns/0/");
1351         }
1352         int size;
1353         URelaxer.setElementPropertyByStringList(element, "location", this.location_);
1354         URelaxer.setElementPropertyByStringList(element, "identifier", this.identifier_);
1355         if (this.title_ != null) {
1356             URelaxer.setElementPropertyByString(element, "title", this.title_);
1357         }
1358         if (this.creator_ != null) {
1359             URelaxer.setElementPropertyByString(element, "creator", this.creator_);
1360         }
1361         if (this.annotation_ != null) {
1362             URelaxer.setElementPropertyByString(element, "annotation", this.annotation_);
1363         }
1364         if (this.info_ != null) {
1365             URelaxer.setElementPropertyByString(element, "info", this.info_);
1366         }
1367         if (this.image_ != null) {
1368             URelaxer.setElementPropertyByString(element, "image", this.image_);
1369         }
1370         if (this.album_ != null) {
1371             URelaxer.setElementPropertyByString(element, "album", this.album_);
1372         }
1373         if (this.trackNum_ != null) {
1374             URelaxer.setElementPropertyByBigInteger(element, "trackNum", this.trackNum_);
1375         }
1376         if (this.duration_ != null) {
1377             URelaxer.setElementPropertyByBigInteger(element, "duration", this.duration_);
1378         }
1379         size = this.link_.size();
1380         for (int i = 0; i < size; i++) {
1381             XspfLink value = (XspfLink)this.link_.get(i);
1382             value.makeElement(element);
1383         }
1384         size = this.meta_.size();
1385         for (int i = 0; i < size; i++) {
1386             XspfMeta value = (XspfMeta)this.meta_.get(i);
1387             value.makeElement(element);
1388         }
1389         size = this.extension_.size();
1390         for (int i = 0; i < size; i++) {
1391             XspfExtension value = (XspfExtension)this.extension_.get(i);
1392             value.makeElement(element);
1393         }
1394         parent.appendChild(element);
1395     }
1396 
1397     /**
1398      * Makes an XML text representation.
1399      *
1400      * @param buffer
1401      */
1402     public void makeTextAttribute(StringBuffer buffer) {
1403     }
1404 
1405     /**
1406      * Makes an XML text representation.
1407      *
1408      * @param buffer
1409      * @exception IOException
1410      */
1411     public void makeTextAttribute(Writer buffer)
1412                            throws IOException {
1413     }
1414 
1415     /**
1416      * Makes an XML text representation.
1417      *
1418      * @param buffer
1419      */
1420     public void makeTextAttribute(PrintWriter buffer) {
1421     }
1422 
1423     /**
1424      * Makes an XML text representation.
1425      *
1426      * @return String
1427      */
1428     public String makeTextDocument() {
1429         StringBuffer buffer = new StringBuffer();
1430         makeTextElement(buffer);
1431         return (new String(buffer));
1432     }
1433 
1434     /**
1435      * Makes an XML text representation.
1436      *
1437      * @param buffer
1438      */
1439     public void makeTextElement(StringBuffer buffer) {
1440         int size;
1441         buffer.append("<track");
1442         buffer.append(" xmlns=\"http://xspf.org/ns/0/\"");
1443         buffer.append(">");
1444         size = sizeLocation();
1445         for (int i = 0; i < size; i++) {
1446             buffer.append("<location>");
1447             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getLocation(i))));
1448             buffer.append("</location>");
1449         }
1450         size = sizeIdentifier();
1451         for (int i = 0; i < size; i++) {
1452             buffer.append("<identifier>");
1453             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getIdentifier(i))));
1454             buffer.append("</identifier>");
1455         }
1456         if (title_ != null) {
1457             buffer.append("<title>");
1458             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getTitle())));
1459             buffer.append("</title>");
1460         }
1461         if (creator_ != null) {
1462             buffer.append("<creator>");
1463             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getCreator())));
1464             buffer.append("</creator>");
1465         }
1466         if (annotation_ != null) {
1467             buffer.append("<annotation>");
1468             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getAnnotation())));
1469             buffer.append("</annotation>");
1470         }
1471         if (info_ != null) {
1472             buffer.append("<info>");
1473             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getInfo())));
1474             buffer.append("</info>");
1475         }
1476         if (image_ != null) {
1477             buffer.append("<image>");
1478             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getImage())));
1479             buffer.append("</image>");
1480         }
1481         if (album_ != null) {
1482             buffer.append("<album>");
1483             buffer.append(URelaxer.escapeCharData(URelaxer.getString(getAlbum())));
1484             buffer.append("</album>");
1485         }
1486         if (trackNum_ != null) {
1487             buffer.append("<trackNum>");
1488             buffer.append(URelaxer.getString(getTrackNum()));
1489             buffer.append("</trackNum>");
1490         }
1491         if (duration_ != null) {
1492             buffer.append("<duration>");
1493             buffer.append(URelaxer.getString(getDuration()));
1494             buffer.append("</duration>");
1495         }
1496         size = this.link_.size();
1497         for (int i = 0; i < size; i++) {
1498             XspfLink value = (XspfLink)this.link_.get(i);
1499             value.makeTextElement(buffer);
1500         }
1501         size = this.meta_.size();
1502         for (int i = 0; i < size; i++) {
1503             XspfMeta value = (XspfMeta)this.meta_.get(i);
1504             value.makeTextElement(buffer);
1505         }
1506         size = this.extension_.size();
1507         for (int i = 0; i < size; i++) {
1508             XspfExtension value = (XspfExtension)this.extension_.get(i);
1509             value.makeTextElement(buffer);
1510         }
1511         buffer.append("</track>");
1512     }
1513 
1514     /**
1515      * Makes an XML text representation.
1516      *
1517      * @param buffer
1518      * @exception IOException
1519      */
1520     public void makeTextElement(Writer buffer)
1521                          throws IOException {
1522         int size;
1523         buffer.write("<track");
1524         buffer.write(" xmlns=\"http://xspf.org/ns/0/\"");
1525         buffer.write(">");
1526         size = sizeLocation();
1527         for (int i = 0; i < size; i++) {
1528             buffer.write("<location>");
1529             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getLocation(i))));
1530             buffer.write("</location>");
1531         }
1532         size = sizeIdentifier();
1533         for (int i = 0; i < size; i++) {
1534             buffer.write("<identifier>");
1535             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getIdentifier(i))));
1536             buffer.write("</identifier>");
1537         }
1538         if (title_ != null) {
1539             buffer.write("<title>");
1540             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getTitle())));
1541             buffer.write("</title>");
1542         }
1543         if (creator_ != null) {
1544             buffer.write("<creator>");
1545             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getCreator())));
1546             buffer.write("</creator>");
1547         }
1548         if (annotation_ != null) {
1549             buffer.write("<annotation>");
1550             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getAnnotation())));
1551             buffer.write("</annotation>");
1552         }
1553         if (info_ != null) {
1554             buffer.write("<info>");
1555             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getInfo())));
1556             buffer.write("</info>");
1557         }
1558         if (image_ != null) {
1559             buffer.write("<image>");
1560             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getImage())));
1561             buffer.write("</image>");
1562         }
1563         if (album_ != null) {
1564             buffer.write("<album>");
1565             buffer.write(URelaxer.escapeCharData(URelaxer.getString(getAlbum())));
1566             buffer.write("</album>");
1567         }
1568         if (trackNum_ != null) {
1569             buffer.write("<trackNum>");
1570             buffer.write(URelaxer.getString(getTrackNum()));
1571             buffer.write("</trackNum>");
1572         }
1573         if (duration_ != null) {
1574             buffer.write("<duration>");
1575             buffer.write(URelaxer.getString(getDuration()));
1576             buffer.write("</duration>");
1577         }
1578         size = this.link_.size();
1579         for (int i = 0; i < size; i++) {
1580             XspfLink value = (XspfLink)this.link_.get(i);
1581             value.makeTextElement(buffer);
1582         }
1583         size = this.meta_.size();
1584         for (int i = 0; i < size; i++) {
1585             XspfMeta value = (XspfMeta)this.meta_.get(i);
1586             value.makeTextElement(buffer);
1587         }
1588         size = this.extension_.size();
1589         for (int i = 0; i < size; i++) {
1590             XspfExtension value = (XspfExtension)this.extension_.get(i);
1591             value.makeTextElement(buffer);
1592         }
1593         buffer.write("</track>");
1594     }
1595 
1596     /**
1597      * Makes an XML text representation.
1598      *
1599      * @param buffer
1600      */
1601     public void makeTextElement(PrintWriter buffer) {
1602         int size;
1603         buffer.print("<track");
1604         buffer.print(" xmlns=\"http://xspf.org/ns/0/\"");
1605         buffer.print(">");
1606         size = sizeLocation();
1607         for (int i = 0; i < size; i++) {
1608             buffer.print("<location>");
1609             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getLocation(i))));
1610             buffer.print("</location>");
1611         }
1612         size = sizeIdentifier();
1613         for (int i = 0; i < size; i++) {
1614             buffer.print("<identifier>");
1615             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getIdentifier(i))));
1616             buffer.print("</identifier>");
1617         }
1618         if (title_ != null) {
1619             buffer.print("<title>");
1620             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getTitle())));
1621             buffer.print("</title>");
1622         }
1623         if (creator_ != null) {
1624             buffer.print("<creator>");
1625             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getCreator())));
1626             buffer.print("</creator>");
1627         }
1628         if (annotation_ != null) {
1629             buffer.print("<annotation>");
1630             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getAnnotation())));
1631             buffer.print("</annotation>");
1632         }
1633         if (info_ != null) {
1634             buffer.print("<info>");
1635             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getInfo())));
1636             buffer.print("</info>");
1637         }
1638         if (image_ != null) {
1639             buffer.print("<image>");
1640             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getImage())));
1641             buffer.print("</image>");
1642         }
1643         if (album_ != null) {
1644             buffer.print("<album>");
1645             buffer.print(URelaxer.escapeCharData(URelaxer.getString(getAlbum())));
1646             buffer.print("</album>");
1647         }
1648         if (trackNum_ != null) {
1649             buffer.print("<trackNum>");
1650             buffer.print(URelaxer.getString(getTrackNum()));
1651             buffer.print("</trackNum>");
1652         }
1653         if (duration_ != null) {
1654             buffer.print("<duration>");
1655             buffer.print(URelaxer.getString(getDuration()));
1656             buffer.print("</duration>");
1657         }
1658         size = this.link_.size();
1659         for (int i = 0; i < size; i++) {
1660             XspfLink value = (XspfLink)this.link_.get(i);
1661             value.makeTextElement(buffer);
1662         }
1663         size = this.meta_.size();
1664         for (int i = 0; i < size; i++) {
1665             XspfMeta value = (XspfMeta)this.meta_.get(i);
1666             value.makeTextElement(buffer);
1667         }
1668         size = this.extension_.size();
1669         for (int i = 0; i < size; i++) {
1670             XspfExtension value = (XspfExtension)this.extens