You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/17 19:34:01 UTC
svn commit: r529682 - in /incubator/wicket/branches/wicket-1.x:
jdk-1.4/wicket/src/main/java/org/apache/wicket/
jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/
jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/
jdk-1.5/wicket-examples/src...
Author: ehillenius
Date: Tue Apr 17 10:33:59 2007
New Revision: 529682
URL: http://svn.apache.org/viewvc?view=rev&rev=529682
Log:
WICKET-477
Added:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml
Removed:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.properties
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.properties
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.properties
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.properties
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <!-- have to confirm whether this is really ok -->
+ <entry key="RequiredValidator">поле '${label}' обÑзаÑелÑно Ð´Ð»Ñ Ð²Ð²Ð¾Ð´Ð°.</entry>
+ <entry key="TypeValidator">'${input}' должно бÑÑÑ Ñипа ${type}.</entry>
+ <entry key="NumberValidator.range">${input} должно бÑÑÑ Ð¼ÐµÐ¶Ð´Ñ ${minimum} и ${maximum}.</entry>
+ <entry key="NumberValidator.minimum">'${input}' должно бÑÑÑ Ð±Ð¾Ð»ÑÑе Ñем ${minimum}.</entry>
+ <entry key="NumberValidator.maximum">'${input}' должно бÑÑÑ Ð¼ÐµÐ½ÑÑе Ñем ${maximum}.</entry>
+ <entry key="StringValidator.range">'${input}' должно бÑÑÑ Ð´Ð»Ð¸Ð½Ð¾Ð¹ Ð¾Ñ ${minimum} до ${maximum} Ñимволов(а).</entry>
+ <entry key="StringValidator.minimum">'${input}' должно бÑÑÑ Ð´Ð»Ð¸Ð½Ð¾Ð¹ не менÑÑе ${minimum} Ñимволов(а).</entry>
+ <entry key="StringValidator.maximum">'${input}' должно бÑÑÑ Ð´Ð»Ð¸Ð½Ð¾Ð¹ не менÑÑе ${maximum} Ñимволов(а).</entry>
+ <entry key="StringValidator.exact">'${input}' должно бÑÑÑ Ð´Ð»Ð¸Ð½Ð¾Ð¹ ${exact} Ñимвол(ов).</entry>
+ <entry key="DateValidator.range">даÑа '${input}' должна бÑÑÑ Ð¼ÐµÐ¶Ð´Ñ ${minimum} и ${maximum}.</entry>
+ <entry key="DateValidator.minimum">даÑа '${input}' должна бÑÑÑ Ð±Ð¾Ð»ÑÑе Ñем ${minimum}.</entry>
+ <entry key="DateValidator.maximum">даÑа '${input}' должна бÑÑÑ Ð¼ÐµÐ½ÑÑе Ñем ${maximum}.</entry>
+ <entry key="PatternValidator">'${input}' не ÑооÑвеÑÑÑвÑÐµÑ ÑÐ°Ð±Ð»Ð¾Ð½Ñ '${pattern}'.</entry>
+ <entry key="EmailAddressPatternValidator">'${input}' не ÑвлÑеÑÑÑ ÐºÐ¾ÑÑекÑнÑм поÑÑовÑм адÑеÑом.</entry>
+ <entry key="EqualInputValidator">'${input0}' из Ð¿Ð¾Ð»Ñ ${label0} и '${input1}' из Ð¿Ð¾Ð»Ñ ${label1} Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±ÑÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ñми.</entry>
+ <entry key="EqualPasswordInputValidator">Ð¿Ð¾Ð»Ñ ${label0} и ${label1} Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±ÑÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ñми.</entry>
+ <entry key="null">ÐÑбеÑиÑе знаÑение</entry>
+ <entry key="nullValid"></entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <!-- have to confirm whether this is really ok -->
+ <entry key="RequiredValidator">à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸ ${label} à¹à¸à¹à¸à¸à¸µà¹à¸à¹à¸à¸à¸à¸²à¸£.</entry>
+ <entry key="TypeValidator">à¹à¸¡à¹à¹à¸à¹ '${input}' à¸à¸µà¹à¹à¸à¹à¸à¸²à¸à¹à¸à¹à¸à¸£à¸´à¸ ${type}.</entry>
+ <entry key="NumberValidator.range">${input} à¸à¹à¸à¸à¸à¸¢à¸¹à¹à¸£à¸°à¸«à¸§à¹à¸²à¸ ${minimum} à¹à¸¥à¸° ${maximum}.</entry>
+ <entry key="NumberValidator.minimum">'${input}' à¸à¹à¸à¸à¸¡à¸²à¸à¸à¸§à¹à¸² ${minimum}.</entry>
+ <entry key="NumberValidator.maximum">'${input}' à¸à¹à¸à¸à¸à¹à¸à¸¢à¸à¸§à¹à¸² ${maximum}.</entry>
+ <entry key="StringValidator.range">'${input}' à¸à¹à¸à¸à¸à¸¢à¸¹à¹à¸£à¸°à¸«à¸§à¹à¸²à¸ ${minimum} à¹à¸¥à¸° ${maximum} chars.</entry>
+ <entry key="StringValidator.minimum">'${input}' à¸à¹à¸à¸à¸¡à¸µà¸à¸¢à¹à¸²à¸à¸à¹à¸à¸¢ ${minimum} à¸à¸±à¸§à¸à¸±à¸à¸©à¸£.</entry>
+ <entry key="StringValidator.maximum">'${input}' à¸à¹à¸à¸à¸¡à¸µà¹à¸¡à¹à¹à¸à¸´à¸ ${maximum} à¸à¸±à¸§à¸à¸±à¸à¸©à¸£.</entry>
+ <entry key="StringValidator.exact">'${input}' à¸à¹à¸à¸à¸¡à¸µ ${exact} à¸à¸§à¸²à¸¡à¸¢à¸²à¸§à¸à¸±à¸§à¸à¸±à¸à¸©à¸£.</entry>
+ <entry key="DateValidator.range">'${input}' must be between ${minimum} and ${maximum}.</entry>
+ <entry key="DateValidator.minimum">'${input}' must be greater than ${minimum}.</entry>
+ <entry key="DateValidator.maximum">'${input}' must be smaller than ${maximum}.</entry>
+ <entry key="PatternValidator">'${input}' à¹à¸¡à¹à¸à¸£à¸à¸à¸±à¸à¸£à¸¹à¸à¹à¸à¸ '${pattern}'</entry>
+ <entry key="EmailAddressPatternValidator">'${input}' à¹à¸¡à¹à¹à¸à¹à¸à¸µà¹à¸¡à¸¥à¸à¸µà¹à¹à¸à¹à¸à¸²à¸à¹à¸à¹à¸à¸£à¸´à¸.</entry>
+ <entry key="EqualInputValidator">'${input0}' à¸à¸²à¸ ${label0} à¹à¸¥à¸° '${input1}' à¸à¸²à¸ ${label1} à¸à¹à¸à¸à¹à¸à¹à¸²à¸à¸±à¸.</entry>
+ <entry key="EqualPasswordInputValidator">${label0} à¹à¸¥à¸° ${label1} à¸à¹à¸à¸à¹à¸à¹à¸²à¸à¸±à¸.</entry>
+ <entry key="null">à¹à¸¥à¸·à¸à¸à¸«à¸à¸¶à¹à¸à¸à¸¢à¹à¸²à¸</entry>
+ <entry key="nullValid"></entry>
+</properties>
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java Tue Apr 17 10:33:59 2007
@@ -29,10 +29,13 @@
import org.apache.wicket.Application;
import org.apache.wicket.settings.IResourceSettings;
import org.apache.wicket.util.concurrent.ConcurrentHashMap;
+import org.apache.wicket.util.io.Streams;
import org.apache.wicket.util.listener.IChangeListener;
+import org.apache.wicket.util.resource.IFixedLocationResourceStream;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
+import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.value.ValueMap;
import org.apache.wicket.util.watch.ModificationWatcher;
@@ -99,12 +102,13 @@
/**
*
- * @see org.apache.wicket.resource.IPropertiesFactory#load(java.lang.Class, java.lang.String)
+ * @see org.apache.wicket.resource.IPropertiesFactory#load(java.lang.Class,
+ * java.lang.String)
*/
public Properties load(final Class clazz, final String path)
{
// Check the cache
- Properties properties = (Properties) propertiesCache.get(path);
+ Properties properties = (Properties)propertiesCache.get(path);
if (properties != null)
{
// Return null, if no resource stream was found
@@ -165,15 +169,12 @@
{
// Make sure someone else didn't load our resources while we were
// waiting for the synchronized lock on the method
- Properties props = (Properties) propertiesCache.get(key);
+ Properties props = (Properties)propertiesCache.get(key);
if (props != null)
{
return props;
}
- // Do the resource load
- final java.util.Properties properties = new java.util.Properties();
-
if (resourceStream == null)
{
props = new Properties(key, ValueMap.EMPTY_MAP);
@@ -186,32 +187,33 @@
{
try
{
- // Get the InputStream
+ // Get the InputStream
BufferedInputStream in = new BufferedInputStream(resourceStream
.getInputStream());
-
+
// Determine if resource is a XML File
-// boolean loadAsXml = false;
-// if (resourceStream instanceof IFixedLocationResourceStream)
-// {
-// String location = ((IFixedLocationResourceStream)resourceStream)
-// .locationAsString();
-// if (location != null)
-// {
-// String ext = Strings.lastPathComponent(location, '.').toLowerCase();
-// if ("xml".equals(ext))
-// {
-// loadAsXml = true;
-// }
-// }
-// }
-//
-// // Load the properties
-// if (loadAsXml)
-// {
-// properties.loadFromXML(in);
-// }
-// else
+ boolean loadAsXml = false;
+ if (resourceStream instanceof IFixedLocationResourceStream)
+ {
+ String location = ((IFixedLocationResourceStream)resourceStream)
+ .locationAsString();
+ if (location != null)
+ {
+ String ext = Strings.lastPathComponent(location, '.').toLowerCase();
+ if ("xml".equals(ext))
+ {
+ loadAsXml = true;
+ }
+ }
+ }
+
+ // Load the properties
+ java.util.Properties properties = new java.util.Properties();
+ if (loadAsXml)
+ {
+ Streams.loadFromXml(properties, in);
+ }
+ else
{
properties.load(in);
}
@@ -273,7 +275,7 @@
+ "from the cache. Resource: " + resourceStream);
// Clear the whole cache as associated localized files may
- // be affected and may need reloading as well.
+ // be affected and may need reloading as well.
clearCache();
// Inform all listeners
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java Tue Apr 17 10:33:59 2007
@@ -22,6 +22,23 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
+import java.io.StringReader;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.wicket.WicketRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
/**
* Utilities methods for working with input and output streams.
@@ -30,6 +47,12 @@
*/
public final class Streams
{
+ private static final String XML_PROPERTIES_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<!-- DTD for properties -->" + "<!ELEMENT properties ( comment?, entry* ) >"
+ + "<!ATTLIST properties" + " version CDATA #FIXED \"1.0\">"
+ + "<!ELEMENT comment (#PCDATA) >" + "<!ELEMENT entry (#PCDATA) >" + "<!ATTLIST entry "
+ + " key CDATA #REQUIRED>";
+
/**
* Writes the input stream to the output stream. Input is done without a
* Reader object, meaning that the input is copied in its raw form.
@@ -56,6 +79,100 @@
bytesCopied += byteCount;
}
return bytesCopied;
+ }
+
+ /**
+ * Loads properties from an XML input stream into the provided properties
+ * object.
+ *
+ * @param properties
+ * The object to load the properties into
+ * @param inputStream
+ * @throws IOException
+ * When the input stream could not be read from
+ */
+ public static void loadFromXml(Properties properties, InputStream inputStream)
+ throws IOException
+ {
+ if (properties == null)
+ {
+ throw new IllegalArgumentException("properties must not be null");
+ }
+ if (inputStream == null)
+ {
+ throw new IllegalArgumentException("inputStream must not be null");
+ }
+
+ // TODO in a Wicket version that supports Java 5 (Wicket 2.0?), we can
+ // just use the loadFromXml method on java.util.Properties directly
+ // rather than manual as we do here
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setIgnoringElementContentWhitespace(true);
+ documentBuilderFactory.setValidating(true);
+ documentBuilderFactory.setCoalescing(true);
+ documentBuilderFactory.setIgnoringComments(true);
+ try
+ {
+ DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
+ db.setEntityResolver(new EntityResolver()
+ {
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException
+ {
+ if (systemId.equals("http://java.sun.com/dtd/properties.dtd"))
+ {
+ InputSource inputSource;
+ inputSource = new InputSource(new StringReader(XML_PROPERTIES_DTD));
+ inputSource.setSystemId("http://java.sun.com/dtd/properties.dtd");
+ return inputSource;
+ }
+ else
+ {
+ throw new SAXException("Invalid system identifier: " + systemId);
+ }
+ }
+ });
+ db.setErrorHandler(new ErrorHandler()
+ {
+ public void error(SAXParseException e) throws SAXException
+ {
+ throw e;
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException
+ {
+ throw e;
+ }
+
+ public void warning(SAXParseException e) throws SAXException
+ {
+ throw e;
+ }
+ });
+ InputSource is = new InputSource(inputStream);
+ Document doc = db.parse(is);
+ NodeList entries = ((Element)doc.getChildNodes().item(1)).getChildNodes();
+ int len = entries.getLength();
+ for (int i = (len > 0 && entries.item(0).getNodeName().equals("comment")) ? 1 : 0; i < len; i++)
+ {
+ Element entry = (Element)entries.item(i);
+ if (entry.hasAttribute("key"))
+ {
+ Node node = entry.getFirstChild();
+ String val = (node == null) ? "" : node.getNodeValue();
+ properties.setProperty(entry.getAttribute("key"), val);
+ }
+ }
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new WicketRuntimeException(e);
+ }
+ catch (SAXException e)
+ {
+ throw new WicketRuntimeException("invalid XML properties format", e);
+ }
}
/**
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java Tue Apr 17 10:33:59 2007
@@ -292,7 +292,9 @@
/** Relevant locales wrapped in a list. */
private static final List LOCALES = Arrays.asList(new Locale[] { Locale.ENGLISH,
- new Locale("nl"), Locale.GERMAN, new Locale("pt", "BR"), new Locale("da", "DK") });
+ new Locale("nl"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE,
+ new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"),
+ new Locale("th", "TH"), new Locale("ru") });
/** available sites for the multiple select. */
private static final List SITES = Arrays.asList(new String[] { "The Server Side", "Java Lobby",
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' er ikke en gyldig URL adresse</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' er ikke et gyldigt US telefonnummer</entry>
+ <entry key="use.locale">Brug locale:</entry>
+ <entry key="default">default</entry>
+ <entry key="input">Indtastningsform</entry>
+ <entry key="string">Tekststreng</entry>
+ <entry key="integer">Heltal</entry>
+ <entry key="double">Kommatal</entry>
+ <entry key="date">Dato</entry>
+ <entry key="boolean">Boolean</entry>
+ <entry key="value.between.0.and.100">Værdi mellem 0 og 100</entry>
+ <entry key="valid.url">URL adresse (skal være en gyldig URL)</entry>
+ <entry key="us.phone.number.mask">US telefonnummer (format: '(###) ###-####')</entry>
+ <entry key="select.a.number">Vælg et nummer</entry>
+ <entry key="select.one.or.more.numbers">Vælg et eller flere numre</entry>
+ <entry key="your.favorite.sites">Dine favorit sider</entry>
+ <entry key="save">Gem</entry>
+ <entry key="reset">Nulstil</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' ist keine gültige URL</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' nicht ist keine gültige US Telefonnummerุ</entry>
+ <entry key="use.locale">Locale:</entry>
+ <entry key="default">standard</entry>
+ <entry key="input">input</entry>
+ <entry key="string">String</entry>
+ <entry key="integer">Integer</entry>
+ <entry key="double">Double</entry>
+ <entry key="date">Datum</entry>
+ <entry key="boolean">Boolean</entry>
+ <entry key="value.between.0.and.100">Nur Werte zwischen 0 und 100 sind erlaubt</entry>
+ <entry key="valid.url">URL (muss eine gültige URL sein)</entry>
+ <entry key="us.phone.number.mask">Amerikanische Telefonnummer (mask: '(###) ###-####')</entry>
+ <entry key="select.a.number">Bitte eine Zahl auswählen</entry>
+ <entry key="select.one.or.more.numbers">Bitte eins oder mehr auswählen</entry>
+ <entry key="your.favorite.sites">Deine bevorzugten Seiten</entry>
+ <entry key="save">Sichern</entry>
+ <entry key="reset">Zurücksetzen</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' ÛÚ© آدرس Ù
عتبر ÙÙ
Û Ø¨Ø§Ø´Ø¯</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' ÛÚ© Ø´Ù
ار٠Ù
عتبر در اÛاÙات Ù
تØد٠ÙÙ
Û Ø¨Ø§Ø´à¸¸</entry>
+ <entry key="use.locale">استÙاد٠از Ù
ØÙÛ Ø³Ø§Ø²Û:</entry>
+ <entry key="default">standard</entry>
+ <entry key="input">ÙرÙ
ÙرÙدÛ</entry>
+ <entry key="string">رشتÙ</entry>
+ <entry key="integer">عدد صØÛØ</entry>
+ <entry key="double">Ø§Ø¹Ø´Ø§Ø±Û Ø¨Ø²Ø±Ú¯</entry>
+ <entry key="date">تارÛØ®</entry>
+ <entry key="boolean">Ù
تغÛر بÙÙÛ</entry>
+ <entry key="value.between.0.and.100">عدد بÛÙ 0 تا 100</entry>
+ <entry key="valid.url">آدرس (باÛد ÛÚ© آدرس Ù
عتبر باشد)</entry>
+ <entry key="us.phone.number.mask">Ø´Ù
ار٠تÙÙ٠اÛاÙات Ù
تØد٠(Ù
اسک: '(###) ###-####')</entry>
+ <entry key="select.a.number">ÛÚ© Ø´Ù
ار٠اÙتخاب Ú©ÙÛد</entry>
+ <entry key="select.one.or.more.numbers">ÛÚ© Ûا ÚÙد Ø´Ù
ار٠اÙتخاب Ú©ÙÛد (اÙتخاب گرÙÙÛ)</entry>
+ <entry key="your.favorite.sites">ساÛت ÙØ§Û Ù
ØبÙب Ø´Ù
ا</entry>
+ <entry key="save">ذخÙرÙ</entry>
+ <entry key="reset">بازÙشاÙÙ</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' ã¯æ£ããURLã§ã¯ããã¾ããã</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' ã¯æ£ããé»è©±çªå·ã§ã¯ããã¾ãããุ</entry>
+ <entry key="use.locale">使ç¨ãããã±ã¼ã«:</entry>
+ <entry key="default">standard</entry>
+ <entry key="input">input</entry>
+ <entry key="string">String</entry>
+ <entry key="integer">Integer</entry>
+ <entry key="double">Double</entry>
+ <entry key="date">Datum</entry>
+ <entry key="boolean">Boolean</entry>
+ <entry key="value.between.0.and.100">0ãã100ã®å¤</entry>
+ <entry key="valid.url">URL (æå¹ãªURLãå
¥åãã¦ãã ãã)</entry>
+ <entry key="us.phone.number.mask">é»è©±çªå· (å½¢å¼: '(###) ###-####')</entry>
+ <entry key="select.a.number">çªå·ãé¸æãã¦ãã ãã</entry>
+ <entry key="select.one.or.more.numbers">1ã¤ä»¥ä¸ã®çªå·ãé¸æãã¦ãã ãã</entry>
+ <entry key="your.favorite.sites">ãæ°ã«å
¥ã</entry>
+ <entry key="save">ä¿å</entry>
+ <entry key="reset">ãªã»ãã</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' não é uma URL válida</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' não é um telefone válido</entry>
+ <entry key="use.locale">Usar localização:</entry>
+ <entry key="default">padrão</entry>
+ <entry key="input">Formulário</entry>
+ <entry key="string">Texto</entry>
+ <entry key="integer">Inteiro</entry>
+ <entry key="double">Double</entry>
+ <entry key="date">Data</entry>
+ <entry key="boolean">Booleano</entry>
+ <entry key="value.between.0.and.100">Valor entre 0 e 100</entry>
+ <entry key="valid.url">URL (deve ser uma url válida)</entry>
+ <entry key="us.phone.number.mask">Número Telefônico EUA (máscara: '(###) ###-####')</entry>
+ <entry key="select.a.number">Selecione um número</entry>
+ <entry key="select.one.or.more.numbers">Selecione hum ou mais números</entry>
+ <entry key="your.favorite.sites">Seus sites favoritos</entry>
+ <entry key="save">Save</entry>
+ <entry key="reset">Reset</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' не ÑвлÑеÑÑÑ ÐºÐ¾ÑÑекÑнÑм URL</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' не ÑвлÑеÑÑÑ ÐºÐ¾ÑÑекÑнÑм ÑелеÑоннÑм номеÑом СШÐ</entry>
+ <entry key="use.locale">ÐокалÑ:</entry>
+ <entry key="default">по-ÑмолÑаниÑ</entry>
+ <entry key="input">Ðвод</entry>
+ <entry key="string">String</entry>
+ <entry key="integer">Integer</entry>
+ <entry key="double">Double</entry>
+ <entry key="date">ÐаÑа</entry>
+ <entry key="boolean">Boolean</entry>
+ <entry key="value.between.0.and.100">ЧиÑло Ð¼ÐµÐ¶Ð´Ñ 0 и 100</entry>
+ <entry key="valid.url">URL (должен бÑÑÑ ÐºÐ¾ÑÑекÑнÑм URL)</entry>
+ <entry key="us.phone.number.mask">ТелеÑоннÑй Ð½Ð¾Ð¼ÐµÑ Ð¡Ð¨Ð (маÑка: '(###) ###-####')</entry>
+ <entry key="select.a.number">ÐÑбеÑиÑе ÑиÑло</entry>
+ <entry key="select.one.or.more.numbers">ÐÑбеÑиÑе одно или неÑколÑко ÑиÑел</entry>
+ <entry key="your.favorite.sites">ÐÑбимÑе ÑайÑÑ</entry>
+ <entry key="save">СоÑ
ÑаниÑÑ</entry>
+ <entry key="reset">СбÑоÑ</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' à¹à¸¡à¹à¹à¸ URL à¸à¸µà¹à¹à¸à¹à¸à¸²à¸à¹à¸à¹à¸à¸£à¸´à¸</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' à¹à¸¡à¹à¹à¸à¹à¸«à¸¡à¸²à¸¢à¹à¸¥à¸à¹à¸à¸£à¸¨à¸±à¸à¸à¹à¸à¸µà¹à¹à¸à¹à¸à¸²à¸à¹à¸</entry>
+ <entry key="use.locale">à¹à¸¥à¸·à¸à¸à¹à¸à¹à¸ าษาหลัà¸:</entry>
+ <entry key="default">à¸à¹à¸²à¸¡à¸²à¸à¸£à¸à¸²à¸</entry>
+ <entry key="input">à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸³à¹à¸à¹à¸²</entry>
+ <entry key="string">à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸à¸´à¸à¸à¹à¸à¸à¸§à¸²à¸¡</entry>
+ <entry key="integer">à¸à¸³à¸à¸§à¸à¹à¸à¹à¸¡</entry>
+ <entry key="double">Double</entry>
+ <entry key="date">วัà¸à¸à¸µ</entry>
+ <entry key="boolean">Boolean</entry>
+ <entry key="value.between.0.and.100">à¸à¹à¸²à¸£à¸°à¸«à¸§à¹à¸²à¸ 0 à¹à¸¥à¸° 100</entry>
+ <entry key="valid.url">URL (à¸à¹à¸à¸à¹à¸à¹à¸ URL à¸à¸µà¹à¹à¸à¹à¸à¸²à¸à¹à¸)</entry>
+ <entry key="us.phone.number.mask">หมายà¹à¸¥à¸à¹à¸à¸£à¸¨à¸±à¸à¸à¹ (รูà¸à¹à¸à¸: '(###) ###-####')</entry>
+ <entry key="select.a.number">à¹à¸¥à¸·à¸à¸à¸à¸±à¸§à¹à¸¥à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸§</entry>
+ <entry key="select.one.or.more.numbers">à¹à¸¥à¸·à¸à¸à¸à¸±à¸§à¹à¸¥à¸à¸«à¸à¸¶à¹à¸à¸à¸±à¸§à¸«à¸£à¸·à¸à¸¡à¸²à¸à¸à¸§à¹à¸²</entry>
+ <entry key="your.favorite.sites">à¹à¸§à¸à¹à¸à¸à¹à¸à¸µà¹à¸à¸à¸</entry>
+ <entry key="save">à¸à¸±à¸à¸à¸¶à¸</entry>
+ <entry key="reset">ลà¹à¸²à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸à¸·à¹à¸à¹à¸£à¸´à¹à¸¡à¹à¸«à¸¡</entry>
+</properties>
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="inputForm.urlProperty.TypeValidator">'${input}' ä¸æ¯åæ³çURL</entry>
+ <entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' ä¸æ¯ä¸ä¸ªåæ³çç¾å½çµè¯å·ç ุ</entry>
+ <entry key="use.locale">使ç¨å°ç¹:</entry>
+ <entry key="default">缺ç</entry>
+ <entry key="input">è¾å
¥</entry>
+ <entry key="string">å符串</entry>
+ <entry key="integer">æ´æ°</entry>
+ <entry key="double">æ°å</entry>
+ <entry key="date">æ¥æ</entry>
+ <entry key="boolean">å¸å°å¼</entry>
+ <entry key="value.between.0.and.100">å¨ 0 å 100 ä¹é´çæ´æ°</entry>
+ <entry key="valid.url">URL (å¿
é¡»æ¯åæ³çURL)</entry>
+ <entry key="us.phone.number.mask">ç¾å½çµè¯å·ç (æ ¼å¼: '(###) ###-####')</entry>
+ <entry key="select.a.number">éæ©ä¸ä¸ªæ°å</entry>
+ <entry key="select.one.or.more.numbers">éæ©ä¸ä¸ªæå¤ä¸ªæ°å</entry>
+ <entry key="your.favorite.sites">æ¨åç±çç½ç«</entry>
+ <entry key="save">ä¿å</entry>
+ <entry key="reset">éç½®</entry>
+</properties>
\ No newline at end of file
Re: WICKET-477 (Was: svn commit: r529682 - in /incubator/wicket/branches/wicket-1.x: jdk-1.4/wicket/src/main/java/org/apache/wicket/ jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/ jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/ jdk-1.5/wicket-examples/src...)
Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* ehillenius@apache.org:
> Author: ehillenius
> Date: Tue Apr 17 10:33:59 2007
> New Revision: 529682
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=529682
> Log:
> WICKET-477
>
> Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
> URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java?view=diff&rev=529682&r1=529681&r2=529682
> ==============================================================================
> --- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java (original)
> +++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java Tue Apr 17 10:33:59 2007
> @@ -22,6 +22,23 @@
> import java.io.InputStreamReader;
> import java.io.OutputStream;
> import java.io.Reader;
> +import java.io.StringReader;
> +import java.util.Properties;
> +
> +import javax.xml.parsers.DocumentBuilder;
> +import javax.xml.parsers.DocumentBuilderFactory;
> +import javax.xml.parsers.ParserConfigurationException;
> +
> +import org.apache.wicket.WicketRuntimeException;
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
> +import org.xml.sax.EntityResolver;
> +import org.xml.sax.ErrorHandler;
> +import org.xml.sax.InputSource;
> +import org.xml.sax.SAXException;
> +import org.xml.sax.SAXParseException;
>
> /**
> * Utilities methods for working with input and output streams.
> @@ -30,6 +47,12 @@
> */
> public final class Streams
> {
> + private static final String XML_PROPERTIES_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> + + "<!-- DTD for properties -->" + "<!ELEMENT properties ( comment?, entry* ) >"
> + + "<!ATTLIST properties" + " version CDATA #FIXED \"1.0\">"
> + + "<!ELEMENT comment (#PCDATA) >" + "<!ELEMENT entry (#PCDATA) >" + "<!ATTLIST entry "
> + + " key CDATA #REQUIRED>";
> +
> /**
> * Writes the input stream to the output stream. Input is done without a
> * Reader object, meaning that the input is copied in its raw form.
> @@ -56,6 +79,100 @@
> bytesCopied += byteCount;
> }
> return bytesCopied;
> + }
> +
> + /**
> + * Loads properties from an XML input stream into the provided properties
> + * object.
> + *
> + * @param properties
> + * The object to load the properties into
> + * @param inputStream
> + * @throws IOException
> + * When the input stream could not be read from
> + */
> + public static void loadFromXml(Properties properties, InputStream inputStream)
> + throws IOException
> + {
> + if (properties == null)
> + {
> + throw new IllegalArgumentException("properties must not be null");
> + }
> + if (inputStream == null)
> + {
> + throw new IllegalArgumentException("inputStream must not be null");
> + }
> +
> + // TODO in a Wicket version that supports Java 5 (Wicket 2.0?), we can
> + // just use the loadFromXml method on java.util.Properties directly
> + // rather than manual as we do here
> +
> + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
> + documentBuilderFactory.setIgnoringElementContentWhitespace(true);
> + documentBuilderFactory.setValidating(true);
> + documentBuilderFactory.setCoalescing(true);
> + documentBuilderFactory.setIgnoringComments(true);
> + try
> + {
> + DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
> + db.setEntityResolver(new EntityResolver()
> + {
> + public InputSource resolveEntity(String publicId, String systemId)
> + throws SAXException
> + {
> + if (systemId.equals("http://java.sun.com/dtd/properties.dtd"))
> + {
> + InputSource inputSource;
> + inputSource = new InputSource(new StringReader(XML_PROPERTIES_DTD));
> + inputSource.setSystemId("http://java.sun.com/dtd/properties.dtd");
> + return inputSource;
> + }
> + else
> + {
> + throw new SAXException("Invalid system identifier: " + systemId);
> + }
> + }
> + });
> + db.setErrorHandler(new ErrorHandler()
> + {
> + public void error(SAXParseException e) throws SAXException
> + {
> + throw e;
> + }
> +
> + public void fatalError(SAXParseException e) throws SAXException
> + {
> + throw e;
> + }
> +
> + public void warning(SAXParseException e) throws SAXException
> + {
> + throw e;
> + }
> + });
> + InputSource is = new InputSource(inputStream);
> + Document doc = db.parse(is);
> + NodeList entries = ((Element)doc.getChildNodes().item(1)).getChildNodes();
> + int len = entries.getLength();
> + for (int i = (len > 0 && entries.item(0).getNodeName().equals("comment")) ? 1 : 0; i < len; i++)
> + {
> + Element entry = (Element)entries.item(i);
> + if (entry.hasAttribute("key"))
> + {
> + Node node = entry.getFirstChild();
> + String val = (node == null) ? "" : node.getNodeValue();
> + properties.setProperty(entry.getAttribute("key"), val);
> + }
> + }
> + }
> + catch (ParserConfigurationException e)
> + {
> + throw new WicketRuntimeException(e);
> + }
> + catch (SAXException e)
> + {
> + throw new WicketRuntimeException("invalid XML properties format", e);
> + }
> }
Hi Eelco,
Indeed it would be good to use the native XML properties loading
on 1.5. And on 1.4, do you think it's OK to use DOM? We could as
well use our pseudo-Stax parser for maximal efficiency.
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/