001: /*
002: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: * 1. Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * 3. The name of the author may not be used to endorse or promote products
014: * derived from this software without specific prior written permission.
015:
016: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
017: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
018: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
019: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
020: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
021: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
022: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
023: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
025: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026: *
027: * $Id: JenaConfig.java,v 1.11 2008/01/02 12:05:48 andy_seaborne Exp $
028: *
029: * Created on 27 June 2002, 08:49
030: */
031:
032: package com.hp.hpl.jena.rdf.model;
033:
034: import org.apache.commons.logging.Log;
035: import org.apache.commons.logging.LogFactory;
036:
037: import com.hp.hpl.jena.*;
038:
039: /** A Class for configuring Jena's behaviour.
040: *
041: * <p>It is sometimes necessary to configure Jena's behaviour. For example
042: * when external functionality has changed, it may, for a time be desirable
043: * to be able to configure Jena to continue the old behaviour so that existing
044: * code which relied on the old behaviour does not break.<p>
045: *
046: * <p> Configuration options can sometimes be set using system properties. The
047: * following system properties are defined:</p>
048: * <ul>
049: * <li><code>com.hp.hpl.jena.oldLiteralCompare</code>: This can be set
050: to "true" before running Jena to turn on old literal compare behaviour.
051: See <code>setOldLiteralCompare</code> below.</li>
052: * </ul>
053: * @author bwm
054: * @version $Revision: 1.11 $
055: *
056: */
057: public class JenaConfig {
058:
059: /** Creates new JenaConfig */
060: private JenaConfig() {
061: }
062:
063: protected static Log logger = LogFactory.getLog(JenaConfig.class);
064:
065: private static boolean oldLiteralCompare;
066:
067: /** Configure Jena to use its previous algorithm for comparing Literals.
068: *
069: * <p>The RDFCore WG recently decided that two literals were not equal
070: * if they differed only in the setting of their isWellFormedXML
071: * flag. This is different from Jena's original behaviour.</p>
072: *
073: * <p>Jena literals have been modified to support the behaviour
074: * defined by RDFCore. By calling this method with true as
075: * a parameter, Jena can be configured to use its old behaviour.</p>
076: *
077: * @param b The value to set the oldLiteralCompare flag
078: * @return the previous value of the oldLiteralCompare flag
079: * @deprecated this functionality is temporary
080: */
081: public static boolean setOldLiteralCompare(boolean b) {
082: boolean previous = oldLiteralCompare;
083: oldLiteralCompare = b;
084: return previous;
085: }
086:
087: /** Return the value of the oldLiteralCompare flag
088: * @return the value of the oldLiteralCompare flag
089: * @deprecated this functionality is temporary
090: */
091: public static boolean getOldLiteralCompare() {
092: return oldLiteralCompare;
093: }
094:
095: static {
096: try {
097: String str = JenaRuntime.getSystemProperty(Jena.PATH
098: + ".oldLiteralCompare", "false");
099: oldLiteralCompare = (str.equalsIgnoreCase("true") || str
100: .equals("1"));
101: } catch (SecurityException se) {
102: // could get this in an applet for example
103: // so ignore
104: oldLiteralCompare = false;
105: } catch (Exception e) {
106: // other exceptions are unexpected
107: // log and ignore
108: logger
109: .warn(
110: "Unexpected Exception: JenaConfig.<Static Init>",
111: e);
112: oldLiteralCompare = false;
113: }
114: }
115: }
|