W3C home > Mailing lists > Public > www-validator-cvs@w3.org > February 2008

2006/unicorn/org/w3c/unicorn/util LocalizedString.java,1.2,1.3

From: Hiep Duong via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 20 Feb 2008 15:10:01 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1JRqa9-0007zk-5r@lionel-hutz.w3.org>

Update of /sources/public/2006/unicorn/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv30553/org/w3c/unicorn/util

Modified Files:
	LocalizedString.java 
Log Message:
simplified observationresponse and generalize output format (now we can map a format type what defnied in the contract to a ResponseParser)

Index: LocalizedString.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/util/LocalizedString.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- LocalizedString.java	29 Sep 2006 09:25:12 -0000	1.2
+++ LocalizedString.java	20 Feb 2008 15:09:59 -0000	1.3
@@ -29,6 +29,11 @@
 		this.mapOfString = new LinkedHashMap<String, String>();
 	}
 
+	public LocalizedString (String s, String lang) {
+		this();
+		mapOfString.put(lang, s);
+	}
+	
 	public boolean hasLocale (final String sLocale) {
 		return null != this.mapOfString.get(sLocale);
 	}
@@ -56,8 +61,18 @@
 		return this.mapOfString.keySet();
 	}
 
+	// return the message in DEFAULT_LANGUAGE (en) or in the first language in
+	// the list
 	public String toString () {
-		return this.mapOfString.get(LocalizedString.DEFAULT_LANGUAGE);
+		String res = this.mapOfString.get(LocalizedString.DEFAULT_LANGUAGE);
+		if (res==null) {
+			for (String s: this.mapOfString.values()) {
+				return s; 
+			}
+		}
+		if (res==null)
+			return "";
+		return res;
 	}
 
 }
Received on Wednesday, 20 February 2008 15:10:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:00 GMT