commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dflo...@apache.org
Subject svn commit: r154555 - jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml
Date Sun, 20 Feb 2005 18:21:03 GMT
Author: dflorey
Date: Sun Feb 20 10:21:02 2005
New Revision: 154555

URL: http://svn.apache.org/viewcvs?view=rev&rev=154555
Log:
Improved documentation

Modified:
    jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml

Modified: jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml?view=diff&r1=154554&r2=154555
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml (original)
+++ jakarta/commons/sandbox/i18n/trunk/xdocs/examples.xml Sun Feb 20 10:21:02 2005
@@ -9,42 +9,54 @@
 
  <body>
  
+<section name="Examples">
+<p>This page contains some examples showing the capabilities of the i18n-compoenent.
+Most of the examples can be found in the components sources in the example-package.</p>
+</section>
+
 <section name="Using localized exceptions">
 <p>
 The following example shows how to take advantage of detailed error information
 provided by localized exceptions. In the real world it is no good idea to create
-LocalizedExceptions but to create your own subclasses of LocalizedException.</p>
+LocalizedExceptions directly, but to create your own subclasses of LocalizedException.</p>
 <source>
 public class LocalizedExceptionExample {
-    private static final Logger logger = Logger.getLogger(LocalizedExceptionExample.class.getName());
+    private static final Logger logger = Logger
+            .getLogger(LocalizedExceptionExample.class.getName());
 
     public static void main(String[] args) {
-	    // Install the file providing the required messages for this example
-        XMLMessageProvider.install("org.apache.commons-i18n.examples", 
-        	Thread.currentThread().getContextClassLoader().getResourceAsStream("exampleMessages.xml"));
+        // Install the file providing the required messages for this example
+        XMLMessageProvider.install("org.apache.commons-i18n.examples", Thread
+                .currentThread().getContextClassLoader().getResourceAsStream(
+                        "exampleMessages.xml"));
 
-		// Simulate the locale of the current user in a multi-user environment
-		// such as a web application
+        // Simulate the locale of the current user in a multi-user environment
+        // such as a web application
         Locale currentUsersLocale = Locale.GERMAN;
-        
+
         // This is the real part dealing with localized exceptions
         try {
             someMethodThrowingAnException();
-        } catch ( LocalizedException exception ) {
-			// Retrieve the detailed localized error message
+        } catch (LocalizedException exception) {
+            // Retrieve the detailed localized error message
             ErrorBundle errorMessage = exception.getErrorMessage();
 
             // Print the summary of this error to the log with level SEVERE
             // using the VM default locale:
-            logger.log(Level.SEVERE, errorMessage.getSummary(Locale.getDefault()));
+            logger.log(Level.SEVERE, errorMessage.getSummary(Locale
+                    .getDefault()));
 
             // Print the details of this error to the log with level FINE
             // using the VM default locale:
-            logger.log(Level.FINE, errorMessage.getDetails(Locale.getDefault()));
+            logger
+                    .log(Level.FINE, errorMessage.getDetails(Locale
+                            .getDefault()));
 
-            // Provide the title of this error to the user in a highly visible way
+            // Provide the title of this error to the user in a highly visible
+            // way
             // using the current users locale:
-            System.out.println("#### "+errorMessage.getTitle(currentUsersLocale)+" ####");
+            System.out.println("#### "
+                    + errorMessage.getTitle(currentUsersLocale) + " ####");
 
             // Provide the text of this error to the user
             // using the current users locale:
@@ -53,17 +65,18 @@
     }
 
     /**
-     * @throws LocalizedException is thrown just to show the capabilities of LocalizedExceptions
+     * @throws LocalizedException
+     *             is thrown just to show the capabilities of
+     *             LocalizedExceptions
      */
-    private static void someMethodThrowingAnException() throws LocalizedException {
+    private static void someMethodThrowingAnException()
+            throws LocalizedException {
         String userCausingTheException = "Daniel";
-        throw new LocalizedException(
-                new ErrorBundle("theCauseOfThisException",
-                new String[] { userCausingTheException } ));
+        throw new LocalizedException(new ErrorBundle("theCauseOfThisException",
+                new String[]{userCausingTheException}));
     }
 }
 </source>
-</p>
 </section>
 
 <section name="Custom message bundles">



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message