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: */package org.jfree.report;
031:
032: import java.util.Arrays;
033:
034: import org.jfree.JCommon;
035: import org.jfree.base.BootableProjectInfo;
036: import org.jfree.formula.LibFormulaInfo;
037: import org.jfree.layouting.LibLayoutInfo;
038: import org.jfree.resourceloader.LibLoaderInfo;
039: import org.jfree.serializer.JCommonSerializerInfo;
040: import org.jfree.ui.about.Contributor;
041: import org.jfree.ui.about.Licences;
042: import org.jfree.ui.about.ProjectInfo;
043: import org.jfree.util.ObjectUtilities;
044: import org.jfree.xmlns.LibXmlInfo;
045:
046: /**
047: * Details about the JFreeReport project.
048: *
049: * @author David Gilbert
050: */
051: public class JFreeReportInfo extends ProjectInfo {
052: /**
053: * This namespace covers all current reporting structures. These structures
054: * are not being forwarded to libLayout and should be treated to be generally
055: * invisible for all non-liblayout output targets.
056: *
057: * This is not an XML namespace, so dont expect to see documents using that
058: * namespace. It is purely internal.
059: */
060: public static final String REPORT_NAMESPACE = "http://jfreereport.sourceforge.net/namespaces/engine";
061:
062: /**
063: * This namespace contains the compatibility layer for the old JFreeReport
064: * structures.
065: *
066: * This is not an XML namespace, so dont expect to see documents using that
067: * namespace. It is purely internal.
068: */
069: public static final String COMPATIBILITY_NAMESPACE = "http://jfreereport.sourceforge.net/namespaces/engine/compatibility";
070:
071: private static JFreeReportInfo instance;
072:
073: public static synchronized JFreeReportInfo getInstance() {
074: if (instance == null) {
075: instance = new JFreeReportInfo();
076: }
077: return instance;
078: }
079:
080: /**
081: * Constructs an object containing information about the JFreeReport project.
082: * <p/>
083: * Uses a resource bundle to localise some of the information.
084: */
085: private JFreeReportInfo() {
086: setName("JFreeReport");
087: setVersion("0.9.3");
088: setInfo("http://reporting.pentaho.org/");
089: setCopyright("(C)opyright 2000-2007, by Pentaho Corporation, Object Refinery Limited and Contributors");
090:
091: setContributors(Arrays
092: .asList(new Contributor[] {
093: new Contributor("David Gilbert",
094: "david.gilbert@object-refinery.com"),
095: new Contributor("Thomas Morgner",
096: "taqua@users.sourceforge.net"),
097: new Contributor("J\u00d6rg Sch\u00d6mer",
098: "joerg.schoemer@nikocity.de"),
099: new Contributor("Heiko Evermann", "-"),
100: new Contributor("Piotr Bzdyl", "-"),
101: new Contributor("Patrice Rolland", "-"),
102: new Contributor("Cedric Pronzato",
103: "mimil@users.sourceforge.get"),
104: new Contributor("Maciej Wegorkiewicz", "-"),
105: new Contributor("Michael Tennes",
106: "michael@tennes.com"),
107: new Contributor("Dmitri Colebatch",
108: "dimc@users.sourceforge.net"),
109: new Contributor("J\u00d6rg Schaible",
110: "joehni@users.sourceforge.net"),
111: new Contributor("Marc Casas", "-"),
112: new Contributor("Ramon Juanes", "-"),
113: new Contributor("Demeter F. Tamas", "-"),
114: new Contributor("Hendri Smit", "-"),
115: new Contributor("Sergey M Mozgovoi", "-"),
116: new Contributor("Thomas Dilts", "-"),
117: new Contributor("Illka",
118: "ipriha@users.sourceforge.net"), }));
119:
120: addLibrary(JCommon.INFO);
121: addLibrary(JCommonSerializerInfo.getInstance());
122: addLibrary(LibLoaderInfo.getInstance());
123: addLibrary(LibLayoutInfo.getInstance());
124: addLibrary(LibFormulaInfo.getInstance());
125: addLibrary(LibXmlInfo.getInstance());
126:
127: final BootableProjectInfo pixieLibraryInfo = tryLoadPixieInfo();
128: if (pixieLibraryInfo != null) {
129: addLibrary(pixieLibraryInfo);
130: }
131: final BootableProjectInfo libfontsLibraryInfo = tryLoadLibFontInfo();
132: if (libfontsLibraryInfo != null) {
133: addLibrary(libfontsLibraryInfo);
134: }
135:
136: setBootClass(JFreeReportBoot.class.getName());
137: }
138:
139: /**
140: * Tries to load the Pixie boot classes. If the loading fails,
141: * this method returns null.
142: *
143: * @return the Pixie boot info, if Pixie is available.
144: */
145: private static BootableProjectInfo tryLoadPixieInfo() {
146: try {
147: return (BootableProjectInfo) ObjectUtilities
148: .loadAndInstantiate("org.jfree.pixie.PixieInfo",
149: JFreeReportInfo.class,
150: BootableProjectInfo.class);
151: } catch (Exception e) {
152: return null;
153: }
154: }
155:
156: /**
157: * Tries to load the libFonts boot classes. If the loading fails,
158: * this method returns null.
159: *
160: * @return the Pixie boot info, if Pixie is available.
161: */
162: private static BootableProjectInfo tryLoadLibFontInfo() {
163: try {
164: return (BootableProjectInfo) ObjectUtilities
165: .loadAndInstantiate("org.jfree.fonts.LibFontInfo",
166: JFreeReportInfo.class,
167: BootableProjectInfo.class);
168: } catch (Exception e) {
169: return null;
170: }
171: }
172:
173: /**
174: * Checks, whether the Pixie-library is available and in a working condition.
175: *
176: * @return true, if Pixie is available, false otherwise.
177: */
178: public static boolean isPixieAvailable() {
179: return tryLoadPixieInfo() != null;
180: }
181:
182: /**
183: * Tries to read the licence text from jcommon. This method does not reference jcommon
184: * directly, as this would increase the size of that class file.
185: *
186: * @return the licence text for this project.
187: *
188: * @see org.jfree.ui.about.ProjectInfo#getLicenceText()
189: */
190: public String getLicenceText() {
191: return Licences.getInstance().getLGPL();
192: }
193:
194: /**
195: * Print the library version and information about the library.
196: * <p/>
197: * After there seems to be confusion about which version is currently used by the user,
198: * this method will print the project information to clarify this issue.
199: *
200: * @param args ignored
201: */
202: public static void main(final String[] args) {
203: final JFreeReportInfo info = new JFreeReportInfo();
204: System.out.println(info.getName() + " " + info.getVersion());
205: System.out
206: .println("----------------------------------------------------------------");
207: System.out.println(info.getCopyright());
208: System.out.println(info.getInfo());
209: System.out
210: .println("----------------------------------------------------------------");
211: System.out
212: .println("This project is licenced under the terms of the "
213: + info.getLicenceName() + ".");
214: System.exit(0);
215: }
216: }
|