1 6 7 package com.hp.hpl.jena; 8 9 import java.util.* ; 10 import java.security.AccessController ; 11 12 18 19 public class JenaRuntime 20 { 21 22 public static final String featureNoSecurity = "http://jena.hpl.hp.com/2004/07/feature/noSecurity" ; 23 24 25 public static final String featureNoCharset = "http://jena.hpl.hp.com/2004/07/feature/noCharset" ; 26 27 static Map features = new HashMap() ; 28 static { 29 if ( System.getProperty(featureNoSecurity) != null ) 30 setFeature(featureNoSecurity) ; 31 if ( System.getProperty(featureNoCharset) != null ) 32 setFeature(featureNoCharset) ; 33 } 34 35 public static void setFeature(String featureName) { features.put(featureName, "true") ; } 36 public static boolean runUnder(String featureName) { return features.containsKey(featureName) ; } 37 public static boolean runNotUnder(String featureName) { return ! features.containsKey(featureName) ; } 38 39 40 static final String lineSeparator = getSystemProperty("line.separator", "\n") ; 41 public static String getLineSeparator() 42 { 43 return lineSeparator ; 44 } 45 46 public static String getSystemProperty(String propName) 47 { 48 return getSystemProperty(propName, null) ; 49 } 50 51 public static String getSystemProperty(String propName, String defaultValue) 52 { 53 try { 54 return System.getProperty(propName, defaultValue) ; 55 } catch (SecurityException ex) 56 { 57 if ( runUnder(featureNoSecurity)) 58 return defaultValue ; 59 try { 60 Object x = AccessController.doPrivileged( 61 new sun.security.action.GetPropertyAction(propName)); 62 return (String )x ; 63 } catch (Exception ex2) 64 { 65 return defaultValue ; 67 } 68 } 69 } 70 71 } 72 73 | Popular Tags |