]> git.argeo.org Git - gpl/argeo-suite.git/blob - SuiteContentTypes.java
15b1125b29bce29946006e5c8ee289d9e4511c91
[gpl/argeo-suite.git] / SuiteContentTypes.java
1 package org.argeo.app.core;
2
3 import java.net.MalformedURLException;
4 import java.net.URL;
5 import java.util.Objects;
6
7 public enum SuiteContentTypes {
8 //
9 // ARGEO
10 //
11 ENTITY("entity", "http://www.argeo.org/ns/entity", null, null),
12 //
13 ARGEO_DBK("argeodbk", "http://www.argeo.org/ns/argeodbk", null, null),
14 //
15 // EXTERNAL
16 //
17 XCARD_4_0("xcard", "urn:ietf:params:xml:ns:vcard-4.0", "xCard-4.0.xsd", null),
18 //
19 XSL_FO_1999("fo", "http://www.w3.org/1999/XSL/Format", "fop.xsd",
20 "https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/fop/src/foschema/fop.xsd"),
21 //
22 // XCAL_2_0("xcal", "urn:ietf:params:xml:ns:icalendar-2.0", "xCal-2.0.xsd", null),
23 //
24 XHTML_1_1("h", "http://www.w3.org/1999/xhtml", null, "https://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"),
25 //
26 // ODK
27 //
28 JR("jr", "http://openrosa.org/javarosa", null, null),
29 //
30 ORX("orx", "http://openrosa.org/xforms", null, null),
31 //
32 ORX_LIST("orxList", "http://openrosa.org/xforms/xformsList", null, null),
33 //
34 ORX_MANIFEST("orxManifest", "http://openrosa.org/xforms/xformsManifest", null, null),
35 //
36 ODK("odk", "http://www.opendatakit.org/xforms", null, null),
37 //
38 ;
39
40 private final static String RESOURCE_BASE = "/org/argeo/app/core/schemas/";
41
42 private String defaultPrefix;
43 private String namespace;
44 private URL resource;
45 private URL publicUrl;
46
47 SuiteContentTypes(String defaultPrefix, String namespace, String resourceFileName, String publicUrl) {
48 Objects.requireNonNull(namespace);
49 this.defaultPrefix = defaultPrefix;
50 Objects.requireNonNull(namespace);
51 this.namespace = namespace;
52 if (resourceFileName != null) {
53 resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
54 Objects.requireNonNull(resource);
55 }
56 if (publicUrl != null)
57 try {
58 this.publicUrl = new URL(publicUrl);
59 } catch (MalformedURLException e) {
60 throw new IllegalArgumentException("Cannot interpret public URL", e);
61 }
62 }
63
64 public String getDefaultPrefix() {
65 return defaultPrefix;
66 }
67
68 public String getNamespace() {
69 return namespace;
70 }
71
72 public URL getResource() {
73 return resource;
74 }
75
76 public URL getPublicUrl() {
77 return publicUrl;
78 }
79
80 }