Tue, 10 Feb 2015 19:38:00 +0100
Upgrade embedded ical4j from ancient whatever to upstream version 1.0.6.
1 /**
2 * Copyright (c) 2012, Ben Fortuna
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * o Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * o Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * o Neither the name of Ben Fortuna nor the names of any other contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package net.fortuna.ical4j.util;
34 import java.util.Map;
36 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
38 /**
39 * $Id$
40 *
41 * Created on 9/03/2006
42 *
43 * A set of keys used to enable compatibility features.
44 *
45 * @author Ben Fortuna
46 */
47 public final class CompatibilityHints {
49 /**
50 * A system property key to enable relaxed unfolding. Relaxed unfolding is enabled by setting this system property
51 * to "true".
52 */
53 public static final String KEY_RELAXED_UNFOLDING = "ical4j.unfolding.relaxed";
55 /**
56 * A system property key to enable relaxed parsing. Relaxed parsing is enabled by setting this system property to
57 * "true".
58 */
59 public static final String KEY_RELAXED_PARSING = "ical4j.parsing.relaxed";
61 /**
62 * A system property key to enable relaxed validation. Relaxed validation disables validation of certain conformance
63 * rules that many iCalendar implementations do not conform to. Relaxed validation is enabled by setting this system
64 * property to "true".
65 */
66 public static final String KEY_RELAXED_VALIDATION = "ical4j.validation.relaxed";
68 /**
69 * A system property key used to enable compatibility with Outlook/Exchange-generated iCalendar files. Outlook
70 * compatibility is enabled by setting this system property to "true".
71 */
72 public static final String KEY_OUTLOOK_COMPATIBILITY = "ical4j.compatibility.outlook";
74 /**
75 * A system property key used to enable compatibility with Lotus Notes-generated iCalendar files. Notes
76 * compatibility is enabled by setting this system property to "true".
77 */
78 public static final String KEY_NOTES_COMPATIBILITY = "ical4j.compatibility.notes";
80 /**
81 * Support for vCard features that are not necessarily compatible with the iCalendar standard.
82 */
83 public static final String KEY_VCARD_COMPATIBILITY = "ical4j.compatibility.vcard";
85 private static final Map HINTS = new ConcurrentHashMap();
86 // preload known hints from the configurator
87 static {
88 setHintEnabled(KEY_RELAXED_UNFOLDING, "true".equals(Configurator.getProperty(KEY_RELAXED_UNFOLDING)));
89 setHintEnabled(KEY_RELAXED_PARSING, "true".equals(Configurator.getProperty(KEY_RELAXED_PARSING)));
90 setHintEnabled(KEY_RELAXED_VALIDATION, "true".equals(Configurator.getProperty(KEY_RELAXED_VALIDATION)));
91 setHintEnabled(KEY_OUTLOOK_COMPATIBILITY, "true".equals(Configurator.getProperty(KEY_OUTLOOK_COMPATIBILITY)));
92 setHintEnabled(KEY_NOTES_COMPATIBILITY, "true".equals(Configurator.getProperty(KEY_NOTES_COMPATIBILITY)));
93 }
95 /**
96 * Constructor made private to enforce static nature.
97 */
98 private CompatibilityHints() {
99 }
101 /**
102 * @param key
103 * a compatibility hint key
104 * @param enabled
105 * indicates whether to enable or disable the compatibility hint
106 */
107 public static void setHintEnabled(final String key, final boolean enabled) {
108 HINTS.put(key, Boolean.valueOf(enabled));
109 }
111 /**
112 * @param key
113 * a compatibility hint key
114 */
115 public static void clearHintEnabled(final String key) {
116 HINTS.remove(key);
117 }
119 /**
120 * @param key
121 * a compatibility hint key
122 * @return true if the specified compatibility hint is enabled, otherwise false
123 */
124 public static boolean isHintEnabled(final String key) {
125 if (HINTS.get(key) != null) {
126 return ((Boolean) HINTS.get(key)).booleanValue();
127 }
128 return "true".equals(Configurator.getProperty(key));
129 }
130 }