Source for org.jfree.report.JFreeReportInfo

   1: /**
   2:  * ========================================
   3:  * JFreeReport : a free Java report library
   4:  * ========================================
   5:  *
   6:  * Project Info:  http://reporting.pentaho.org/
   7:  *
   8:  * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
   9:  *
  10:  * This library is free software; you can redistribute it and/or modify it under the terms
  11:  * of the GNU Lesser General Public License as published by the Free Software Foundation;
  12:  * either version 2.1 of the License, or (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15:  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16:  * See the GNU Lesser General Public License for more details.
  17:  *
  18:  * You should have received a copy of the GNU Lesser General Public License along with this
  19:  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20:  * Boston, MA 02111-1307, USA.
  21:  *
  22:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  23:  * in the United States and other countries.]
  24:  *
  25:  * ------------
  26:  * $Id: JFreeReportInfo.java 3071 2007-07-30 18:08:28Z tmorgner $
  27:  * ------------
  28:  * (C) Copyright 2000-2005, by Object Refinery Limited.
  29:  * (C) Copyright 2005-2007, by Pentaho Corporation.
  30:  */
  31: 
  32: package org.jfree.report;
  33: 
  34: import java.util.Arrays;
  35: 
  36: import org.jfree.JCommon;
  37: import org.jfree.base.BootableProjectInfo;
  38: import org.jfree.formula.LibFormulaInfo;
  39: import org.jfree.layouting.LibLayoutInfo;
  40: import org.jfree.resourceloader.LibLoaderInfo;
  41: import org.jfree.serializer.JCommonSerializerInfo;
  42: import org.jfree.ui.about.Contributor;
  43: import org.jfree.ui.about.Licences;
  44: import org.jfree.ui.about.ProjectInfo;
  45: import org.jfree.util.ObjectUtilities;
  46: import org.jfree.xmlns.LibXmlInfo;
  47: 
  48: /**
  49:  * Details about the JFreeReport project.
  50:  *
  51:  * @author David Gilbert
  52:  */
  53: public class JFreeReportInfo extends ProjectInfo
  54: {
  55:   /**
  56:    * This namespace covers all current reporting structures. These structures
  57:    * are not being forwarded to libLayout and should be treated to be generally
  58:    * invisible for all non-liblayout output targets.
  59:    *
  60:    * This is not an XML namespace, so dont expect to see documents using that
  61:    * namespace. It is purely internal.
  62:    */
  63:   public static final String REPORT_NAMESPACE =
  64:           "http://jfreereport.sourceforge.net/namespaces/engine";
  65: 
  66:   /**
  67:    * This namespace contains the compatibility layer for the old JFreeReport
  68:    * structures.
  69:    *
  70:    * This is not an XML namespace, so dont expect to see documents using that
  71:    * namespace. It is purely internal.
  72:    */
  73:   public static final String COMPATIBILITY_NAMESPACE =
  74:           "http://jfreereport.sourceforge.net/namespaces/engine/compatibility";
  75: 
  76:   private static JFreeReportInfo instance;
  77: 
  78:   public static synchronized JFreeReportInfo getInstance()
  79:   {
  80:     if (instance == null)
  81:     {
  82:       instance = new JFreeReportInfo();
  83:     }
  84:     return instance;
  85:   }
  86: 
  87:   /**
  88:    * Constructs an object containing information about the JFreeReport project.
  89:    * <p/>
  90:    * Uses a resource bundle to localise some of the information.
  91:    */
  92:   private JFreeReportInfo ()
  93:   {
  94:     setName("JFreeReport");
  95:     setVersion("0.9.2");
  96:     setInfo("http://reporting.pentaho.org/");
  97:     setCopyright
  98:             ("(C)opyright 2000-2007, by Pentaho Corporation, Object Refinery Limited and Contributors");
  99: 
 100:     setContributors(Arrays.asList(new Contributor[]
 101:     {
 102:       new Contributor("David Gilbert", "david.gilbert@object-refinery.com"),
 103:       new Contributor("Thomas Morgner", "taqua@users.sourceforge.net"),
 104:       new Contributor("J\u00d6rg Sch\u00d6mer", "joerg.schoemer@nikocity.de"),
 105:       new Contributor("Heiko Evermann", "-"),
 106:       new Contributor("Piotr Bzdyl", "-"),
 107:       new Contributor("Patrice Rolland", "-"),
 108:       new Contributor("Cedric Pronzato", "mimil@users.sourceforge.get"),
 109:       new Contributor("Maciej Wegorkiewicz", "-"),
 110:       new Contributor("Michael Tennes", "michael@tennes.com"),
 111:       new Contributor("Dmitri Colebatch", "dimc@users.sourceforge.net"),
 112:       new Contributor("J\u00d6rg Schaible", "joehni@users.sourceforge.net"),
 113:       new Contributor("Marc Casas", "-"),
 114:       new Contributor("Ramon Juanes", "-"),
 115:       new Contributor("Demeter F. Tamas", "-"),
 116:       new Contributor("Hendri Smit", "-"),
 117:       new Contributor("Sergey M Mozgovoi", "-"),
 118:       new Contributor("Thomas Dilts", "-"),
 119:       new Contributor("Illka", "ipriha@users.sourceforge.net"),
 120:     }));
 121: 
 122:     addLibrary(JCommon.INFO);
 123:     addLibrary(JCommonSerializerInfo.getInstance());
 124:     addLibrary(LibLoaderInfo.getInstance());
 125:     addLibrary(LibLayoutInfo.getInstance());
 126:     addLibrary(LibFormulaInfo.getInstance());
 127:     addLibrary(LibXmlInfo.getInstance());
 128: 
 129:     final BootableProjectInfo pixieLibraryInfo = tryLoadPixieInfo();
 130:     if (pixieLibraryInfo != null)
 131:     {
 132:       addLibrary(pixieLibraryInfo);
 133:     }
 134:     final BootableProjectInfo libfontsLibraryInfo = tryLoadLibFontInfo();
 135:     if (libfontsLibraryInfo != null)
 136:     {
 137:       addLibrary(libfontsLibraryInfo);
 138:     }
 139: 
 140:     setBootClass(JFreeReportBoot.class.getName());
 141:   }
 142: 
 143:   /**
 144:    * Tries to load the Pixie boot classes. If the loading fails,
 145:    * this method returns null.
 146:    *
 147:    * @return the Pixie boot info, if Pixie is available.
 148:    */
 149:   private static BootableProjectInfo tryLoadPixieInfo ()
 150:   {
 151:     try
 152:     {
 153:       return (BootableProjectInfo) ObjectUtilities.loadAndInstantiate
 154:               ("org.jfree.pixie.PixieInfo", JFreeReportInfo.class,
 155:                   BootableProjectInfo.class);
 156:     }
 157:     catch (Exception e)
 158:     {
 159:       return null;
 160:     }
 161:   }
 162: 
 163:   /**
 164:    * Tries to load the libFonts boot classes. If the loading fails,
 165:    * this method returns null.
 166:    *
 167:    * @return the Pixie boot info, if Pixie is available.
 168:    */
 169:   private static BootableProjectInfo tryLoadLibFontInfo ()
 170:   {
 171:     try
 172:     {
 173:       return (BootableProjectInfo) ObjectUtilities.loadAndInstantiate
 174:               ("org.jfree.fonts.LibFontInfo",
 175:                   JFreeReportInfo.class, BootableProjectInfo.class);
 176:     }
 177:     catch (Exception e)
 178:     {
 179:       return null;
 180:     }
 181:   }
 182: 
 183:   /**
 184:    * Checks, whether the Pixie-library is available and in a working condition.
 185:    *
 186:    * @return true, if Pixie is available, false otherwise.
 187:    */
 188:   public static boolean isPixieAvailable ()
 189:   {
 190:     return tryLoadPixieInfo() != null;
 191:   }
 192: 
 193:   /**
 194:    * Tries to read the licence text from jcommon. This method does not reference jcommon
 195:    * directly, as this would increase the size of that class file.
 196:    *
 197:    * @return the licence text for this project.
 198:    *
 199:    * @see org.jfree.ui.about.ProjectInfo#getLicenceText()
 200:    */
 201:   public String getLicenceText ()
 202:   {
 203:     return Licences.getInstance().getLGPL();
 204:   }
 205: 
 206:   /**
 207:    * Print the library version and information about the library.
 208:    * <p/>
 209:    * After there seems to be confusion about which version is currently used by the user,
 210:    * this method will print the project information to clarify this issue.
 211:    *
 212:    * @param args ignored
 213:    */
 214:   public static void main (final String[] args)
 215:   {
 216:     final JFreeReportInfo info = new JFreeReportInfo();
 217:     System.out.println(info.getName() + " " + info.getVersion());
 218:     System.out.println("----------------------------------------------------------------");
 219:     System.out.println(info.getCopyright());
 220:     System.out.println(info.getInfo());
 221:     System.out.println("----------------------------------------------------------------");
 222:     System.out.println("This project is licenced under the terms of the "
 223:             + info.getLicenceName() + ".");
 224:     System.exit(0);
 225:   }
 226: }
 227: