Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Copyright (C) 2002 Albert Tumanov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package net.sourceforge.pldoc.cpd;
import java.io.*;
import java.util.*;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.dom.DOMResult;
import net.sourceforge.pmd.cpd.*;
/** Represents all settings for the program.
* Setting values may be received from command line options and/or defaulted.
* This class should not have side effects.
* @author Stuart Turton
*/
public class Settings
{
// Default settings
private static final String GET_METADATA_STATEMENT_DEFAULT =
"BEGIN" +
"\n DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE);" +
"\n DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS', FALSE);" +
"\n DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA. SESSION_TRANSFORM,'SQLTERMINATOR',true );" +
"\n :1 := DBMS_METADATA.GET_DDL(\n :2 ,\n :3 ,\n :4 ,\n :5 ,\n :6 ,\n :7 ) \n;" +
"\nEND;"
;
private static final String DRIVER_NAME_DEFAULT = "oracle.jdbc.OracleDriver";
//CPD specific defaults
public static final String CPD_RENDER_FORMAT_DEFAULT = "text";
public static final String CPD_LANGUAGE_DEFAULT = "plsql";
public static final int CPD_MINIMUM_TOKENS_DEFAULT = 50;
// settings and their defaults
private String applicationName = "MyApplication";
private File outputDirectory = new File("." + File.separator);
private File outputFile = null ;
private File stylesheetFile = null ;
private File sourcestylesheetFile = null ;
private Collection inputFiles = new ArrayList();
private Properties defines = null;
// by default, assume system default encoding for all input files
private String inputEncoding = System.getProperty("file.encoding");
// we cannot yet set output encoding dynamically, because of XSLs
private boolean exitOnError = false;
private boolean verbose = false;
private String driverName = DRIVER_NAME_DEFAULT ;
private String getMetadataStatement = GET_METADATA_STATEMENT_DEFAULT ;
private int returnType = java.sql.Types.CLOB;
private String dbUrl = null;
private String dbUser = null;
private String dbPassword = null;
private Collection inputTypes = new ArrayList();
private Collection inputObjects = new ArrayList();
private boolean showSkippedPackages = false;
private boolean savesourcecode = false;
// CPD Settings
private String formatString = CPD_RENDER_FORMAT_DEFAULT;
private String languageString = CPD_LANGUAGE_DEFAULT;
private int minimumTileSize = CPD_MINIMUM_TOKENS_DEFAULT;
private boolean skipDuplicates = false;
private boolean ignoreComments = false;
private boolean ignoreIdentifiers = false;
private boolean ignoreLiterals = false;
private Renderer renderer;
private Language language;
private static final String usage =
"Arguments: [options] inputfile(s)\n" +
"-verbose Verbose - report each object processed \n" +
"-language Language expected in the source code [default: "+ CPD_LANGUAGE_DEFAULT +" ]\n" +
"-format Output format [default: "+ CPD_RENDER_FORMAT_DEFAULT +" ]\n" +
"-ignorecomments Ignore comments in code\n" +
"-ignoreidentifiers Ignore identifiers (variable names etc.) in code\n" +
"-ignoreliterals Ignore literals (constant values, strings etc.) in code\n" +
"-minimumTokens Minimum number of sequential tokens before declaring a match [default: " + CPD_MINIMUM_TOKENS_DEFAULT +" ]\n" +
"-skipduplicates Ignore duplicated files\n" +
"-savesourcecode Save read source code to file system\n" +
"-inputencoding Encoding used in the input files [default: operation system default encoding]\n" +
"-outputfile output file name [default: standard output ] \n" +
"-stylesheetfile stylesheet name (when is xml) \n" +
"-sourcestylesheetfile stylesheet name (when is xml) \n" +
"-exitonerror Force program to exit when some input file cannot be processed\n" +
" [by default, the file is skipped and processing continues]\n" +
"-driver Name of JDBC driver class, for example oracle.jdbc.OracleDriver, com.edb.Driver, or org.postgresql.Driver [default: " + DRIVER_NAME_DEFAULT + "].\n" +
"-getmetadata SQL 92 CallableStatement Statement that retrieves the object source (EnterpriseDB does not support Oracle BEGIN .. END statements) [default: Oracle DBMS_METADATA anonymous block ].\n" +
" Statement structure is (\"call\" and function are case sensitive} \"{ ? = call GET_SOURCE( ? , ? , ? , ? , ? , ? ) }\" where GET_SOURCE(...) mimics \n" +
" \"{ = call DBMS_METADATA.GET_DDL( , , , 'COMPATIBLE' , 'ORACLE' , 'DDL' ) }\" \n" +
"-returntype number corresponding to java.sql.Types.CLOB (2005) or java.sql.Types.VARCHAR (12) [default: java.sql.Types.CLOB].\n" +
"-url Database URL, for example jdbc:oracle:thin:@HOST:PORT:SID, jdbc:oracle:thin:@HOST:PORT/SERVICE, jdbc:edb://HOST:PORT/DATABASE,\n" +
" or jdbc:postgresql://HOST:PORT/DATABASE [default: none].\n" +
" Required when generating from the Oracle dictionary.\n" +
"-user Schema name.\n" +
" Required when generating from the Oracle dictionary. The user name is\n" +
" case sensitive since Oracle stores user/schema names like \"My schema\" (name wit \n" +
" double quotes) as 'My schema' in the dictionary. Ordinary schema names\n" +
" like scott are stored as 'SCOTT' (upper case).\n" +
"-password Password of the logon user.\n" +
" Required when generating from the Oracle dictionary.\n" +
"-types