]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.core/src/org/argeo/app/core/SuiteContentNamespace.java
Releasing
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / core / SuiteContentNamespace.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 import org.argeo.api.acr.spi.ContentNamespace;
8
9 public enum SuiteContentNamespace implements ContentNamespace {
10 //
11 // ARGEO
12 //
13 ENTITY("entity", "http://www.argeo.org/ns/entity", "/org/argeo/app/api/entity.xsd", null),
14 //
15 ARGEO_DBK("argeodbk", "http://www.argeo.org/ns/argeodbk", null, null),
16 //
17 // EXTERNAL
18 //
19 DOCBOOK5("dbk", "http://docbook.org/ns/docbook", "docbook.xsd", "http://docbook.org/xml/5.0.1/xsd/docbook.xsd"),
20 //
21 XML_EVENTS("ev", "http://www.w3.org/2001/xml-events", "xml-events-attribs-1.xsd",
22 "http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd"),
23 //
24 XFORMS("xforms", "http://www.w3.org/2002/xforms", "XForms-11-Schema.xsd",
25 "https://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd"),
26 //
27 XCARD("xcard", "urn:ietf:params:xml:ns:vcard-4.0", "xCard-4.0.xsd", null),
28 //
29 XSL_FO("fo", "http://www.w3.org/1999/XSL/Format", "fop.xsd",
30 "https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/fop/src/foschema/fop.xsd"),
31 //
32 // XCAL_2_0("xcal", "urn:ietf:params:xml:ns:icalendar-2.0", "xCal-2.0.xsd", null),
33 //
34 XHTML("h", "http://www.w3.org/1999/xhtml", null, "https://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"),
35 //
36 // ODK
37 //
38 JR("jr", "http://openrosa.org/javarosa", null, null),
39 //
40 ORX("orx", "http://openrosa.org/xforms", null, null),
41 //
42 ORX_LIST("orxList", "http://openrosa.org/xforms/xformsList", null, null),
43 //
44 ORX_MANIFEST("orxManifest", "http://openrosa.org/xforms/xformsManifest", null, null),
45 //
46 ODK("odk", "http://www.opendatakit.org/xforms", null, null),
47 //
48 WGS84("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#", null, null),
49 //
50 ;
51
52 private final static String RESOURCE_BASE = "/org/argeo/app/core/schemas/";
53
54 private String defaultPrefix;
55 private String namespace;
56 private URL resource;
57 private URL publicUrl;
58
59 SuiteContentNamespace(String defaultPrefix, String namespace, String resourceFileName, String publicUrl) {
60 Objects.requireNonNull(namespace);
61 this.defaultPrefix = defaultPrefix;
62 Objects.requireNonNull(namespace);
63 this.namespace = namespace;
64 if (resourceFileName != null) {
65 if (!resourceFileName.startsWith("/"))
66 resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
67 else
68 resource = getClass().getResource(resourceFileName);
69 Objects.requireNonNull(resource);
70 }
71 if (publicUrl != null)
72 try {
73 this.publicUrl = new URL(publicUrl);
74 } catch (MalformedURLException e) {
75 throw new IllegalArgumentException("Cannot interpret public URL", e);
76 }
77 }
78
79 @Override
80 public String getDefaultPrefix() {
81 return defaultPrefix;
82 }
83
84 @Override
85 public String getNamespaceURI() {
86 return namespace;
87 }
88
89 @Override
90 public URL getSchemaResource() {
91 return resource;
92 }
93
94 public URL getPublicUrl() {
95 return publicUrl;
96 }
97
98 }