View Javadoc

1   
2   /*
3    * Copyright (C) 2005 by Arno Schumacher
4    *
5    * This file is part of net.sourceforge.servletspy
6    *
7    * net.sourceforge.servletspy is free software; you can redistribute
8    * it and/or modify it under the terms of the GNU General Public 
9    * License as published by the Free Software Foundation; either 
10   * version 2, or (at your option) any later version.
11   *
12   * net.sourceforge.servletspy is distributed in the hope that it will
13   * be useful, but WITHOUT ANY WARRANTY; without even the implied 
14   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
15   * See the GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA 
20   */
21  package net.sourceforge.servletspy;
22  
23  import java.io.BufferedReader;
24  import java.io.IOException;
25  import java.io.InputStream;
26  import java.io.InputStreamReader;
27  import java.io.PrintWriter;
28  import java.io.Serializable;
29  import java.io.StringWriter;
30  
31  /***
32   * @author arno schumacher
33   */
34  public final class About implements Serializable {
35  
36      /*** The serial version id. */
37      private static final long serialVersionUID = -2036186781095617094L;
38  
39      /*** The location of the license file. */
40      private static final String RESOURCE = "META-INF/SERVLETSPY-LICENSE.txt";
41  
42      /*** String holding the license. */
43      private String license = "GNU GENERAL PUBLIC license, Version 2, June 1991";
44  
45      /***
46       * Constructor.
47       */
48      public About() {
49          final StringWriter stringWriter = new StringWriter();
50          final PrintWriter writer = new PrintWriter(stringWriter);
51          try {
52              final InputStream ios = Thread.currentThread()
53                      .getContextClassLoader().getResourceAsStream(RESOURCE);
54              if (ios == null) {
55                  throw new IOException("Resource '" + RESOURCE
56                          + "' could not be found.");
57              }
58              final BufferedReader in = new BufferedReader(new InputStreamReader(
59                      ios));
60              String s = in.readLine();
61              while (s != null) {
62                  writer.println(s);
63                  s = in.readLine();
64              }
65              in.close();
66              stringWriter.close();
67              license = stringWriter.toString();
68          } catch (Exception e) {
69              e.printStackTrace();
70          }
71      }
72  
73      /***
74       * Returns the license information.
75       *
76       * @return String providing the license information.
77       */
78      public String getLicense() {
79          return license;
80      }
81  }