DBVIEW
src/org/dbview/input_addons/InputCatalog.java
00001 /*
00002         DbView - Graph Visualization
00003     Copyright (C) 2012  Denis BEURIVE
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 /**
00020  * @author Denis Beurive
00021  */
00022 
00023 package org.dbview.input_addons;
00024 
00025 import java.util.ArrayList;
00026 import java.util.regex.Pattern;
00027 
00028 /**
00029  * This class loads all the <i>resources</i> that contain input adapters' implementations and creates a catalog of available add-ons.
00030  * @remark Right now, there is only one <i>resource</i> that contains input adaptors. This is a JAR file, create by the ANT script.
00031  * @author Denis BEURIVE
00032  */
00033 public class InputCatalog extends org.dbview.addons.AddOnCatalog
00034 {
00035     /**
00036      * Name of the <i>property</i> that references the JAR file that contains all the adaptors to list.
00037      * @remark This property is defined in the configuration file of the software.
00038      *         The software's configuration file is a "property file" (see file "resources.properties").
00039      */
00040     private static final String ADAPTOR_RESOURCE_NAME = "inputAddons"; // __CONFPROP__
00041 
00042     /**
00043      * Regular expression that is used to recognize an adaptor for an input add-on.
00044      * @remark There is a relation between the following line and the ANT script (build.xml)
00045      *         <code>&lt;property name=&quot;dir.pkg.input.addons&quot;  value=&quot;org/dbview/addons/input&quot;/&gt;</code>
00046      *         <p>example <code>toto.titi.tata.addons.input.addon_name.adaptor_name.class</code></p>
00047      *         <p>The important point is: "addons.input.<name of the add-on>.<name of the adaptor>.class".</p>
00048      * @warning Make sure that the regular expression has 3 pairs of brackets.
00049      *          <ul>
00050      *              <li>First pair of bracket: the full name of the package that represents the add-on.</li>
00051      *              <li>Second pair: the name of the add-on.</li>
00052      *              <li>Third pair: The name of the adaptor.</li>
00053      *          </ul>
00054      */
00055     private static final Pattern ADD_ON_PATTERN  = Pattern.compile("^(.+\\.addons\\.input\\.([^\\.]+))\\.([^\\.]+)\\.class$"); // __BUILD_CONF__
00056 
00057     /**
00058      * This array contains the expected list of adaptors' names.
00059      * @remark If you plan to add a new adapter, then you must declare the new adaptor in the list below.
00060      */
00061     private static final ArrayList<String> ADAPTORS = new ArrayList<String>() {{ add("Cli"); add("Configuration"); add("Description"); add("Loader"); }};
00062 
00063     /**
00064      * Constructor.
00065      * @throws Exception
00066      */
00067     public InputCatalog() throws Exception
00068     {
00069         super(InputCatalog.ADAPTOR_RESOURCE_NAME, InputCatalog.ADAPTORS, InputCatalog.ADD_ON_PATTERN);
00070     }
00071 }