[LIB-4] Extend copyright for 2019 year
[hespiff.git] / src / main / java / org / hedgecode / xml / xspf / XSPFConstants.java
1 /*
2  * Copyright (c) 2015-2019. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.xml.xspf;
18
19 import java.nio.charset.Charset;
20 import java.nio.charset.StandardCharsets;
21 import javax.xml.namespace.QName;
22
23 /**
24  * Store of library constants.
25  *
26  * @author Dmitry Samoshin aka gotty
27  */
28 public final class XSPFConstants {
29
30     public static final Charset DEF_CHARSET = StandardCharsets.UTF_8;
31
32     public static final String XSD_FORMAT = "xsd";
33     public static final String RNG_FORMAT = "rng";
34
35     public static enum Format {
36
37         XSD      ( XSD_FORMAT ),
38         RELAX_NG ( RNG_FORMAT );
39
40         private String formatName;
41
42         Format(String name) {
43             this.formatName = name;
44         }
45
46         public String getName() {
47             return formatName;
48         }
49
50         public static Format byName(String formatName) {
51             for (Format format : Format.values()) {
52                 if (format.getName().equals(formatName))
53                     return format;
54             }
55             return null;
56         }
57     }
58
59     public static final String VER_1_0_2 = "1_0.2";
60     public static final String VER_1_0_7 = "1_0.7";
61
62     public static enum Version {
63
64         V1_2 ( VER_1_0_2 ),
65         V1_7 ( VER_1_0_7 );
66
67         private String versionName;
68
69         Version(String name) {
70             this.versionName = name;
71         }
72
73         public String getName() {
74             return versionName;
75         }
76
77         public static Version byName(String versionName) {
78             for (Version version : Version.values()) {
79                 if (version.getName().equals(versionName))
80                     return version;
81             }
82             return null;
83         }
84     }
85
86     public static final String XSPF_VERSION = "1";
87
88     public static final QName PLAYLIST_QNAME = new QName("http://xspf.org/ns/0/", "playlist");
89
90     public static final String XML_HEADER_NAME = "com.sun.xml.internal.bind.xmlHeaders";
91     public static final String XML_HEADER_VALUE = "<?xml version=\"1.0\" encoding=\"%CHARSET%\"?>";
92
93
94     public static interface Errors {
95         public static final int NULL_PLAYLIST = 101;
96         public static final int VALIDATE_ERROR = 201;
97         public static final int BINDING_ERROR = 301;
98         public static final int ENCODING_ERROR = 401;
99     }
100
101     private XSPFConstants() {
102         throw new AssertionError(
103                 "No org.hedgecode.xml.xspf.XSPFConstants instances!"
104         );
105     }
106
107 }