01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.outerj.daisy.util;
17:
18: import java.util.regex.Pattern;
19: import java.util.Map;
20: import java.util.HashMap;
21:
22: public class Constants {
23: /**
24: * Regex for parsing "daisy:" links.
25: *
26: * <p>The resulting groups are:
27: *
28: * <ul>
29: * <li>1 -> document ID
30: * <li>2 -> branch
31: * <li>3 -> language
32: * <li>4 -> version
33: * <li>5 -> unused, reserved for when we might add document part addressing
34: * <li>6 -> query string (without the ?)
35: * <li>7 -> fragment identifier (including the #)
36: * </ul>
37: */
38: public static final Pattern DAISY_LINK_PATTERN = Pattern
39: .compile("^daisy:([0-9]{1,19}(?:-[a-zA-Z0-9_]{1,200})?)(?:@([^:#?]*)(?::([^:#?]*))?(?::([^:#?]*))?)?()(?:\\?([^#]*))?(#.*)?$");
40: public static final String DAISY_NAMESPACE = "http://outerx.org/daisy/1.0";
41: public static final String PUBLISHER_NS = "http://outerx.org/daisy/1.0#publisher";
42: public static final String NAVIGATION_NS = "http://outerx.org/daisy/1.0#navigation";
43: public static final String VARIABLES_NS = "http://outerx.org/daisy/1.0#variables";
44: public static final Pattern DAISY_DOCID_PATTERN = Pattern
45: .compile("^([0-9]{1,19})-([a-zA-Z0-9_]{1,200})$");
46:
47: /**
48: * Compatibility pattern for Daisy document IDs: doesn't require namespace part to be present.
49: * (Namespaces were introduced in Daisy 2.0)
50: */
51: public static final Pattern DAISY_COMPAT_DOCID_PATTERN = Pattern
52: .compile("^([0-9]{1,19})(?:-([a-zA-Z0-9_]{1,200}))?$");
53:
54: public static final Map SUGGESTED_NAMESPACE_PREFIXES = new HashMap();
55: static {
56: SUGGESTED_NAMESPACE_PREFIXES.put(
57: "http://outerx.org/daisy/1.0#workflow", "wf");
58: }
59: }
|