001    /**
002     * ========================================
003     * JFreeReport : a free Java report library
004     * ========================================
005     *
006     * Project Info:  http://reporting.pentaho.org/
007     *
008     * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
009     *
010     * This library is free software; you can redistribute it and/or modify it under the terms
011     * of the GNU Lesser General Public License as published by the Free Software Foundation;
012     * either version 2.1 of the License, or (at your option) any later version.
013     *
014     * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016     * See the GNU Lesser General Public License for more details.
017     *
018     * You should have received a copy of the GNU Lesser General Public License along with this
019     * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020     * Boston, MA 02111-1307, USA.
021     *
022     * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023     * in the United States and other countries.]
024     *
025     * ------------
026     * $Id: JFreeReportInfo.java 3071 2007-07-30 18:08:28Z tmorgner $
027     * ------------
028     * (C) Copyright 2000-2005, by Object Refinery Limited.
029     * (C) Copyright 2005-2007, by Pentaho Corporation.
030     */
031    
032    package org.jfree.report;
033    
034    import java.util.Arrays;
035    
036    import org.jfree.JCommon;
037    import org.jfree.base.BootableProjectInfo;
038    import org.jfree.formula.LibFormulaInfo;
039    import org.jfree.layouting.LibLayoutInfo;
040    import org.jfree.resourceloader.LibLoaderInfo;
041    import org.jfree.serializer.JCommonSerializerInfo;
042    import org.jfree.ui.about.Contributor;
043    import org.jfree.ui.about.Licences;
044    import org.jfree.ui.about.ProjectInfo;
045    import org.jfree.util.ObjectUtilities;
046    import org.jfree.xmlns.LibXmlInfo;
047    
048    /**
049     * Details about the JFreeReport project.
050     *
051     * @author David Gilbert
052     */
053    public class JFreeReportInfo extends ProjectInfo
054    {
055      /**
056       * This namespace covers all current reporting structures. These structures
057       * are not being forwarded to libLayout and should be treated to be generally
058       * invisible for all non-liblayout output targets.
059       *
060       * This is not an XML namespace, so dont expect to see documents using that
061       * namespace. It is purely internal.
062       */
063      public static final String REPORT_NAMESPACE =
064              "http://jfreereport.sourceforge.net/namespaces/engine";
065    
066      /**
067       * This namespace contains the compatibility layer for the old JFreeReport
068       * structures.
069       *
070       * This is not an XML namespace, so dont expect to see documents using that
071       * namespace. It is purely internal.
072       */
073      public static final String COMPATIBILITY_NAMESPACE =
074              "http://jfreereport.sourceforge.net/namespaces/engine/compatibility";
075    
076      private static JFreeReportInfo instance;
077    
078      public static synchronized JFreeReportInfo getInstance()
079      {
080        if (instance == null)
081        {
082          instance = new JFreeReportInfo();
083        }
084        return instance;
085      }
086    
087      /**
088       * Constructs an object containing information about the JFreeReport project.
089       * <p/>
090       * Uses a resource bundle to localise some of the information.
091       */
092      private JFreeReportInfo ()
093      {
094        setName("JFreeReport");
095        setVersion("0.9.2");
096        setInfo("http://reporting.pentaho.org/");
097        setCopyright
098                ("(C)opyright 2000-2007, by Pentaho Corporation, Object Refinery Limited and Contributors");
099    
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