2ronwalf// The MIT License
2ronwalf//
2ronwalf// Copyright (c) 2004 Evren Sirin
2ronwalf//
2ronwalf// Permission is hereby granted, free of charge, to any person obtaining a copy
2ronwalf// of this software and associated documentation files (the "Software"), to
2ronwalf// deal in the Software without restriction, including without limitation the
2ronwalf// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
2ronwalf// sell copies of the Software, and to permit persons to whom the Software is
2ronwalf// furnished to do so, subject to the following conditions:
2ronwalf//
2ronwalf// The above copyright notice and this permission notice shall be included in
2ronwalf// all copies or substantial portions of the Software.
2ronwalf//
2ronwalf// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2ronwalf// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2ronwalf// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2ronwalf// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2ronwalf// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2ronwalf// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2ronwalf// IN THE SOFTWARE.
2ronwalf
2ronwalf/*
2ronwalf * Created on Jan 15, 2004
2ronwalf */
2ronwalfpackage org.mindswap.owl;
2ronwalf
2ronwalfimport java.util.Arrays;
2ronwalfimport java.util.HashMap;
30daenzeroramaimport java.util.Hashtable;
2ronwalfimport java.util.List;
2ronwalfimport java.util.Map;
2ronwalf
2ronwalfimport org.mindswap.owls.OWLSFactory;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf */
2ronwalfpublic class OWLConfig {
2ronwalf /**
2ronwalf * Default language is used to determine which literal will be chosen by the
2ronwalf * getProperty(prop) function when there are multiple triples for the given
2ronwalf * property. An empty string means the literals with no language identifier
2ronwalf * will be chosen. A null value means the first found literal will be returned
2ronwalf * without looking at the language identifier. Note that even when a default
2ronwalf * language is chosen getProperty(prop, lang) can be used to get literal value
2ronwalf * for a certain identifier.
2ronwalf *
2ronwalf * All the language identifiers in the list will be tried in the order given.
2ronwalf * Original value for the list is
2ronwalf * DEFAULT_LANGS = {"en", "", "en", null};
2ronwalf * The ordering here works as follows:
2ronwalf * 1) Try the default language (which is English at the beginning but can be
2ronwalf * changed any time with setDefaultLanguage() function
2ronwalf * 2) Try to find literal with no language identifier
2ronwalf * 3) Try English literal
2ronwalf * 4) Try literal with any language identifier
2ronwalf *
2ronwalf * See http://www.w3.org/TR/REC-xml#sec-lang-tag for language identifier specs
2ronwalf */
2ronwalf public static String[] DEFAULT_LANGS = {"en", "", "en", null};
2ronwalf
2ronwalf public static List DEFAULT_LANG_LIST = Arrays.asList(DEFAULT_LANGS);
2ronwalf
2ronwalf /**
2ronwalf * Sets the default language that will be tried first when a literal property
2ronwalf * value is searched. Note that this function only sets the first language
2ronwalf * but there can be multiple languages defined as DEFAULT_LANGS.
2ronwalf *
2ronwalf * @param lang
2ronwalf */
2ronwalf public static void setDefaultLanguage(String lang) {
2ronwalf DEFAULT_LANGS[0] = lang;
2ronwalf }
2ronwalf
2ronwalf /**
2ronwalf * Sets all the languages that will be tried when a literal property values is
2ronwalf * searched. All the languages in the list wil lbe tried in the order given
2ronwalf *
2ronwalf * @param langs
2ronwalf */
2ronwalf public static void setDefaultLanguages(String[] langs) {
2ronwalf DEFAULT_LANGS = langs;
2ronwalf }
2ronwalf
2ronwalf
2ronwalf private static Map converters = getDefaultConverters();
2ronwalf private static boolean strictConversion = true;
2ronwalf
2ronwalf private static Map getDefaultConverters() {
2ronwalf Map converters = new HashMap();
2ronwalf converters.putAll(OWLFactory.getDefaultConverters());
2ronwalf converters.putAll(OWLSFactory.getDefaultConverters());
2ronwalf return converters;
2ronwalf }
2ronwalf
2ronwalf public static void addConverter(Class javaClass, OWLObjectConverter converter) {
2ronwalf converters.put(javaClass ,converter);
2ronwalf }
2ronwalf
2ronwalf public static OWLObjectConverter getConverter(Class javaClass) {
2ronwalf return (OWLObjectConverter) converters.get(javaClass);
2ronwalf }
2ronwalf
2ronwalf public static boolean setStrictConversion(boolean strict) {
2ronwalf boolean old = strictConversion;
2ronwalf strictConversion = strict;
2ronwalf
2ronwalf return old;
2ronwalf }
2ronwalf
2ronwalf public static boolean getStrictConversion() {
2ronwalf return strictConversion;
2ronwalf }
30daenzerorama
30daenzerorama private static Map transformators = new Hashtable();
30daenzerorama
30daenzerorama public static void addTransformator(OWLClass owlClass, OWLTransformator oWLTransformator) {
30daenzerorama transformators.put(owlClass, oWLTransformator);
30daenzerorama }
30daenzerorama
30daenzerorama public static OWLTransformator getTransformator(OWLClass owlClass) {
30daenzerorama return (OWLTransformator) transformators.get(owlClass);
30daenzerorama }
2ronwalf}