logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/examples/src/sort Sort.java
Date Tue, 07 Sep 2004 17:22:45 GMT
ceki        2004/09/07 10:22:45

  Modified:    examples/src/sort Sort.java
  Log:
  Indentation changes only
  
  Revision  Changes    Path
  1.2       +43 -24    logging-log4j/examples/src/sort/Sort.java
  
  Index: Sort.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/examples/src/sort/Sort.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Sort.java	22 Dec 2003 17:47:57 -0000	1.1
  +++ Sort.java	7 Sep 2004 17:22:45 -0000	1.2
  @@ -1,12 +1,29 @@
  +/*
  + * Copyright 1999,2004 The Apache Software Foundation.
  + *
  + * Licensed 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.
  + */
  +
   package sort;
   
  -import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.Logger;
  +import org.apache.log4j.PropertyConfigurator;
  +
   
   /**
      Example code for log4j to viewed in conjunction with the {@link
      examples.SortAlgo SortAlgo} class.
  -   
  +
      <p>This program expects a configuration file name as its first
      argument, and the size of the array to sort as the second and last
      argument. See its <b><a href="doc-files/Sort.java">source
  @@ -21,37 +38,40 @@
      href="doc-files/sort3.properties">sort3.properties</a> and <a
      href="doc-files/sort4.properties">sort4.properties</a> are supplied with the
      package.
  -   
  +
      <p>If you are also interested in logging performance, then have
      look at the {@link org.apache.log4j.performance.Logging} class.
   
      @author Ceki G&uuml;lc&uuml; */
  -
   public class Sort {
  -
     static Logger logger = Logger.getLogger(Sort.class.getName());
  -  
  +
     public static void main(String[] args) {
  -    if(args.length != 2) {
  +    if (args.length != 2) {
         usage("Incorrect number of parameters.");
       }
  +
       int arraySize = -1;
  +
       try {
         arraySize = Integer.valueOf(args[1]).intValue();
  -      if(arraySize <= 0) 
  -	usage("Negative array size.");
  -    }
  -    catch(java.lang.NumberFormatException e) {
  -      usage("Could not number format ["+args[1]+"].");
  +
  +      if (arraySize <= 0) {
  +        usage("Negative array size.");
  +      }
  +    } catch (java.lang.NumberFormatException e) {
  +      usage("Could not number format [" + args[1] + "].");
       }
   
       PropertyConfigurator.configure(args[0]);
   
       int[] intArray = new int[arraySize];
   
  -    logger.info("Populating an array of " + arraySize + " elements in" +
  -	     " reverse order.");
  -    for(int i = arraySize -1 ; i >= 0; i--) {
  +    logger.info(
  +      "Populating an array of " + arraySize + " elements in"
  +      + " reverse order.");
  +
  +    for (int i = arraySize - 1; i >= 0; i--) {
         intArray[i] = arraySize - i - 1;
       }
   
  @@ -62,17 +82,16 @@
       // We intentionally initilize sa2 with null.
       SortAlgo sa2 = new SortAlgo(null);
       logger.info("The next log statement should be an error message.");
  -    sa2.dump();  
  -    logger.info("Exiting main method.");    
  +    sa2.dump();
  +    logger.info("Exiting main method.");
     }
  -  
  -  static
  -  void usage(String errMsg) {
  +
  +  static void usage(String errMsg) {
       System.err.println(errMsg);
  -    System.err.println("\nUsage: java org.apache.examples.Sort " +
  -		       "configFile ARRAY_SIZE\n"+
  -      "where  configFile is a configuration file\n"+
  -      "      ARRAY_SIZE is a positive integer.\n");
  +    System.err.println(
  +      "\nUsage: java org.apache.examples.Sort " + "configFile ARRAY_SIZE\n"
  +      + "where  configFile is a configuration file\n"
  +      + "      ARRAY_SIZE is a positive integer.\n");
       System.exit(1);
     }
   }
  
  
  

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


Mime
View raw message