DBVIEW
|
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.addons.output.table.utils.dot; 00024 00025 import org.dbview.runtime.cli.CliParser; 00026 import org.dbview.utils.args4j.*; 00027 import org.kohsuke.args4j.Option; 00028 import java.util.*; 00029 00030 /** 00031 * This class defines command line options container for all DOT add-ons. 00032 * @remark See Args4j. The command line options are declared in a class. We call this class the <i>command line options container</i> 00033 * @author Denis Beurive 00034 */ 00035 public class CliOptions extends OptionContainer 00036 { 00037 /** 00038 * This constant means that the users requests the horizontal layout. 00039 */ 00040 final static public int LAYOUT_HORIZONTAL = 1; 00041 00042 /** 00043 * This constant means that the users requests the vertical layout. 00044 */ 00045 final static public int LAYOUT_VERTICAL = 2; 00046 00047 /** 00048 * Command line parameter used to specify the layout. Possible values are: 00049 * <ul> 00050 * <li>"horizontal" (or "h")</li> 00051 * <li>"vertical" (or "v")</li> 00052 * </ul> 00053 */ 00054 final static public String LAYOUT = "-layout"; 00055 00056 /** 00057 * This is a command line option. 00058 * It represents the path of the output file. 00059 */ 00060 final static public String PATH = "-path"; 00061 00062 /** 00063 * Layout. Possible values are: 00064 * <ul> 00065 * <li>"horizontal" (or "h")</li> 00066 * <li>"vertical" (or "v")</li> 00067 * </ul> 00068 */ 00069 @Option(name=CliOptions.LAYOUT, handler=SpecialStringOptionHandler.class) 00070 private String __layout = null; 00071 00072 /** 00073 * This option represents the path to the output file. 00074 */ 00075 @Option(name=CliOptions.PATH, handler=SpecialStringOptionHandler.class) 00076 private String __path = null; 00077 00078 /** 00079 * This method returns the layout requested by the user. 00080 * @return The method returns the layout requested by the user. The returned value may be: 00081 * <ul> 00082 * <li>CliOptions.LAYOUT_HORIZONTAL</li> 00083 * <li>CliOptions.LAYOUT_VERTICAL</li> 00084 * </ul> 00085 * @throws Exception 00086 */ 00087 public int getLayout() throws Exception 00088 { 00089 if (null == this.__layout) { return CliOptions.LAYOUT_HORIZONTAL; } 00090 if (0 == this.__layout.compareToIgnoreCase("horizontal")) { return CliOptions.LAYOUT_HORIZONTAL; } 00091 if (0 == this.__layout.compareToIgnoreCase("h")) { return CliOptions.LAYOUT_HORIZONTAL; } 00092 if (0 == this.__layout.compareToIgnoreCase("vertical")) { return CliOptions.LAYOUT_VERTICAL; } 00093 if (0 == this.__layout.compareToIgnoreCase("v")) { return CliOptions.LAYOUT_VERTICAL; } 00094 throw new Exception("Invalid layout \"" + this.__layout + "\""); 00095 } 00096 00097 /** 00098 * This method returns the path to the output file. 00099 * @return This method returns the path to the output file. 00100 */ 00101 public String getPath() 00102 { return this.__path; } 00103 }