W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2009

2006/unicorn/src/org/w3c/unicorn Test.java,1.1.2.3,1.1.2.4 Framework.java,1.1.2.2,1.1.2.3

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 12 Aug 2009 17:28:07 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MbHcN-0005cT-4b@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv21455/src/org/w3c/unicorn

Modified Files:
      Tag: dev2
	Test.java Framework.java 
Log Message:
language initialization

Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Attic/Framework.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- Framework.java	12 Aug 2009 13:15:18 -0000	1.1.2.2
+++ Framework.java	12 Aug 2009 17:28:05 -0000	1.1.2.3
@@ -15,8 +15,10 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -24,9 +26,11 @@
 import javax.xml.namespace.NamespaceContext;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
+import org.apache.velocity.VelocityContext;
 import org.w3c.unicorn.contract.Observer;
 import org.w3c.unicorn.contract.WADLUnmarshaller;
 import org.w3c.unicorn.contract.WADLUnmarshallerXPath;
+import org.w3c.unicorn.language.Language;
 import org.w3c.unicorn.output.OutputFactory;
 import org.w3c.unicorn.response.parser.ResponseParser;
 import org.w3c.unicorn.tasklist.RDFUnmarshaller;
@@ -60,7 +64,7 @@
 	/**
 	 * Properties of the framework
 	 */
-	public static Properties aPropertiesExtension;
+	//public static Properties aPropertiesExtension;
 
 	/**
 	 * List of availables output lang in PATH_TO_OUTPUT_TEMPLATES
@@ -87,6 +91,10 @@
 	 */
 	public static boolean isUcnInitialized = false;
 	
+	private static Hashtable<String, Properties> unicornPropertiesFiles;
+	private static Hashtable<String, VelocityContext> languageContexts;
+	private static Hashtable<String, Properties> languageProperties;
+	
 	/**
 	 * Initialize Unicorn
 	 * @throws Exception 
@@ -140,7 +148,7 @@
 			UCNProperties ucnProperties = new UCNProperties();
 			ucnProperties.put("UNICORN_HOME", unicornHome.getPath());
 			ucnProperties.load(unicornPropFile.toURI().toURL().openStream());
-			Property.getUnicornPropertiesFiles().put("unicorn.properties", ucnProperties);
+			unicornPropertiesFiles.put("unicorn.properties", ucnProperties);
 			//Property.setUnicornProps(ucnProperties);
 			logger.info("Unicorn properties file successfully loaded");
 			logger.debug("Loaded properties: " + ucnProperties);
@@ -171,12 +179,28 @@
 			} else {
 				Properties properties = new Properties();
 				properties.load(file.toURI().toURL().openStream());
-				Property.getUnicornPropertiesFiles().put(fileName, properties);
+				unicornPropertiesFiles.put(fileName, properties);
 				logger.info(fileName + " file successfully loaded");
 				logger.debug("Loaded properties: " + properties);
 			}
 		}
 		
+		if (!Language.isISOLanguageCode(Property.get("DEFAULT_LANGUAGE")))
+			logger.error("Property DEFAULT_LANGUAGE is not a valid ISO639 code: " + Property.get("DEFAULT_LANGUAGE"));
+		
+		File defaultLanguageFile = new File(Property.get("PATH_TO_LANGUAGE_FILES", "DEFAULT_LANGUAGE") + ".properties");
+		if (!defaultLanguageFile.exists()) {
+			logger.error("Default language file does not exists: " + Property.get("PATH_TO_LANGUAGE_FILES", "DEFAULT_LANGUAGE") + ".properties");
+		} 
+		
+		File[] languageFiles = ListFiles.listFiles(Property
+				.get("PATH_TO_LANGUAGE_FILES") + "/test", "\\.properties$");
+		
+		for (File langFile : languageFiles) {
+			Language.addLanguageFile(langFile);
+			
+		}
+		
 		TemplateHelper.init();
 		
 		// Initialize WADLUnmarshallerXPath (Gets the Namespace URI and the prefix)
@@ -244,7 +268,7 @@
 		//OutputFactory.init();
 		//IndexGenerator.init();
 			
-		Framework.aPropertiesExtension = Property.getProps("extensions.properties");
+		//Framework.aPropertiesExtension = Property.getProps("extensions.properties");
 		
 	    //Load the map of ResponseParser
 	 
@@ -404,4 +428,8 @@
 		Framework.logger.info("End of initialisation of UniCORN.");
 		isUcnInitialized = true;
 	}
+	
+	public static Hashtable<String, Properties> getUnicornPropertiesFiles() {
+		return unicornPropertiesFiles;
+	}
 }

Index: Test.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Attic/Test.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- Test.java	6 Aug 2009 12:46:57 -0000	1.1.2.3
+++ Test.java	12 Aug 2009 17:28:04 -0000	1.1.2.4
@@ -1,5 +1,6 @@
 package org.w3c.unicorn;
 
+import java.util.Locale;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -10,7 +11,7 @@
 	 */
 	public static void main(String[] args) {
 		// TODO Auto-generated method stub
-		String s = "${TEST} sdf zer ${TEST2}";
+		/*String s = "${TEST} sdf zer ${TEST2}";
 		System.out.println(s.matches("\\$\\{[a-zA-Z_0-9]*\\}"));
 		
 		Matcher matcher = Pattern.compile("\\$\\{[a-zA-Z_0-9]*\\}").matcher(s);
@@ -25,7 +26,11 @@
 		System.out.println(matcher.group(1));
 		System.out.println(matcher.lookingAt());
 		System.out.println(matcher.group());
-	     //replaceAll(repl)
+	     //replaceAll(repl)*/
+		
+		Locale loc = new Locale("sssqn");
+		
+		System.out.println("z" + loc.getLanguage());
 	}
 
 }
Received on Wednesday, 12 August 2009 17:28:16 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:38 UTC