View Javadoc

1   /*
2    * $Id: AsciiTableSupport.java,v 1.1 2005/03/21 18:45:55 mch Exp $
3    *
4    * (C) Copyright Astrogrid...
5    */
6   
7   package org.astrogrid.tableserver.out;
8   import java.text.DateFormat;
9   import java.text.SimpleDateFormat;
10  import org.astrogrid.cfg.ConfigFactory;
11  
12  /***
13   * Provides some methods for writing tables in ASCII text. Mostly help for
14   * dates.
15   *
16   * @author M Hill
17   */
18  
19  public abstract class AsciiTableSupport implements TableWriter {
20     
21     /*** Key used to configure date formats */
22     public static final String DATE_FORMAT_KEY = "default.date.pattern";
23  
24     protected static final String defaultDatePattern = "yyyy-MM-dd'T'HH:mm:ss";
25     protected DateFormat dateFormat = null;
26  
27     protected AsciiTableSupport() {
28        dateFormat = new SimpleDateFormat(ConfigFactory.getCommonConfig().getString(DATE_FORMAT_KEY, defaultDatePattern));
29        
30     }
31     
32     /*** Returns an empty string if the given string is null, otherwise returns
33      * the string.  Prevents annoying 'null' turning up if there is no entry. In
34      *  general, use it for header info; for cell values, it's best to use something
35      * to distinguish between 'no value' and 'empty value'
36      */
37     public String emptyIfNull(String s) {
38        if (s==null) return ""; else return s;
39     }
40              
41     
42     
43  }
44  
45  /*
46   $Log: AsciiTableSupport.java,v $
47   Revision 1.1  2005/03/21 18:45:55  mch
48   Naughty big lump of changes
49  
50   Revision 1.1.1.1  2005/02/17 18:37:34  mch
51   Initial checkin
52  
53   Revision 1.1.1.1  2005/02/16 17:11:24  mch
54   Initial checkin
55  
56   Revision 1.1.2.1  2005/02/11 15:58:27  mch
57   Some fixes before split
58  
59  
60  
61   */
62  
63  
64  
65  
66  
67  
68