KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > JenaConfig


1 /*
2  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
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  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $Id: JenaConfig.java,v 1.7 2005/02/21 12:14:02 andy_seaborne Exp $
28  *
29  * Created on 27 June 2002, 08:49
30  */

31
32 package com.hp.hpl.jena.rdf.model;
33
34 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37 import com.hp.hpl.jena.*;
38
39 /** A Class for configuring Jena's behaviour.
40  *
41  * <p>It is sometimes necessary to configure Jena's behaviour. For example
42  * when external functionality has changed, it may, for a time be desirable
43  * to be able to configure Jena to continue the old behaviour so that existing
44  * code which relied on the old behaviour does not break.<p>
45  *
46  * <p> Configuration options can sometimes be set using system properties. The
47  * following system properties are defined:</p>
48  * <ul>
49  * <li><code>com.hp.hpl.jena.oldLiteralCompare</code>: This can be set
50        to "true" before running Jena to turn on old literal compare behaviour.
51        See <code>setOldLiteralCompare</code> below.</li>
52  * </ul>
53  * @author bwm
54  * @version $Revision: 1.7 $
55  *
56  */

57 public class JenaConfig {
58
59     /** Creates new JenaConfig */
60     private JenaConfig() {
61     }
62     
63     protected static Log logger = LogFactory.getLog( JenaConfig.class );
64     
65     private static boolean oldLiteralCompare;
66     
67     /** Configure Jena to use its previous algorithm for comparing Literals.
68      *
69      * <p>The RDFCore WG recently decided that two literals were not equal
70      * if they differed only in the setting of their isWellFormedXML
71      * flag. This is different from Jena's original behaviour.</p>
72      *
73      * <p>Jena literals have been modified to support the behaviour
74      * defined by RDFCore. By calling this method with true as
75      * a parameter, Jena can be configured to use its old behaviour.</p>
76      *
77      * @param b The value to set the oldLiteralCompare flag
78      * @return the previous value of the oldLiteralCompare flag
79      * @deprecated this functionality is temporary
80      */

81     public static boolean setOldLiteralCompare(boolean b) {
82         boolean previous = oldLiteralCompare;
83         oldLiteralCompare = b;
84         return previous;
85     }
86     
87     /** Return the value of the oldLiteralCompare flag
88      * @return the value of the oldLiteralCompare flag
89      * @deprecated this functionality is temporary
90      */

91     public static boolean getOldLiteralCompare() {
92         return oldLiteralCompare;
93     }
94     
95     static {
96         try {
97             String JavaDoc str =
98                   System.getProperty(Jena.PATH + ".oldLiteralCompare", "false");
99             oldLiteralCompare =
100                         (str.equalsIgnoreCase("true") || str.equals("1"));
101         } catch (SecurityException JavaDoc se) {
102             // could get this in an applet for example
103
// so ignore
104
oldLiteralCompare = false;
105         } catch (Exception JavaDoc e) {
106             // other exceptions are unexpected
107
// log and ignore
108
logger.warn("Unexpected Exception: JenaConfig.<Static Init>", e);
109             oldLiteralCompare = false;
110         }
111     }
112 }
113
Popular Tags