- From: CVS User ylafon <cvsmail@w3.org>
- Date: Mon, 18 May 2015 08:52:38 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/util In directory roscoe:/var/tmp/cvs-serv20487/org/w3c/css/util Modified Files: Messages.java Log Message: added q unit (absolute length) per css3-values edcopy http://dev.w3.org/csswg/css-values-3/ added calc() parsing, more to be done on type checking... --- /sources/public/2002/css-validator/org/w3c/css/util/Messages.java 2012/08/04 21:17:07 1.44 +++ /sources/public/2002/css-validator/org/w3c/css/util/Messages.java 2015/05/18 08:52:38 1.45 @@ -1,5 +1,5 @@ // -// $Id: Messages.java,v 1.44 2012/08/04 21:17:07 ylafon Exp $ +// $Id: Messages.java,v 1.45 2015/05/18 08:52:38 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. @@ -13,564 +13,564 @@ import java.util.concurrent.ConcurrentHashMap; /** - * @version $Revision: 1.44 $ + * @version $Revision: 1.45 $ */ public class Messages { - /** - * Message properties - */ - public Utf8Properties<String, String> properties = null; - - public static final ConcurrentHashMap<String, Utf8Properties<String, String>> languages; - public static final ArrayList<String> languages_name; - - /** - * Creates a new Messages - */ - public Messages(String lang) { - if (lang != null) { - StringTokenizer lanTok = new StringTokenizer(lang, ","); - int maxTok = lanTok.countTokens(); - - String slang[] = new String[maxTok]; - float qlang[] = new float[maxTok]; - - // quick and dirty, it would be better to use Jigsaw's classes - while (lanTok.hasMoreTokens()) { - String l = lanTok.nextToken().trim().toLowerCase(); - int qualsep = l.indexOf(';'); - float qval = 1; - if (qualsep != -1) { - String p = l.substring(qualsep + 1); - l = l.substring(0, qualsep); - if (p.startsWith("q=")) { - qval = Float.parseFloat(p.substring(2)); - } - } - for (int i = 0; i < maxTok; i++) { - if (slang[i] == null) { - slang[i] = l; - qlang[i] = qval; - break; - } else if (qval > qlang[i]) { - System.arraycopy(slang, i, slang, i + 1, (maxTok - i - 1)); - System.arraycopy(qlang, i, qlang, i + 1, (maxTok - i - 1)); - slang[i] = l; - qlang[i] = qval; - break; - } - - } - } - for (int i = 0; i < maxTok; i++) { - String l = slang[i]; - properties = languages.get(l); - if (properties != null) { - break; - } - int minusIndex = l.indexOf('-'); - if (minusIndex != -1) { - // suppressed -cn in zh-cn (example) - l = l.substring(0, minusIndex); - properties = languages.get(l); - } - if (properties != null) { - break; - } - } - } - if (properties == null) { - properties = languages.get("en"); - } - } - - /** - * Get a property. - */ - public String getString(String message) { - return properties.getProperty(message); - } - - /** - * Get a warning property. - * - * @param message the warning property. - */ - public String getWarningString(String message) { - return getString("warning." + message); - } - - /** - * Get a warning level property. - * - * @param message the warning property. - */ - public String getWarningLevelString(String message) { - return getString(new StringBuilder("warning.").append(message).append(".level").toString()); - } - - /** - * Get an error property. - * - * @param message the error property. - */ - public String getErrorString(String message) { - return getString("error." + message); - } - - /** - * Get an generator property. - * - * @param message the generator property. - */ - public String getGeneratorString(String message) { - return getString("generator." + message); - } - - /** - * Get an generator property. - * - * @param message the generator property. - */ - public String getGeneratorString(String message, String param) { - String str = getString("generator." + message); - - // replace all parameters - int i = str.indexOf("%s"); - if (i >= 0) { - str = str.substring(0, i) + param + str.substring(i + 2); - } - return str; - } - - /** - * Get an generator property. - * - * @param message the generator property. - */ - public String getServletString(String message) { - return getString("servlet." + message); - } - - /** - * escape string - */ - static public String escapeString(String orig) { - if (orig != null) { - int len = orig.length(); - StringBuilder ret = new StringBuilder(len + 16); - char c; - - for (int i = 0; i < len; i++) { - switch (c = orig.charAt(i)) { - case '&': - ret.append("&"); - break; - case '\'': - ret.append("'"); - break; - case '"': - ret.append("""); - break; - case '<': - ret.append("<"); - break; - case '>': - ret.append(">"); - break; - default: - ret.append(c); - } - } - return ret.toString(); - } - return "[empty string]"; - } - - public String getString(String message, ArrayList<String> params) { - if ((params == null) || params.size() == 0) { - return getString(message); - } - String[] msg_parts = getString(message).split("%s", -1); - Iterator<String> param_it = params.iterator(); - StringBuilder sb = new StringBuilder(msg_parts[0]); - for (int i = 1; i < msg_parts.length; i++) { - if (param_it.hasNext()) { - sb.append(param_it.next()); - } - sb.append(msg_parts[i]); - } - return sb.toString(); - } - - static { - languages = new ConcurrentHashMap<String, Utf8Properties<String, String>>(); - languages_name = new ArrayList<String>(); - - Utf8Properties<String, String> tmp; - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.de"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("de"); - languages.put("de", tmp); - languages.put("de_DE", tmp); - languages.put("de_AT", tmp); - languages.put("de_CH", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties de"); - System.err.println(" " + e.toString()); - } - - // ------------------------------------------------ - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.en"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("en"); - languages.put("en", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties en"); - System.err.println(" " + e.toString()); - } - - // ------------------------------------------------ - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.es"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("es"); - languages.put("es", tmp); - languages.put("es_ES", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties es"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.fr"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("fr"); - languages.put("fr", tmp); - languages.put("fr_FR", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties fr"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.ko"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("ko"); - languages.put("ko", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties ko"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.it"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("it"); - languages.put("it", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties it"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.nl"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("nl"); - languages.put("nl", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties nl"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.ja"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("ja"); - languages.put("ja", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages:" + " couldn't load properties ja"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.pl-PL"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("pl-PL"); - languages.put("pl", tmp); - languages.put("pl_PL", tmp); - languages.put("pl-PL", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties pl"); - System.err.println(" " + e.toString()); - } - - // ----------------------- - - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.pt-BR"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("pt-BR"); - languages.put("pt-br", tmp); - languages.put("pt-BR", tmp); - languages.put("pt_BR", tmp); - languages.put("pt", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties pt-br"); - System.err.println(" " + e.toString()); - } - // ----------------------- - try { - java.io.InputStream f = Messages.class.getResourceAsStream("Messages.properties.ru"); - try { - tmp = new Utf8Properties<String, String>(); - tmp.load(f); - languages_name.add("ru"); - languages.put("ru", tmp); - } finally { - f.close(); - } - } catch (Exception e) { - System.err.println("org.w3c.css.util.Messages: " + "couldn't load properties ru"); [731 lines skipped]
Received on Monday, 18 May 2015 08:52:44 UTC