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