src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
Const { public static String escapeSQL( String content ) { if ( Utils.isEmpty( content ) ) { return content; } return StringEscapeUtils.escapeSql( content ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testEscapeSQL() { assertEquals( "SELECT ''Let''s rock!'' FROM dual", Const.escapeSQL( "SELECT 'Let's rock!' FROM dual" ) ); }
|
Const { public static String removeCRLF( String in ) { if ( ( in != null ) && ( in.length() > 0 ) ) { int inLen = in.length(), posn = 0; char[] tmp = new char[ inLen ]; char ch; for ( int i = 0; i < inLen; i++ ) { ch = in.charAt( i ); if ( ( ch != '\n' && ch != '\r' ) ) { tmp[posn] = ch; posn++; } } return new String( tmp, 0, posn ); } else { return ""; } } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testRemoveCRLF() { assertEquals( "foo\tbar", Const.removeCRLF( "foo\r\n\tbar" ) ); assertEquals( "", Const.removeCRLF( "" ) ); assertEquals( "", Const.removeCRLF( null ) ); assertEquals( "", Const.removeCRLF( "\r\n" ) ); assertEquals( "This is a test of the emergency broadcast system", Const.removeCRLF( "This \r\nis \ra \ntest \rof \n\rthe \r\nemergency \rbroadcast \nsystem\r\n" ) ); }
|
Const { public static String removeCR( String in ) { return removeChar( in, '\n' ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testRemoveCR() { assertEquals( "foo\r\tbar", Const.removeCR( "foo\r\n\tbar" ) ); assertEquals( "", Const.removeCR( "" ) ); assertEquals( "", Const.removeCR( null ) ); assertEquals( "", Const.removeCR( "\n" ) ); assertEquals( "\r", Const.removeCR( "\n\r\n" ) ); assertEquals( "This \ris \ra test \rof \rthe \remergency \rbroadcast system\r", Const.removeCR( "This \r\nis \ra \ntest \rof \n\rthe \r\nemergency \rbroadcast \nsystem\r\n" ) ); }
|
Const { public static String removeLF( String in ) { return removeChar( in, '\r' ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testRemoveLF() { assertEquals( "foo\n\tbar", Const.removeLF( "foo\r\n\tbar" ) ); assertEquals( "", Const.removeLF( "" ) ); assertEquals( "", Const.removeLF( null ) ); assertEquals( "", Const.removeLF( "\r" ) ); assertEquals( "\n", Const.removeLF( "\r\n\r" ) ); assertEquals( "This \nis a \ntest of \nthe \nemergency broadcast \nsystem\n", Const.removeLF( "This \r\nis \ra \ntest \rof \n\rthe \r\nemergency \rbroadcast \nsystem\r\n" ) ); }
|
Const { public static String removeTAB( String in ) { return removeChar( in, '\t' ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testRemoveTAB() { assertEquals( "foo\r\nbar", Const.removeTAB( "foo\r\n\tbar" ) ); assertEquals( "", Const.removeTAB( "" ) ); assertEquals( "", Const.removeTAB( null ) ); assertEquals( "", Const.removeTAB( "\t" ) ); assertEquals( "\r", Const.removeTAB( "\t\r\t" ) ); assertEquals( "Thisisatest", Const.removeTAB( "\tThis\tis\ta\ttest" ) ); }
|
Const { public static Date addTimeToDate( Date input, String time, String DateFormat ) throws Exception { if ( Utils.isEmpty( time ) ) { return input; } if ( input == null ) { return null; } String dateformatString = NVL( DateFormat, "HH:mm:ss" ); int t = decodeTime( time, dateformatString ); return new Date( input.getTime() + t ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testAddTimeToDate() throws Exception { final Date date = new Date( 1447252914241L ); assertNull( Const.addTimeToDate( null, null, null ) ); assertEquals( date, Const.addTimeToDate( date, null, null ) ); assertEquals( 1447256637241L, Const.addTimeToDate( date, "01:02:03", "HH:mm:ss" ).getTime() ); }
|
Const { public static int getOccurenceString( String string, String searchFor ) { if ( string == null || string.length() == 0 ) { return 0; } int counter = 0; int len = searchFor.length(); if ( len > 0 ) { int start = string.indexOf( searchFor ); while ( start != -1 ) { counter++; start = string.indexOf( searchFor, start + len ); } } return counter; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testGetOccurenceString() { assertEquals( 0, Const.getOccurenceString( "", "" ) ); assertEquals( 0, Const.getOccurenceString( "foo bar bazfoo", "cat" ) ); assertEquals( 2, Const.getOccurenceString( "foo bar bazfoo", "foo" ) ); }
|
Const { public static String[] GetAvailableFontNames() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); String[] FontName = new String[fonts.length]; for ( int i = 0; i < fonts.length; i++ ) { FontName[i] = fonts[i].getFontName(); } return FontName; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testGetAvailableFontNames() { assertTrue( Const.GetAvailableFontNames().length > 0 ); }
|
Const { public static String getKettlePropertiesFileHeader() { StringBuilder out = new StringBuilder(); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line01", BuildVersion .getInstance().getVersion() ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line02" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line03" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line04" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line05" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line06" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line07" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line08" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line09" ) + CR ); out.append( BaseMessages.getString( PKG, "Props.Kettle.Properties.Sample.Line10" ) + CR ); return out.toString(); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testGetKettlePropertiesFileHeader() { assertFalse( Const.getKettlePropertiesFileHeader().isEmpty() ); }
|
Const { public static String protectXMLCDATA( String content ) { if ( Utils.isEmpty( content ) ) { return content; } return "<![CDATA[" + content + "]]>"; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testProtectXMLCDATA() { assertEquals( null, Const.protectXMLCDATA( null ) ); assertEquals( "", Const.protectXMLCDATA( "" ) ); assertEquals( "<![CDATA[foo]]>", Const.protectXMLCDATA( "foo" ) ); }
|
Const { public static int getOcuranceString( String string, String searchFor ) { if ( string == null || string.length() == 0 ) { return 0; } Pattern p = Pattern.compile( searchFor ); Matcher m = p.matcher( string ); int count = 0; while ( m.find() ) { ++count; } return count; } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testGetOcuranceString() { assertEquals( 0, Const.getOcuranceString( "", "" ) ); assertEquals( 0, Const.getOcuranceString( "foo bar bazfoo", "cat" ) ); assertEquals( 2, Const.getOcuranceString( "foo bar bazfoo", "foo" ) ); }
|
Const { public static String escapeXML( String content ) { if ( Utils.isEmpty( content ) ) { return content; } return StringEscapeUtils.escapeXml( content ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testEscapeXml() { final String xml = "<xml xmlns:test=\"http: final String escaped = "<xml xmlns:test="http: assertNull( Const.escapeXml( null ) ); assertEquals( escaped, Const.escapeXml( xml ) ); }
|
Const { public static String Lpad( String valueToPad, String filler, int size ) { if ( ( size == 0 ) || ( valueToPad == null ) || ( filler == null ) ) { return valueToPad; } int vSize = valueToPad.length(); int fSize = filler.length(); if ( ( vSize >= size ) || ( fSize == 0 ) ) { return valueToPad; } int tgt = ( size - vSize ); StringBuilder sb = new StringBuilder( size ); sb.append( filler ); while ( sb.length() < tgt ) { sb.append( sb ); } sb.append( valueToPad ); return sb.substring( Math.max( 0, sb.length() - size ) ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testLpad() { final String s = "pad me"; assertEquals( s, Const.Lpad( s, "-", 0 ) ); assertEquals( s, Const.Lpad( s, "-", 3 ) ); assertEquals( "--" + s, Const.Lpad( s, "-", 8 ) ); assertEquals( s, Const.Lpad( s, null, 15 ) ); assertEquals( s, Const.Lpad( s, "", 15 ) ); assertEquals( s, Const.Lpad( s, "*", 5 ) ); assertEquals( null, Const.Lpad( null, "*", 15 ) ); assertEquals( "****Test", Const.Lpad( "Test", "**********", 8 ) ); assertEquals( "*Test", Const.Lpad( "Test", "**", 5 ) ); assertEquals( "****", Const.Lpad( "", "*", 4 ) ); }
|
Const { public static String Rpad( String valueToPad, String filler, int size ) { if ( ( size == 0 ) || ( valueToPad == null ) || ( filler == null ) ) { return valueToPad; } int vSize = valueToPad.length(); int fSize = filler.length(); if ( ( vSize >= size ) || ( fSize == 0 ) ) { return valueToPad; } int tgt = ( size - vSize ); StringBuilder sb1 = new StringBuilder( size ); sb1.append( filler ); while ( sb1.length() < tgt ) { sb1.append( sb1 ); } StringBuilder sb = new StringBuilder( valueToPad ); sb.append( sb1 ); return sb.substring( 0, size ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testRpad() { final String s = "pad me"; assertEquals( s, Const.Rpad( s, "-", 0 ) ); assertEquals( s, Const.Rpad( s, "-", 3 ) ); assertEquals( s + "--", Const.Rpad( s, "-", 8 ) ); assertEquals( s, Const.Rpad( s, null, 15 ) ); assertEquals( s, Const.Rpad( s, "", 15 ) ); assertEquals( s, Const.Rpad( s, "*", 5 ) ); assertEquals( null, Const.Rpad( null, "*", 15 ) ); assertEquals( "Test****", Const.Rpad( "Test", "**********", 8 ) ); assertEquals( "Test*", Const.Rpad( "Test", "**", 5 ) ); assertEquals( "****", Const.Rpad( "", "*", 4 ) ); }
|
Const { public static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ) { if ( clazz.equals( Object.class ) ) { return false; } return clazz.equals( superClass ) || classIsOrExtends( clazz.getSuperclass(), superClass ); } static double round( double f, int places ); static double round( double f, int places, int roundingMode ); static BigDecimal round( BigDecimal f, int places, int roundingMode ); static long round( long f, int places, int roundingMode ); static int toInt( String str, int def ); static long toLong( String str, long def ); static double toDouble( String str, double def ); static Date toDate( String str, Date def ); static boolean isSpace( char c ); static String ltrim( String source ); static String rtrim( String source ); static String trim( String str ); static String rightPad( String ret, int limit ); static String rightPad( StringBuffer ret, int limit ); static String rightPad( StringBuilder ret, int limit ); static String replace( String string, String repl, String with ); static void repl( StringBuffer str, String code, String repl ); static void repl( StringBuilder str, String code, String repl ); static int nrSpacesBefore( String field ); static int nrSpacesAfter( String field ); static boolean onlySpaces( String str ); static String getOS(); static String getQuoteCharByOS(); static String optionallyQuoteStringByOS( String string ); static boolean isWindows(); static boolean isLinux(); static boolean isOSX(); static boolean isKDE(); static String getHostname(); static String getHostnameReal(); static String getIPAddress(); static String getIPAddress( String networkInterfaceName ); static String getMACAddress(); static String getUserHomeDirectory(); static String getKettleDirectory(); static String getUserBaseDir(); static String getDIHomeDirectory(); static String getSharedObjectsFile(); static String getKettleLocalRepositoriesFile(); static String getKettleUserRepositoriesFile(); static String getKettleLocalCartePasswordFile(); static String getKettleCartePasswordFile(); static String getBaseDocUrl(); static String getDocUrl( final String uri ); static String getEnvironmentVariable( String variable, String deflt ); @Deprecated static String replEnv( String string ); @Deprecated static String[] replEnv( String[] string ); static String NVL( String source, String def ); static String nullToEmpty( String source ); static int indexOfString( String lookup, String[] array ); static int[] indexsOfStrings( String[] lookup, String[] array ); static int[] indexsOfFoundStrings( String[] lookup, String[] array ); static int indexOfString( String lookup, List<String> list ); static String[] sortStrings( String[] input ); static String[] splitString( String string, String separator ); static String[] splitString( String string, char separator ); static String[] splitString( String string, char separator, boolean escape ); static String[] splitPath( String path, String separator ); static String[] splitString( String stringToSplit, String delimiter, String enclosure ); static String[] splitString( String stringToSplit, String delimiter, String enclosure, boolean removeEnclosure ); static String[] getDistinctStrings( String[] strings ); static String getStackTracker( Throwable e ); static String getClassicStackTrace( Throwable e ); static String getCustomStackTrace( Throwable aThrowable ); @Deprecated static boolean isEmpty( String val ); @Deprecated static boolean isEmpty( StringBuffer val ); @Deprecated static boolean isEmpty( String[] vals ); @Deprecated static boolean isEmpty( CharSequence val ); @Deprecated static boolean isEmpty( CharSequence[] vals ); @Deprecated static boolean isEmpty( Object[] array ); @Deprecated static boolean isEmpty( List<?> list ); static ClassLoader createNewClassLoader(); static byte[] createByteArray( int size ); static String initCap( String string ); static String createFilename( String name ); static String createFilename( String directory, String name, String extension ); static String createName( String filename ); static String filenameOnly( String sFullPath ); static String[] getDateFormats(); static String[] getNumberFormats(); static String[] getConversionFormats(); static String[] getTransformationAndJobFilterNames(); static String[] getTransformationFilterNames(); static String[] getJobFilterNames(); static long nanoTime(); static String trimToType( String string, int trimType ); static String safeAppendDirectory( String dir, String file ); static String[] getEmptyPaddedStrings(); static int getPercentageFreeMemory(); static String removeDigits( String input ); static String getDigitsOnly( String input ); static Date removeTimeFromDate( Date input ); static String escapeXML( String content ); static String escapeHtml( String content ); static String unEscapeHtml( String content ); static String unEscapeXml( String content ); static String escapeSQL( String content ); static String removeCRLF( String in ); static String removeChar( String in, char badChar ); static String removeCR( String in ); static String removeLF( String in ); static String removeTAB( String in ); static Date addTimeToDate( Date input, String time, String DateFormat ); static int decodeTime( String s, String DateFormat ); static int getOccurenceString( String string, String searchFor ); static String[] GetAvailableFontNames(); static String getKettlePropertiesFileHeader(); static String protectXMLCDATA( String content ); static int getOcuranceString( String string, String searchFor ); static String escapeXml( String content ); static String Lpad( String valueToPad, String filler, int size ); static String Rpad( String valueToPad, String filler, int size ); static boolean classIsOrExtends( Class<?> clazz, Class<?> superClass ); static String getDeprecatedPrefix(); @Deprecated
static final String VERSION; static final String COPYRIGHT_YEAR; static final int TIMEOUT_GET_MILLIS; static final int TIMEOUT_PUT_MILLIS; static final int ROWS_UPDATE; static final int ROWS_IN_ROWSET; static final int FETCH_SIZE; static final int SORT_SIZE; static final int HEARTBEAT_PERIODIC_INTERVAL_IN_SECS; static final String FILE_SEPARATOR; static final String PATH_SEPARATOR; static final String CR; static final String DOSCR; static final String EMPTY_STRING; static final String JAVA_VERSION; @Deprecated
static final String USER_HOME_DIRECTORY; static String JNDI_DIRECTORY; static final String PLUGIN_BASE_FOLDERS_PROP; static final String DEFAULT_PLUGIN_BASE_FOLDERS; static final Date MIN_DATE; static final Date MAX_DATE; static final int MIN_YEAR; static final int MAX_YEAR; static final int RIGHT; static final int LENGTH; static final int MARGIN; static final int MIDDLE_PCT; static final int ARROW_WIDTH; static final int FORM_MARGIN; static final int SHADOW_SIZE; static final int SYMBOLSIZE; static final int MAX_FILE_HIST; static final Locale DEFAULT_LOCALE; static final char DEFAULT_DECIMAL_SEPARATOR; static final char DEFAULT_GROUPING_SEPARATOR; static final String DEFAULT_CURRENCY_SYMBOL; static final String DEFAULT_NUMBER_FORMAT; static final String NULL_STRING; static final String NULL_NUMBER; static final String NULL_DATE; static final String NULL_BIGNUMBER; static final String NULL_BOOLEAN; static final String NULL_INTEGER; static final String NULL_BINARY; static final String NULL_NONE; static final int ROUND_HALF_CEILING; static final String CHEF_LOG_FILE; static final String SPOON_LOG_FILE; static final String MENU_LOG_FILE; static final String GENERALIZED_DATE_TIME_FORMAT; static final String GENERALIZED_DATE_TIME_FORMAT_MILLIS; static final String XML_ENCODING; static final String[] STRING_TRANS_AND_JOB_FILTER_EXT; static final String STRING_TRANS_DEFAULT_EXT; static final String[] STRING_TRANS_FILTER_EXT; static final String STRING_JOB_DEFAULT_EXT; static final String[] STRING_JOB_FILTER_EXT; static final String KETTLE_PROPERTIES; static final String SHARED_DATA_FILE; static final String INTERNAL_VARIABLE_PREFIX; static final String INTERNAL_VARIABLE_KETTLE_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_VERSION; static final String INTERNAL_VARIABLE_KETTLE_BUILD_DATE; static final String INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_FILENAME_NAME; static final String INTERNAL_VARIABLE_JOB_NAME; static final String INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_JOB_RUN_ID; static final String INTERNAL_VARIABLE_JOB_RUN_ATTEMPTNR; static final String VARIABLE_HEARTBEAT_PERIODIC_INTERVAL_SECS; static final String VARIABLE_MONITORING_SNMP_TRAPS_ENABLED; static final String INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY; static final String[] INTERNAL_TRANS_VARIABLES; static final String[] INTERNAL_JOB_VARIABLES; static final String[] DEPRECATED_VARIABLES; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY; static final String INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_NAME; static final String INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY; static final String INTERNAL_VARIABLE_STEP_PARTITION_ID; static final String INTERNAL_VARIABLE_STEP_PARTITION_NR; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER; static final String INTERNAL_VARIABLE_SLAVE_SERVER_NAME; static final String INTERNAL_VARIABLE_CLUSTER_SIZE; static final String INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER; static final String INTERNAL_VARIABLE_CLUSTER_MASTER; static final String INTERNAL_VARIABLE_CLUSTER_RUN_ID; static final String INTERNAL_VARIABLE_STEP_UNIQUE_COUNT; static final String INTERNAL_VARIABLE_STEP_NAME; static final String INTERNAL_VARIABLE_STEP_COPYNR; static final int MAX_NR_LOG_LINES; static final int MAX_NR_HISTORY_LINES; static final int HISTORY_LINES_FETCH_SIZE; static final int MAX_LOG_LINE_TIMEOUT_MINUTES; static final int WARNING; static final int ERROR; static final int INFO; static final int NOTE_MARGIN; static final int MAX_UNDO; static final String KETTLE_VARIABLES_FILE; static final String KETTLE_LOG_SIZE_LIMIT; static final String KETTLE_TRANS_LOG_DB; static final String KETTLE_TRANS_LOG_SCHEMA; static final String KETTLE_TRANS_LOG_TABLE; static final String KETTLE_JOB_LOG_DB; static final String KETTLE_JOB_LOG_SCHEMA; static final String KETTLE_SLAVE_DETECTION_TIMER; static final String KETTLE_JOB_LOG_TABLE; static final String KETTLE_TRANS_PERFORMANCE_LOG_DB; static final String KETTLE_TRANS_PERFORMANCE_LOG_SCHEMA; static final String KETTLE_TRANS_PERFORMANCE_LOG_TABLE; static final String KETTLE_JOBENTRY_LOG_DB; static final String KETTLE_JOBENTRY_LOG_SCHEMA; static final String KETTLE_JOBENTRY_LOG_TABLE; static final String KETTLE_STEP_LOG_DB; static final String KETTLE_STEP_LOG_SCHEMA; static final String KETTLE_STEP_LOG_TABLE; static final String KETTLE_CHANNEL_LOG_DB; static final String KETTLE_CHANNEL_LOG_SCHEMA; static final String KETTLE_CHANNEL_LOG_TABLE; static final String KETTLE_METRICS_LOG_DB; static final String KETTLE_METRICS_LOG_SCHEMA; static final String KETTLE_METRICS_LOG_TABLE; static final String KETTLE_CHECKPOINT_LOG_DB; static final String KETTLE_CHECKPOINT_LOG_SCHEMA; static final String KETTLE_CHECKPOINT_LOG_TABLE; static final String KETTLE_SHARED_OBJECTS; static final String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL; static final String KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION; static final String KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE; static final String KETTLE_COMPATIBILITY_IMPORT_PATH_ADDITION_ON_VARIABLES; static final String KETTLE_COMPATIBILITY_IGNORE_TABLE_LOGGING; static final String KETTLE_COMPATIBILITY_TEXT_FILE_OUTPUT_APPEND_NO_HEADER; static final String KETTLE_COMPATIBILITY_MERGE_ROWS_USE_REFERENCE_STREAM_WHEN_IDENTICAL; static final String KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE; static final String KETTLE_SYSTEM_HOSTNAME; static final String KETTLE_MAX_LOG_SIZE_IN_LINES; static final String KETTLE_MAX_LOG_TIMEOUT_IN_MINUTES; static final String KETTLE_REDIRECT_STDERR; static final String KETTLE_REDIRECT_STDOUT; static final String KETTLE_CARTE_OBJECT_TIMEOUT_MINUTES; static final String KETTLE_STEP_PERFORMANCE_SNAPSHOT_LIMIT; static final String KETTLE_MAX_JOB_TRACKER_SIZE; static final String KETTLE_MAX_JOB_ENTRIES_LOGGED; static final String KETTLE_MAX_LOGGING_REGISTRY_SIZE; static final String KETTLE_LOG_TAB_REFRESH_DELAY; static final String KETTLE_LOG_TAB_REFRESH_PERIOD; static final String KETTLE_SAP_CONNECTION_FACTORY; static final String KETTLE_SAP_CONNECTION_FACTORY_DEFAULT_NAME; static final String KETTLE_PLUGIN_CLASSES; static final String KETTLE_PLUGIN_PACKAGES; static final String KETTLE_TRANS_ROWSET_SIZE; static final String VERSION_COMMENT_INITIAL_VERSION; static final String VERSION_COMMENT_EDIT_VERSION; static final String XML_FILE_KETTLE_STEPS; static final String KETTLE_CORE_STEPS_FILE; static final String XML_FILE_KETTLE_PARTITION_PLUGINS; static final String KETTLE_CORE_JOBENTRIES_FILE; static final String XML_FILE_KETTLE_SERVLETS; static final String XML_FILE_KETTLE_VALUEMETA_PLUGINS; static final String XML_FILE_KETTLE_PASSWORD_ENCODER_PLUGINS; static final String KETTLE_VALUEMETA_PLUGINS_FILE; static final String KETTLE_PASSWORD_ENCODER_PLUGIN; static final String KETTLE_PASSWORD_ENCODER_PLUGINS_FILE; static final String KETTLE_TWO_WAY_PASSWORD_ENCODER_SEED; static final String XML_FILE_KETTLE_LOGGING_PLUGINS; static final String KETTLE_LOGGING_PLUGINS_FILE; static final String KETTLE_CORE_SERVLETS_FILE; static final String KETTLE_ROWSET_GET_TIMEOUT; static final String KETTLE_ROWSET_PUT_TIMEOUT; static final String KETTLE_BATCHING_ROWSET; static final String KETTLE_DISABLE_CONSOLE_LOGGING; static final String XML_FILE_KETTLE_JOB_ENTRIES; static final String XML_FILE_KETTLE_REPOSITORIES; static final String XML_FILE_KETTLE_DATABASE_TYPES; static final String XML_FILE_KETTLE_COMPRESSION_PROVIDERS; static final String XML_FILE_KETTLE_AUTHENTICATION_PROVIDERS; static final String XML_FILE_KETTLE_EXTENSION_POINTS; static final String XML_FILE_KETTLE_REGISTRY_EXTENSIONS; static final String XML_FILE_KETTLE_LIFECYCLE_LISTENERS; static final String XML_FILE_KETTLE_ENGINES; static final String KETTLE_TRANS_PAN_JVM_EXIT_CODE; static final String KETTLE_DEFAULT_NUMBER_FORMAT; static final String KETTLE_DEFAULT_BIGNUMBER_FORMAT; static final String KETTLE_DEFAULT_INTEGER_FORMAT; static final String KETTLE_DEFAULT_DATE_FORMAT; static final String KETTLE_AGGREGATION_MIN_NULL_IS_VALUED; static final String KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO; static final String KETTLE_DEFAULT_TIMESTAMP_FORMAT; static final String KETTLE_SPLIT_FIELDS_REMOVE_ENCLOSURE; static final String KETTLE_GLOBAL_LOG_VARIABLES_CLEAR_ON_EXPORT; static final String KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION; static final String KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES; static final String KETTLE_COMPATIBILITY_SEND_RESULT_XML_WITH_FULL_STATUS; static final String KETTLE_COMPATIBILITY_SELECT_VALUES_TYPE_CHANGE_USES_TYPE_DEFAULTS; static final String XML_FILE_KETTLE_IMPORT_RULES; static final ReleaseType RELEASE; static final String PENTAHO_METASTORE_FOLDER; static final String PENTAHO_METASTORE_NAME; static final String KETTLE_LOG_MARK_MAPPINGS; static final String KETTLE_CARTE_JETTY_ACCEPTORS; static final String KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE; static final String KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME; static final String VFS_USER_DIR_IS_ROOT; }
|
@Test public void testClassIsOrExtends() { assertFalse( Const.classIsOrExtends( Object.class, Object.class ) ); assertTrue( Const.classIsOrExtends( String.class, String.class ) ); assertTrue( Const.classIsOrExtends( ArrayList.class, ArrayList.class ) ); }
|
XMLFormatter { public static String format( String xml ) { XMLStreamReader rd = null; XMLStreamWriter wr = null; StringWriter result = new StringWriter(); try { rd = INPUT_FACTORY.createXMLStreamReader( new StringReader( xml ) ); wr = OUTPUT_FACTORY.createXMLStreamWriter( result ); StartElementBuffer startElementBuffer = null; StringBuilder str = new StringBuilder(); StringBuilder prefix = new StringBuilder(); boolean wasStart = false; boolean wasSomething = false; while ( rd.hasNext() ) { int event = rd.next(); if ( startElementBuffer != null ) { if ( event == XMLStreamConstants.END_ELEMENT ) { startElementBuffer.writeTo( wr, true ); startElementBuffer = null; prefix.setLength( prefix.length() - STEP_PREFIX.length() ); wasStart = false; continue; } else { startElementBuffer.writeTo( wr, false ); startElementBuffer = null; } } switch ( event ) { case XMLStreamConstants.START_ELEMENT: if ( !whitespacesOnly( str ) ) { wr.writeCharacters( str.toString() ); } else if ( wasSomething ) { wr.writeCharacters( "\n" + prefix ); } str.setLength( 0 ); prefix.append( STEP_PREFIX ); startElementBuffer = new StartElementBuffer( rd ); wasStart = true; wasSomething = true; break; case XMLStreamConstants.END_ELEMENT: prefix.setLength( prefix.length() - STEP_PREFIX.length() ); if ( wasStart ) { wr.writeCharacters( str.toString() ); } else { if ( !whitespacesOnly( str ) ) { wr.writeCharacters( str.toString() ); } else { wr.writeCharacters( "\n" + prefix ); } } str.setLength( 0 ); wr.writeEndElement(); wasStart = false; break; case XMLStreamConstants.SPACE: case XMLStreamConstants.CHARACTERS: str.append( rd.getText() ); break; case XMLStreamConstants.CDATA: if ( !whitespacesOnly( str ) ) { wr.writeCharacters( str.toString() ); } str.setLength( 0 ); wr.writeCData( rd.getText() ); wasSomething = true; break; case XMLStreamConstants.COMMENT: if ( !whitespacesOnly( str ) ) { wr.writeCharacters( str.toString() ); } else if ( wasSomething ) { wr.writeCharacters( "\n" + prefix ); } str.setLength( 0 ); wr.writeComment( rd.getText() ); wasSomething = true; break; case XMLStreamConstants.END_DOCUMENT: wr.writeCharacters( "\n" ); wr.writeEndDocument(); break; default: throw new RuntimeException( "Unknown XML event: " + event ); } } wr.flush(); return result.toString(); } catch ( XMLStreamException ex ) { throw new RuntimeException( ex ); } finally { try { if ( wr != null ) { wr.close(); } } catch ( Exception ex ) { } try { if ( rd != null ) { rd.close(); } } catch ( Exception ex ) { } } } static String format( String xml ); }
|
@Test public void test1() throws Exception { String inXml, expectedXml; try ( InputStream in = XMLFormatterTest.class.getResourceAsStream( "XMLFormatterIn1.xml" ) ) { inXml = IOUtils.toString( in ); } try ( InputStream in = XMLFormatterTest.class.getResourceAsStream( "XMLFormatterExpected1.xml" ) ) { expectedXml = IOUtils.toString( in ); } String result = XMLFormatter.format( inXml ); assertEquals( expectedXml, result ); }
@Test public void testcdata() throws Exception { String input = " <annotations>" + " <annotation>" + " <name>c44cc4ed-9647-44f2-b1d9-0523c01f0c94</name>\n" + " <field>HiddenField</field>\n" + " <type>CREATE_ATTRIBUTE</type>\n" + " <properties>" + " <property>" + " <name>hidden</name>\n" + " <value><![CDATA[true]]></value>" + " </property>" + " </properties> " + " </annotation>" + " <sharedDimension>N</sharedDimension>\n" + " <description/>\n" + "</annotations>"; String result = XMLFormatter.format( input ); String expected = "<annotations>\n" + " <annotation>\n" + " <name>c44cc4ed-9647-44f2-b1d9-0523c01f0c94</name>\n" + " <field>HiddenField</field>\n" + " <type>CREATE_ATTRIBUTE</type>\n" + " <properties>\n" + " <property>\n" + " <name>hidden</name>\n" + " <value><![CDATA[true]]></value>\n" + " </property>\n" + " </properties>\n" + " </annotation>\n" + " <sharedDimension>N</sharedDimension>\n" + " <description/>\n" + "</annotations>\n"; assertEquals( expected, result ); }
@Test public void test2() throws Exception { String inXml, expectedXml; try ( InputStream in = XMLFormatterTest.class.getResourceAsStream( "XMLFormatterIn2.xml" ) ) { inXml = IOUtils.toString( in ); } try ( InputStream in = XMLFormatterTest.class.getResourceAsStream( "XMLFormatterExpected2.xml" ) ) { expectedXml = IOUtils.toString( in ); } String result = XMLFormatter.format( inXml ); assertEquals( expectedXml, result ); }
|
XMLCheck { public static boolean isXMLWellFormed( InputStream is ) throws KettleException { boolean retval = false; try { SAXParserFactory factory = XMLParserFactoryProducer.createSecureSAXParserFactory(); XMLTreeHandler handler = new XMLTreeHandler(); SAXParser saxParser = factory.newSAXParser(); saxParser.parse( is, handler ); retval = true; } catch ( Exception e ) { throw new KettleException( e ); } return retval; } static final boolean isXMLFileWellFormed( FileObject file ); static boolean isXMLWellFormed( InputStream is ); }
|
@Test( expected = KettleException.class ) public void exceptionIsThrownWhenParsingXmlWithBigAmountOfExternalEntities() throws KettleException { final String maliciousXml = "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE lolz [\n" + " <!ENTITY lol \"lol\">\n" + " <!ELEMENT lolz (#PCDATA)>\n" + " <!ENTITY lol1 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">\n" + " <!ENTITY lol2 \"&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;\">\n" + " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">\n" + " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">\n" + " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">\n" + " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">\n" + " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">\n" + " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">\n" + " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">\n" + "]>\n" + "<lolz>&lol9;</lolz>"; XMLCheck.isXMLWellFormed( new ByteArrayInputStream( maliciousXml.getBytes() ) ); }
|
KettleVFS { public static boolean startsWithScheme( String vfsFileName ) { FileSystemManager fsManager = getInstance().getFileSystemManager(); boolean found = false; String[] schemes = fsManager.getSchemes(); for ( int i = 0; i < schemes.length; i++ ) { if ( vfsFileName.startsWith( schemes[i] + ":" ) ) { found = true; break; } } return found; } private KettleVFS(); FileSystemManager getFileSystemManager(); static KettleVFS getInstance(); static FileObject getFileObject( String vfsFilename ); static FileObject getFileObject( String vfsFilename, VariableSpace space ); static FileObject getFileObject( String vfsFilename, FileSystemOptions fsOptions ); static FileObject getFileObject( String vfsFilename, VariableSpace space, FileSystemOptions fsOptions ); static String getTextFileContent( String vfsFilename, String charSetName ); static String getTextFileContent( String vfsFilename, VariableSpace space, String charSetName ); static boolean fileExists( String vfsFilename ); static boolean fileExists( String vfsFilename, VariableSpace space ); static InputStream getInputStream( FileObject fileObject ); static InputStream getInputStream( String vfsFilename ); static InputStream getInputStream( String vfsFilename, VariableSpace space ); static OutputStream getOutputStream( FileObject fileObject, boolean append ); static OutputStream getOutputStream( String vfsFilename, boolean append ); static OutputStream getOutputStream( String vfsFilename, VariableSpace space, boolean append ); static OutputStream getOutputStream( String vfsFilename, VariableSpace space,
FileSystemOptions fsOptions, boolean append ); static String getFilename( FileObject fileObject ); static String getFriendlyURI( String filename ); static String getFriendlyURI( FileObject fileObject ); static FileObject createTempFile( String prefix, String suffix, String directory ); static FileObject createTempFile( String prefix, String suffix, String directory, VariableSpace space ); static Comparator<FileObject> getComparator(); @Deprecated static FileInputStream getFileInputStream( FileObject fileObject ); static boolean startsWithScheme( String vfsFileName ); static void closeEmbeddedFileSystem( String embeddedMetastoreKey ); }
|
@Test public void testStartsWithScheme() { String fileName = "zip:file: assertTrue( KettleVFS.startsWithScheme( fileName ) ); fileName = "SavedLinkedres.zip!Calculate median and percentiles using the group by steps.ktr"; assertFalse( KettleVFS.startsWithScheme( fileName ) ); }
|
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRow( RowMetaInterface rowMeta, Object[] rowData ) { this.rowMeta = rowMeta; this.row = rowData; return true; } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }
|
@Test public void testPutRow() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRow() ); }
|
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ) { return putRow( rowMeta, rowData ); } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }
|
@Test public void testPutRowWait() throws Exception { rowSet.putRowWait( new RowMeta(), row, 1, TimeUnit.SECONDS ); assertSame( row, rowSet.getRowWait( 1, TimeUnit.SECONDS ) ); }
|
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public Object[] getRowImmediate() { return getRow(); } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }
|
@Test public void testGetRowImmediate() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRowImmediate() ); }
|
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public int size() { return row == null ? 0 : 1; } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }
|
@Test public void testSize() throws Exception { assertEquals( 0, rowSet.size() ); rowSet.putRow( new RowMeta(), row ); assertEquals( 1, rowSet.size() ); rowSet.clear(); assertEquals( 0, rowSet.size() ); }
|
DateDetector { public static String getRegexpByDateFormat( String dateFormat ) { return getRegexpByDateFormat( dateFormat, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testGetRegexpByDateFormat() { assertNull( DateDetector.getRegexpByDateFormat( null ) ); assertEquals( SAMPLE_REGEXP, DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT ) ); }
@Test public void testGetRegexpByDateFormatLocale() { assertNull( DateDetector.getRegexpByDateFormat( null, null ) ); assertNull( DateDetector.getRegexpByDateFormat( null, LOCALE_en_US ) ); assertNull( DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT_US ) ); assertEquals( SAMPLE_REGEXP_US, DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT_US, LOCALE_en_US ) ); }
|
DateDetector { public static String getDateFormatByRegex( String regex ) { return getDateFormatByRegex( regex, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testGetDateFormatByRegex() { assertNull( DateDetector.getDateFormatByRegex( null ) ); assertEquals( SAMPLE_DATE_FORMAT, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP ) ); }
@Test public void testGetDateFormatByRegexLocale() { assertNull( DateDetector.getDateFormatByRegex( null, null ) ); assertNull( DateDetector.getDateFormatByRegex( null, LOCALE_en_US ) ); assertEquals( SAMPLE_DATE_FORMAT, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP_US ) ); assertEquals( SAMPLE_DATE_FORMAT_US, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP_US, LOCALE_en_US ) ); }
|
DateDetector { public static Date getDateFromString( String dateString ) throws ParseException { String dateFormat = detectDateFormat( dateString ); if ( dateFormat == null ) { throw new ParseException( "Unknown date format.", 0 ); } return getDateFromStringByFormat( dateString, dateFormat ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testGetDateFromString() throws ParseException { assertEquals( SAMPLE_DATE_US, DateDetector.getDateFromString( SAMPLE_DATE_STRING_US ) ); try { DateDetector.getDateFromString( null ); } catch ( ParseException e ) { } }
@Test public void testGetDateFromStringLocale() throws ParseException { assertEquals( SAMPLE_DATE_US, DateDetector.getDateFromString( SAMPLE_DATE_STRING_US, LOCALE_en_US ) ); try { DateDetector.getDateFromString( null ); } catch ( ParseException e ) { } try { DateDetector.getDateFromString( null, null ); } catch ( ParseException e ) { } }
|
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testGetDateFromStringByFormat() throws ParseException { assertEquals( SAMPLE_DATE, DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) ); try { DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, null ); } catch ( ParseException e ) { } try { DateDetector.getDateFromStringByFormat( null, SAMPLE_DATE_FORMAT ); } catch ( ParseException e ) { } }
|
DateDetector { public static String detectDateFormat( String dateString ) { return detectDateFormat( dateString, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testDetectDateFormat() { assertEquals( SAMPLE_DATE_FORMAT, DateDetector.detectDateFormat( SAMPLE_DATE_STRING, LOCALE_es ) ); assertNull( DateDetector.detectDateFormat( null ) ); }
|
DateDetector { public static boolean isValidDate( String dateString, String dateFormat ) { try { getDateFromStringByFormat( dateString, dateFormat ); return true; } catch ( ParseException e ) { return false; } } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testIsValidDate() { assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING_US ) ); assertFalse( DateDetector.isValidDate( null ) ); assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) ); assertFalse( DateDetector.isValidDate( SAMPLE_DATE_STRING, null ) ); }
|
DateDetector { public static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ) { String detectedDateFormat = detectDateFormat( dateString ); if ( ( dateFormat != null ) && ( dateFormat.equals( detectedDateFormat ) ) ) { return true; } return false; } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
|
@Test public void testIsValidDateFormatToStringDate() { assertTrue( DateDetector.isValidDateFormatToStringDate( SAMPLE_DATE_FORMAT_US, SAMPLE_DATE_STRING_US ) ); assertFalse( DateDetector.isValidDateFormatToStringDate( null, SAMPLE_DATE_STRING_US ) ); assertFalse( DateDetector.isValidDateFormatToStringDate( SAMPLE_DATE_FORMAT_US, null ) ); }
@Test public void testIsValidDateFormatToStringDateLocale() { assertTrue( DateDetector.isValidDateFormatToStringDate( SAMPLE_DATE_FORMAT_US, SAMPLE_DATE_STRING_US, LOCALE_en_US ) ); assertFalse( DateDetector.isValidDateFormatToStringDate( null, SAMPLE_DATE_STRING, LOCALE_en_US ) ); assertFalse( DateDetector.isValidDateFormatToStringDate( SAMPLE_DATE_FORMAT_US, null, LOCALE_en_US ) ); assertTrue( DateDetector.isValidDateFormatToStringDate( SAMPLE_DATE_FORMAT_US, SAMPLE_DATE_STRING_US, null ) ); }
|
StringEvaluator { public int getCount() { return count; } StringEvaluator(); StringEvaluator( boolean tryTrimming ); StringEvaluator( boolean tryTrimming, List<String> numberFormats, List<String> dateFormats ); StringEvaluator( boolean tryTrimming, String[] numberFormats, String[] dateFormats ); void evaluateString( String value ); StringEvaluationResult getAdvicedResult(); String[] getDateFormats(); String[] getNumberFormats(); Set<String> getValues(); List<StringEvaluationResult> getStringEvaluationResults(); int getCount(); int getMaxLength(); }
|
@Test public void testGetCount() { List<String> strings = Arrays.asList( "02/29/2000", "03/29/2000" ); for ( String string : strings ) { evaluator.evaluateString( string ); } assertEquals( strings.size(), evaluator.getCount() ); }
|
EnvUtil { public static void environmentInit() throws KettleException { if ( Thread.currentThread().getContextClassLoader() == null ) { Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader() ); } Map<Object, Object> kettleProperties = EnvUtil.readProperties( Const.KETTLE_PROPERTIES ); insertDefaultValues( kettleProperties ); applyKettleProperties( kettleProperties ); System.getProperties().put( Const.INTERNAL_VARIABLE_CLUSTER_SIZE, "1" ); System.getProperties().put( Const.INTERNAL_VARIABLE_SLAVE_SERVER_NUMBER, "0" ); System.getProperties().put( Const.INTERNAL_VARIABLE_SLAVE_SERVER_NAME, "slave-trans-name" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_COPYNR, "0" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_NAME, "step-name" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_PARTITION_ID, "partition-id" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_PARTITION_NR, "0" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_UNIQUE_COUNT, "1" ); System.getProperties().put( Const.INTERNAL_VARIABLE_STEP_UNIQUE_NUMBER, "0" ); } static Properties readProperties( final String fileName ); static void environmentInit(); static void applyKettleProperties( Map<?, ?> kettleProperties ); static void applyKettleProperties( Map<?, ?> kettleProperties, boolean override ); static void addInternalVariables( Properties prop ); static final String[] getEnvironmentVariablesForRuntimeExec(); static final String getSystemPropertyStripQuotes( String key, String def ); static final String getSystemProperty( String key, String def ); static final String getSystemProperty( String key ); static Locale createLocale( String localeCode ); static TimeZone createTimeZone( String timeZoneId ); static String[] getTimeZones(); static String[] getLocaleList(); }
|
@Test public void vfsUserDirIsRoot_IsPublishedOnInitialisation() throws Exception { EnvUtil.environmentInit(); assertNotNull( Variables.getADefaultVariableSpace().getVariable( Const.VFS_USER_DIR_IS_ROOT ) ); assertNotNull( System.getProperty( Const.VFS_USER_DIR_IS_ROOT ) ); }
|
EnvUtil { public static Locale createLocale( String localeCode ) { Locale resultLocale = null; if ( !Utils.isEmpty( localeCode ) ) { StringTokenizer parser = new StringTokenizer( localeCode, "_" ); if ( parser.countTokens() == 2 ) { resultLocale = new Locale( parser.nextToken(), parser.nextToken() ); } else { resultLocale = new Locale( localeCode ); } } return resultLocale; } static Properties readProperties( final String fileName ); static void environmentInit(); static void applyKettleProperties( Map<?, ?> kettleProperties ); static void applyKettleProperties( Map<?, ?> kettleProperties, boolean override ); static void addInternalVariables( Properties prop ); static final String[] getEnvironmentVariablesForRuntimeExec(); static final String getSystemPropertyStripQuotes( String key, String def ); static final String getSystemProperty( String key, String def ); static final String getSystemProperty( String key ); static Locale createLocale( String localeCode ); static TimeZone createTimeZone( String timeZoneId ); static String[] getTimeZones(); static String[] getLocaleList(); }
|
@Test public void createLocale_Null() throws Exception { assertNull( EnvUtil.createLocale( null ) ); }
@Test public void createLocale_Empty() throws Exception { assertNull( EnvUtil.createLocale( "" ) ); }
@Test public void createLocale_SingleCode() throws Exception { assertEquals( Locale.ENGLISH, EnvUtil.createLocale( "en" ) ); }
@Test public void createLocale_DoubleCode() throws Exception { assertEquals( Locale.US, EnvUtil.createLocale( "en_US" ) ); }
|
TemporaryCacheManager { public void cacheSmallBlock(SmallBlock smallBlock) { smallBlockCacheMap.put(smallBlock.getHeader().getHash(), smallBlock); } private TemporaryCacheManager(); static TemporaryCacheManager getInstance(); void cacheSmallBlock(SmallBlock smallBlock); void cacheSmallBlockWithRequest(NulsDigestData requestHash, SmallBlock smallBlock); SmallBlock getSmallBlockByRequest(NulsDigestData requestHash); SmallBlock getSmallBlockByHash(NulsDigestData blockHash); boolean cacheTx(Transaction tx); Transaction getTx(NulsDigestData hash); void removeSmallBlock(NulsDigestData hash); void clear(); void destroy(); boolean containsTx(NulsDigestData txHash); int getSmallBlockCount(); int getTxCount(); }
|
@Test public void cacheSmallBlock() { SmallBlock smallBlock = new SmallBlock(); BlockHeader header = new BlockHeader(); NulsDigestData hash = NulsDigestData.calcDigestData("abcdefg".getBytes()); header.setHash(hash); manager.cacheSmallBlock(smallBlock); assertTrue(true); this.getSmallBlock(hash, smallBlock); this.removeSmallBlock(hash); manager.cacheSmallBlock(smallBlock); this.clear(); }
|
RoundManager { public MeetingRound getRoundByIndex(long roundIndex) { MeetingRound round = null; for (int i = roundList.size() - 1; i >= 0; i--) { round = roundList.get(i); if (round.getIndex() == roundIndex) { break; } } return round; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }
|
@Test public void testGetRoundByIndex() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); long index = 1002L; assertEquals(0, roundManager.getRoundList().size()); MeetingRound round = new MeetingRound(); round.setIndex(index); roundManager.addRound(round); assertEquals(1, roundManager.getRoundList().size()); MeetingRound round2 = roundManager.getRoundByIndex(index); assertNotNull(round2); assertEquals(round, round2); }
|
RoundManager { public boolean clearRound(int count) { Lockers.ROUND_LOCK.lock(); boolean doit = false; try { while (roundList.size() > count) { doit = true; roundList.remove(0); } if (doit) { MeetingRound round = roundList.get(0); round.setPreRound(null); } return true; } finally { Lockers.ROUND_LOCK.unlock(); } } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }
|
@Test public void testClearRound() { MeetingRound round = new MeetingRound(); round.setIndex(1l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(2l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(3l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(4l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(5l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(6l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(7l); roundManager.addRound(round); assertEquals(7, roundManager.getRoundList().size()); assertEquals(7L, roundManager.getCurrentRound().getIndex()); boolean success = roundManager.clearRound(3); assert(success); assertEquals(3, roundManager.getRoundList().size()); assertEquals(7L, roundManager.getCurrentRound().getIndex()); }
|
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }
|
@Test public void testInitRound() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); Chain chain = roundManager.getChain(); assertNotNull(chain.getEndBlockHeader()); assert(chain.getAllBlockList().size() > 0); MeetingRound round = roundManager.initRound(); assertNotNull(round); assertEquals(round.getIndex(), 2L); Assert.assertEquals(round.getStartTime(), ProtocolConstant.BLOCK_TIME_INTERVAL_MILLIS + 1L); MeetingRound round2 = roundManager.getNextRound(null, false); assertNotNull(round2); assertEquals(round.getIndex(), round2.getIndex()); assertEquals(round.getStartTime(), round2.getStartTime()); round2 = roundManager.getNextRound(null, true); assertNotNull(round2); assert(round.getIndex() < round2.getIndex()); assert(round.getStartTime() < round2.getStartTime()); assertEquals("", 0d, round2.getTotalWeight(), 2200000d); }
|
ConsensusTool { public static SmallBlock getSmallBlock(Block block) { SmallBlock smallBlock = new SmallBlock(); smallBlock.setHeader(block.getHeader()); List<NulsDigestData> txHashList = new ArrayList<>(); for (Transaction tx : block.getTxs()) { txHashList.add(tx.getHash()); if (tx.isSystemTx()) { smallBlock.addBaseTx(tx); } } smallBlock.setTxHashList(txHashList); return smallBlock; } static SmallBlock getSmallBlock(Block block); static Block createBlock(BlockData blockData, Account account); static CoinBaseTransaction createCoinBaseTx(MeetingMember member, List<Transaction> txList, MeetingRound localRound, long unlockHeight); static YellowPunishTransaction createYellowPunishTx(Block preBlock, MeetingMember self, MeetingRound round); static CoinData getStopAgentCoinData(Agent agent, long lockTime); static CoinData getStopAgentCoinData(Agent agent, long lockTime, Long hight); static CoinData getStopAgentCoinData(byte[] address, long lockTime); static byte[] getStateRoot(BlockHeader blockHeader); }
|
@Test public void testGetSmallBlock() { Block block = createBlock(); SmallBlock smallBlock = ConsensusTool.getSmallBlock(block); assertNotNull(smallBlock); assertEquals(smallBlock.getHeader(), block.getHeader()); assertEquals(smallBlock.getSubTxList().size() , 0); assertEquals(smallBlock.getTxHashList().get(0), block.getTxs().get(0).getHash()); }
|
RandomSeedUtils { public static byte[] createRandomSeed() { BigInteger value = new BigInteger(256, new Random()); byte[] result = value.toByteArray(); if (result.length > 32) { byte[] temp = new byte[32]; System.arraycopy(result, result.length - 32, temp, 0, 32); result = temp; } else if (result.length < 32) { byte[] temp = new byte[32]; System.arraycopy(result, 0, temp, 0, result.length); result = temp; } return result; } static byte[] createRandomSeed(); static byte[] getLastDigestEightBytes(byte[] bytes); static RandomSeedStatusPo CACHE_SEED; }
|
@Test public void createRandomSeed() { for (int i = 0; i < 1000000; i++) { byte[] result = RandomSeedUtils.createRandomSeed(); assertEquals(result.length, 32); } }
|
RandomSeedUtils { public static byte[] getLastDigestEightBytes(byte[] bytes) { byte[] hash = Sha256Hash.hashTwice(bytes); byte[] result = new byte[8]; System.arraycopy(hash, bytes.length - 8, result, 0, 8); return result; } static byte[] createRandomSeed(); static byte[] getLastDigestEightBytes(byte[] bytes); static RandomSeedStatusPo CACHE_SEED; }
|
@Test public void getLastDigestEightBytes() { byte[] seed = RandomSeedUtils.createRandomSeed(); byte[] hash = RandomSeedUtils.getLastDigestEightBytes(seed); byte[] hash2 = RandomSeedUtils.getLastDigestEightBytes(seed); assertTrue(ArraysTool.arrayEquals(hash, hash2)); assertEquals(hash.length, 8); }
|
BlockQueueProvider { public boolean put(BlockContainer blockContainer) { boolean receive = (blockContainer.getStatus() == BlockContainerStatus.RECEIVED); if (receive) { int status = BlockContainerStatus.RECEIVED; checkDownloadService(); if (!downloadService.isDownloadSuccess().isSuccess()) { status = BlockContainerStatus.DOWNLOADING; } blockContainer.setStatus(status); blockQueue.offer(blockContainer); } else { if (downloadBlockQueueHasDestory) { initDownloadQueue(); } downloadBlockQueue.offer(blockContainer); } return true; } private BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear(); }
|
@Test public void testPut() { assertNotNull(blockQueueProvider); assertEquals(0, blockQueueProvider.size()); Block block = new Block(); boolean result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); assertEquals(1, blockQueueProvider.size()); }
|
BlockQueueProvider { public BlockContainer get() { BlockContainer blockContainer = null; if (!downloadBlockQueueHasDestory) { blockContainer = downloadBlockQueue.poll(); } checkDownloadService(); boolean hasDownloadSuccess = downloadService.isDownloadSuccess().isSuccess(); if (blockContainer == null && hasDownloadSuccess && !downloadBlockQueueHasDestory) { downloadBlockQueueHasDestory = true; if (blockContainer == null) { blockContainer = blockQueue.poll(); } } else if (hasDownloadSuccess && blockContainer == null) { blockContainer = blockQueue.poll(); } return blockContainer; } private BlockQueueProvider(); static BlockQueueProvider getInstance(); boolean put(BlockContainer blockContainer); BlockContainer get(); long size(); void clear(); }
|
@Test public void testGet() { assertNotNull(blockQueueProvider); assertEquals(0, blockQueueProvider.size()); if(downloadService.isDownloadSuccess().isSuccess()) { downloadService.setDownloadSuccess(false); } Block block = new Block(); boolean result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); assertEquals(1, blockQueueProvider.size()); BlockContainer blockContainer = blockQueueProvider.get(); assertNull(blockContainer); downloadService.setDownloadSuccess(true); blockContainer = blockQueueProvider.get(); assertNotNull(blockContainer); assertEquals(blockContainer.getBlock(), block); assertEquals(blockContainer.getStatus(), BlockContainerStatus.DOWNLOADING); assertEquals(0, blockQueueProvider.size()); block = new Block(); result = blockQueueProvider.put(new BlockContainer(block, BlockContainerStatus.RECEIVED)); assertTrue(result); blockContainer = blockQueueProvider.get(); assertNotNull(blockContainer); assertEquals(blockContainer.getBlock(), block); assertEquals(blockContainer.getStatus(), BlockContainerStatus.RECEIVED); }
|
BlockProcessTask implements Runnable { @Override public void run() { Lockers.CHAIN_LOCK.lock(); try { doTask(); } catch (Exception e) { Log.error(e); } catch (Error e) { Log.error(e); } catch (Throwable e) { Log.error(e); } finally { Lockers.CHAIN_LOCK.unlock(); } } BlockProcessTask(BlockProcess blockProcess); @Override void run(); }
|
@Test public void testRun() { assertNotNull(blockProcessTask); if(downloadService.isDownloadSuccess().isSuccess()) { downloadService.setDownloadSuccess(false); } ConsensusStatusContext.setConsensusStatus(ConsensusStatus.WAIT_RUNNING); blockProcessTask.run(); assert(!ConsensusStatusContext.isRunning()); downloadService.setDownloadSuccess(true); blockProcessTask.run(); assert(ConsensusStatusContext.isRunning()); }
|
ChainContainer implements Cloneable { public MeetingRound getCurrentRound() { return roundManager.getCurrentRound(); } ChainContainer(Chain chain); boolean addBlock(Block block); Result verifyBlock(Block block); Result verifyBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean verifyCoinBaseTx(Block block, MeetingRound currentRound, MeetingMember member); boolean verifyPunishTx(Block block, MeetingRound currentRound, MeetingMember member); Result verifyAndAddBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean rollback(Block block); ChainContainer getBeforeTheForkChain(ChainContainer chainContainer); ChainContainer getAfterTheForkChain(ChainContainer chainContainer); MeetingRound getCurrentRound(); MeetingRound getOrResetCurrentRound(); MeetingRound getOrResetCurrentRound(boolean isRealTime); MeetingRound initRound(); void clearRound(int count); Block getBestBlock(); Chain getChain(); void setChain(Chain chain); @Override boolean equals(Object obj); RoundManager getRoundManager(); }
|
@Test public void testInit() { assertNotNull(chain); assertNotNull(chainContainer); assertNotNull(chainContainer.getCurrentRound()); assertEquals(chainContainer.getCurrentRound().getMemberCount(), 1); }
|
TemporaryCacheManager { public boolean cacheTx(Transaction tx) { return txCacheMap.put(tx.getHash(), tx); } private TemporaryCacheManager(); static TemporaryCacheManager getInstance(); void cacheSmallBlock(SmallBlock smallBlock); void cacheSmallBlockWithRequest(NulsDigestData requestHash, SmallBlock smallBlock); SmallBlock getSmallBlockByRequest(NulsDigestData requestHash); SmallBlock getSmallBlockByHash(NulsDigestData blockHash); boolean cacheTx(Transaction tx); Transaction getTx(NulsDigestData hash); void removeSmallBlock(NulsDigestData hash); void clear(); void destroy(); boolean containsTx(NulsDigestData txHash); int getSmallBlockCount(); int getTxCount(); }
|
@Test public void cacheTx() { Transaction tx = new CacheTestTx(); tx.setTime(1234567654L); try { tx.setHash(NulsDigestData.calcDigestData(tx.serializeForHash())); } catch (IOException e) { Log.error(e); } manager.cacheTx(tx); assertTrue(true); getTx(tx.getHash(), tx); }
|
ChainContainer implements Cloneable { public boolean addBlock(Block block) { if (!chain.getEndBlockHeader().getHash().equals(block.getHeader().getPreHash()) || chain.getEndBlockHeader().getHeight() + 1 != block.getHeader().getHeight()) { return false; } List<Agent> agentList = chain.getAgentList(); List<Deposit> depositList = chain.getDepositList(); List<PunishLogPo> yellowList = chain.getYellowPunishList(); List<PunishLogPo> redList = chain.getRedPunishList(); long height = block.getHeader().getHeight(); BlockExtendsData extendsData = new BlockExtendsData(block.getHeader().getExtend()); List<Transaction> txs = block.getTxs(); for (Transaction tx : txs) { int txType = tx.getType(); if (txType == ConsensusConstant.TX_TYPE_REGISTER_AGENT) { CreateAgentTransaction registerAgentTx = (CreateAgentTransaction) tx; CreateAgentTransaction agentTx = registerAgentTx.clone(); Agent agent = agentTx.getTxData(); agent.setDelHeight(-1L); agent.setBlockHeight(height); agent.setTxHash(agentTx.getHash()); agent.setTime(agentTx.getTime()); agentList.add(agent); } else if (txType == ConsensusConstant.TX_TYPE_JOIN_CONSENSUS) { DepositTransaction joinConsensusTx = (DepositTransaction) tx; DepositTransaction depositTx = joinConsensusTx.clone(); Deposit deposit = depositTx.getTxData(); deposit.setDelHeight(-1L); deposit.setBlockHeight(height); deposit.setTxHash(depositTx.getHash()); deposit.setTime(depositTx.getTime()); depositList.add(deposit); } else if (txType == ConsensusConstant.TX_TYPE_CANCEL_DEPOSIT) { CancelDepositTransaction cancelDepositTx = (CancelDepositTransaction) tx; NulsDigestData joinHash = cancelDepositTx.getTxData().getJoinTxHash(); Iterator<Deposit> it = depositList.iterator(); while (it.hasNext()) { Deposit deposit = it.next(); cancelDepositTx.getTxData().setAddress(deposit.getAddress()); if (deposit.getTxHash().equals(joinHash)) { if (deposit.getDelHeight() == -1L) { deposit.setDelHeight(height); } break; } } } else if (txType == ConsensusConstant.TX_TYPE_STOP_AGENT) { StopAgentTransaction stopAgentTx = (StopAgentTransaction) tx; NulsDigestData agentHash = stopAgentTx.getTxData().getCreateTxHash(); Iterator<Deposit> it = depositList.iterator(); while (it.hasNext()) { Deposit deposit = it.next(); if (deposit.getAgentHash().equals(agentHash) && deposit.getDelHeight() == -1L) { deposit.setDelHeight(height); } } Iterator<Agent> ita = agentList.iterator(); while (ita.hasNext()) { Agent agent = ita.next(); stopAgentTx.getTxData().setAddress(agent.getAgentAddress()); if (agent.getTxHash().equals(agentHash)) { if (agent.getDelHeight() == -1L) { agent.setDelHeight(height); } break; } } } else if (txType == ConsensusConstant.TX_TYPE_RED_PUNISH) { RedPunishTransaction transaction = (RedPunishTransaction) tx; RedPunishData redPunishData = transaction.getTxData(); PunishLogPo po = new PunishLogPo(); po.setAddress(redPunishData.getAddress()); po.setHeight(height); po.setRoundIndex(extendsData.getRoundIndex()); po.setTime(tx.getTime()); po.setType(PunishType.RED.getCode()); redList.add(po); for (Agent agent : agentList) { if (!Arrays.equals(agent.getAgentAddress(), po.getAddress())) { continue; } if (agent.getDelHeight() > 0) { continue; } agent.setDelHeight(height); for (Deposit deposit : depositList) { if (!deposit.getAgentHash().equals(agent.getTxHash())) { continue; } if (deposit.getDelHeight() > 0) { continue; } deposit.setDelHeight(height); } } } else if (txType == ConsensusConstant.TX_TYPE_YELLOW_PUNISH) { YellowPunishTransaction transaction = (YellowPunishTransaction) tx; for (byte[] bytes : transaction.getTxData().getAddressList()) { PunishLogPo po = new PunishLogPo(); po.setAddress(bytes); po.setHeight(height); po.setRoundIndex(extendsData.getRoundIndex()); po.setTime(tx.getTime()); po.setType(PunishType.YELLOW.getCode()); yellowList.add(po); } } } chain.addBlock(block); return true; } ChainContainer(Chain chain); boolean addBlock(Block block); Result verifyBlock(Block block); Result verifyBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean verifyCoinBaseTx(Block block, MeetingRound currentRound, MeetingMember member); boolean verifyPunishTx(Block block, MeetingRound currentRound, MeetingMember member); Result verifyAndAddBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean rollback(Block block); ChainContainer getBeforeTheForkChain(ChainContainer chainContainer); ChainContainer getAfterTheForkChain(ChainContainer chainContainer); MeetingRound getCurrentRound(); MeetingRound getOrResetCurrentRound(); MeetingRound getOrResetCurrentRound(boolean isRealTime); MeetingRound initRound(); void clearRound(int count); Block getBestBlock(); Chain getChain(); void setChain(Chain chain); @Override boolean equals(Object obj); RoundManager getRoundManager(); }
|
@Test public void testAddBlock() { Block bestBlock = chainContainer.getBestBlock(); assertNotNull(bestBlock); Block newBlock = newBlock(bestBlock); Result success = chainContainer.verifyBlock(newBlock); assertTrue(success.isSuccess()); bestBlock = chainContainer.getBestBlock(); assertEquals(bestBlock.getHeader().getHeight(), 0L); for (int i = 0; i < 100; i++) { newBlock = newBlock(bestBlock); success = chainContainer.verifyAndAddBlock(newBlock, false, true); assertTrue(success.isSuccess()); bestBlock = chainContainer.getBestBlock(); assertEquals(bestBlock.getHeader().getHeight(), 1L + i); } System.out.println(); }
|
ChainContainer implements Cloneable { public boolean rollback(Block block) { int length = chain.getAllBlockList().size(); if (block == null || length == 0) { return false; } Block bestBlock = chain.getBestBlock(); if (!block.getHeader().getHash().equals(bestBlock.getHeader().getHash())) { Log.warn("rollbackTransaction block is not best block"); return false; } if (length <= 2) { addBlockInBlockList(chain); } BlockHeader rollbackBlockHeader = chain.rollbackBlock(); List<Agent> agentList = chain.getAgentList(); List<Deposit> depositList = chain.getDepositList(); List<PunishLogPo> yellowList = chain.getYellowPunishList(); List<PunishLogPo> redPunishList = chain.getRedPunishList(); long height = rollbackBlockHeader.getHeight(); for (int i = agentList.size() - 1; i >= 0; i--) { Agent agent = agentList.get(i); if (agent.getDelHeight() == height) { agent.setDelHeight(-1L); } if (agent.getBlockHeight() == height) { agentList.remove(i); } } for (int i = depositList.size() - 1; i >= 0; i--) { Deposit deposit = depositList.get(i); if (deposit.getDelHeight() == height) { deposit.setDelHeight(-1L); } if (deposit.getBlockHeight() == height) { depositList.remove(i); } } for (int i = yellowList.size() - 1; i >= 0; i--) { PunishLogPo tempYellow = yellowList.get(i); if (tempYellow.getHeight() < height) { break; } if (tempYellow.getHeight() == height) { yellowList.remove(i); } } for (int i = redPunishList.size() - 1; i >= 0; i--) { PunishLogPo redPunish = redPunishList.get(i); if (redPunish.getHeight() < height) { break; } if (redPunish.getHeight() == height) { redPunishList.remove(i); } } roundManager.checkIsNeedReset(); return true; } ChainContainer(Chain chain); boolean addBlock(Block block); Result verifyBlock(Block block); Result verifyBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean verifyCoinBaseTx(Block block, MeetingRound currentRound, MeetingMember member); boolean verifyPunishTx(Block block, MeetingRound currentRound, MeetingMember member); Result verifyAndAddBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean rollback(Block block); ChainContainer getBeforeTheForkChain(ChainContainer chainContainer); ChainContainer getAfterTheForkChain(ChainContainer chainContainer); MeetingRound getCurrentRound(); MeetingRound getOrResetCurrentRound(); MeetingRound getOrResetCurrentRound(boolean isRealTime); MeetingRound initRound(); void clearRound(int count); Block getBestBlock(); Chain getChain(); void setChain(Chain chain); @Override boolean equals(Object obj); RoundManager getRoundManager(); }
|
@Test public void testRollback() { testAddAgent(); assertEquals(chainContainer.getCurrentRound().getMemberCount(), 2); for (int i = 3; i > 0; i--) { Block bestBlock = chainContainer.getBestBlock(); boolean success = chainContainer.rollback(bestBlock); assert (success); } assertEquals(chainContainer.getCurrentRound().getMemberCount(), 1); }
|
ChainContainer implements Cloneable { public ChainContainer getBeforeTheForkChain(ChainContainer chainContainer) { Chain newChain = new Chain(); newChain.setId(chainContainer.getChain().getId()); newChain.initData(chain.getStartBlockHeader(), new CopyOnWriteArrayList<>(chain.getAllBlockHeaderList()), new CopyOnWriteArrayList<>(chain.getAllBlockList())); if (chain.getAgentList() != null) { List<Agent> agentList = new ArrayList<>(); for (Agent agent : chain.getAgentList()) { try { agentList.add(agent.clone()); } catch (CloneNotSupportedException e) { Log.error(e); } } newChain.setAgentList(agentList); } if (chain.getDepositList() != null) { List<Deposit> depositList = new ArrayList<>(); for (Deposit deposit : chain.getDepositList()) { try { depositList.add(deposit.clone()); } catch (CloneNotSupportedException e) { Log.error(e); } } newChain.setDepositList(depositList); } if (chain.getYellowPunishList() != null) { newChain.setYellowPunishList(new ArrayList<>(chain.getYellowPunishList())); } if (chain.getRedPunishList() != null) { newChain.setRedPunishList(new ArrayList<>(chain.getRedPunishList())); } ChainContainer newChainContainer = new ChainContainer(newChain); BlockHeader pointBlockHeader = chainContainer.getChain().getStartBlockHeader(); List<Block> blockList = newChain.getAllBlockList(); for (int i = blockList.size() - 1; i >= 0; i--) { Block block = blockList.get(i); if (pointBlockHeader.getPreHash().equals(block.getHeader().getHash())) { break; } newChainContainer.rollback(block); } newChainContainer.initRound(); return newChainContainer; } ChainContainer(Chain chain); boolean addBlock(Block block); Result verifyBlock(Block block); Result verifyBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean verifyCoinBaseTx(Block block, MeetingRound currentRound, MeetingMember member); boolean verifyPunishTx(Block block, MeetingRound currentRound, MeetingMember member); Result verifyAndAddBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean rollback(Block block); ChainContainer getBeforeTheForkChain(ChainContainer chainContainer); ChainContainer getAfterTheForkChain(ChainContainer chainContainer); MeetingRound getCurrentRound(); MeetingRound getOrResetCurrentRound(); MeetingRound getOrResetCurrentRound(boolean isRealTime); MeetingRound initRound(); void clearRound(int count); Block getBestBlock(); Chain getChain(); void setChain(Chain chain); @Override boolean equals(Object obj); RoundManager getRoundManager(); }
|
@Test public void testGetBeforeTheForkChain() { Block forkBlock = null; for (int i = 0; i < 20; i++) { Block bestBlock = chainContainer.getBestBlock(); Block newBlock = newBlock(bestBlock); Result success = chainContainer.verifyAndAddBlock(newBlock, false, true); assertTrue(success.isSuccess()); bestBlock = chainContainer.getBestBlock(); assertEquals(bestBlock.getHeader().getHeight(), 1L + i); if (i == 10) { forkBlock = bestBlock; } } Chain chain = new Chain(); chain.addBlock(forkBlock); Block newBlock = newBlock(forkBlock); chain.addBlock(newBlock); ChainContainer otherChainContainer = new ChainContainer(chain); ChainContainer newForkChainContainer = chainContainer.getBeforeTheForkChain(otherChainContainer); assertEquals(newForkChainContainer.getBestBlock().getHeader().getHeight(), 10L); }
|
ChainContainer implements Cloneable { public ChainContainer getAfterTheForkChain(ChainContainer chainContainer) { BlockHeader pointBlockHeader = chainContainer.getChain().getStartBlockHeader(); Chain chain = new Chain(); List<Block> blockList = getChain().getAllBlockList(); boolean canAdd = false; for (int i = 0; i < blockList.size(); i++) { Block block = blockList.get(i); if (canAdd) { chain.addBlock(block); } if (pointBlockHeader.getPreHash().equals(block.getHeader().getHash())) { canAdd = true; chain.setPreChainId(getChain().getId()); continue; } } return new ChainContainer(chain); } ChainContainer(Chain chain); boolean addBlock(Block block); Result verifyBlock(Block block); Result verifyBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean verifyCoinBaseTx(Block block, MeetingRound currentRound, MeetingMember member); boolean verifyPunishTx(Block block, MeetingRound currentRound, MeetingMember member); Result verifyAndAddBlock(Block block, boolean isDownload, boolean isNeedCheckCoinBaseTx); boolean rollback(Block block); ChainContainer getBeforeTheForkChain(ChainContainer chainContainer); ChainContainer getAfterTheForkChain(ChainContainer chainContainer); MeetingRound getCurrentRound(); MeetingRound getOrResetCurrentRound(); MeetingRound getOrResetCurrentRound(boolean isRealTime); MeetingRound initRound(); void clearRound(int count); Block getBestBlock(); Chain getChain(); void setChain(Chain chain); @Override boolean equals(Object obj); RoundManager getRoundManager(); }
|
@Test public void testGetAfterTheForkChain() { Block forkBlock = null; for (int i = 0; i < 30; i++) { Block bestBlock = chainContainer.getBestBlock(); Block newBlock = newBlock(bestBlock); Result success = chainContainer.verifyAndAddBlock(newBlock, false, true); assertTrue(success.isSuccess()); bestBlock = chainContainer.getBestBlock(); assertEquals(bestBlock.getHeader().getHeight(), 1L + i); if (i == 20) { forkBlock = bestBlock; } } Chain chain = new Chain(); chain.addBlock(forkBlock); Block newBlock = newBlock(forkBlock); chain.addBlock(newBlock); ChainContainer otherChainContainer = new ChainContainer(chain); ChainContainer newForkChainContainer = chainContainer.getAfterTheForkChain(otherChainContainer); assertEquals(newForkChainContainer.getBestBlock().getHeader().getHeight(), 30L); }
|
MicroKernelBootstrap extends BaseModuleBootstrap { @Override public void init() { String folder = null; try { NulsConfig.NULS_CONFIG = ConfigLoader.loadIni(NulsConstant.USER_CONFIG_FILE); String mode = NulsConfig.NULS_CONFIG.getCfgValue(NulsConstant.CFG_SYSTEM_SECTION, "mode", "main"); if ("main".equals(mode)) { NulsConfig.MODULES_CONFIG = ConfigLoader.loadIni(NulsConstant.MODULES_CONFIG_FILE); } else { NulsConfig.MODULES_CONFIG = ConfigLoader.loadIni(mode + "/" + NulsConstant.MODULES_CONFIG_FILE); } } catch (Exception e) { Log.error("Client start failed", e); throw new RuntimeException("Client start failed"); } TimeService.getInstance().start(); try { NulsConfig.DEFAULT_ENCODING = NulsConfig.NULS_CONFIG.getCfgValue(NulsConstant.CFG_SYSTEM_SECTION, NulsConstant.CFG_SYSTEM_DEFAULT_ENCODING); String language = NulsConfig.NULS_CONFIG.getCfgValue(NulsConstant.CFG_SYSTEM_SECTION, NulsConstant.CFG_SYSTEM_LANGUAGE); I18nUtils.setLanguage(language); String chainId = NulsConfig.NULS_CONFIG.getCfgValue(NulsConstant.CFG_SYSTEM_SECTION, NulsConstant.CFG_SYSTEM_DEFAULT_CHAIN_ID, "8964"); NulsContext.getInstance().setDefaultChainId(Short.parseShort(chainId)); } catch (Exception e) { Log.error(e); } SpringLiteContext.init("io.nuls", new ModularServiceMethodInterceptor()); try { NulsConfig.VERSION = getKernelVersion(); TransactionManager.init(); ValidatorManager.init(); } catch (Exception e) { Log.error(e); } } private MicroKernelBootstrap(); static MicroKernelBootstrap getInstance(); @Override void init(); @Override void start(); @Override void shutdown(); @Override void destroy(); @Override String getInfo(); }
|
@Test public void init() { bootstrap.init(); assertNotNull(NulsConfig.MODULES_CONFIG); assertNotNull(NulsConfig.NULS_CONFIG); assertTrue(SpringLiteContext.isInitSuccess()); assertNotNull(NulsConfig.VERSION); assertNotNull(ValidatorManager.isInitSuccess()); }
|
NulsDigestData extends BaseNulsData { public static NulsDigestData calcDigestData(BaseNulsData data) { return calcDigestData(data, (byte) 0); } NulsDigestData(); NulsDigestData(byte algType, byte[] bytes); @Override int size(); @Override void parse(NulsByteBuffer byteBuffer); byte getDigestAlgType(); void setDigestAlgType(byte digestAlgType); String getDigestHex(); static NulsDigestData fromDigestHex(String hex); static boolean validHash(String hex); static NulsDigestData calcDigestData(BaseNulsData data); static NulsDigestData calcDigestData(BaseNulsData data, byte digestAlgType); byte[] getDigestBytes(); static NulsDigestData calcDigestData(byte[] data); static NulsDigestData calcDigestData(byte[] data, byte digestAlgType); static NulsDigestData calcMerkleDigestData(List<NulsDigestData> ddList); @Override boolean equals(Object obj); @Override String toString(); @Override int hashCode(); static final int HASH_LENGTH; static byte DIGEST_ALG_SHA256; static byte DIGEST_ALG_SHA160; }
|
@Test public void test() { NulsDigestData hash = NulsDigestData.calcDigestData(new byte[32]); System.out.println(hash); assertTrue(true); }
|
MessageBusServiceImpl implements MessageBusService { @Override public String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler) { MessageManager.putMessage(messageClass); return handlerManager.registerMessageHandler(null, messageClass, messageHandler); } @Override String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler); @Override void unsubscribeMessage(String subscribeId); @Override void receiveMessage(BaseMessage message, Node node); void shutdown(); @Override Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent); @Override Result sendToNode(BaseMessage message, Node node, boolean aysn); @Override Result<? extends BaseMessage> getMessageInstance(short moduleId, int type); }
|
@Test public void subscribeMessage() throws Exception { subscribe(); assertNotNull(handlerId); Field field = messageBusService.getClass().getDeclaredField("processorManager"); field.setAccessible(true); DispatchManager processorManager = (DispatchManager) field.get(messageBusService); Class processorManagerClass = processorManager.getClass(); Field handlerMapField = processorManagerClass.getDeclaredField("handlerMap"); handlerMapField.setAccessible(true); Map<String, NulsMessageHandler> handlerMap = (Map<String, NulsMessageHandler>) handlerMapField.get(processorManager); assertNotNull(handlerMap.get(handlerId)); assertEquals(handlerMap.get(handlerId), messageHandler); Field messageHandlerMappingField = processorManagerClass.getDeclaredField("messageHandlerMapping"); messageHandlerMappingField.setAccessible(true); Map<Class, Set<String>> messageHandlerMapping = (Map<Class, Set<String>>) messageHandlerMappingField.get(processorManager); assertNotNull(messageHandlerMapping.get(block)); assertTrue(messageHandlerMapping.get(block).contains(handlerId)); }
|
MessageBusServiceImpl implements MessageBusService { @Override public void unsubscribeMessage(String subscribeId) { this.handlerManager.removeMessageHandler(subscribeId); } @Override String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler); @Override void unsubscribeMessage(String subscribeId); @Override void receiveMessage(BaseMessage message, Node node); void shutdown(); @Override Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent); @Override Result sendToNode(BaseMessage message, Node node, boolean aysn); @Override Result<? extends BaseMessage> getMessageInstance(short moduleId, int type); }
|
@Test public void unsubscribeMessage() throws Exception { messageBusService.unsubscribeMessage(handlerId); Field field = messageBusService.getClass().getDeclaredField("processorManager"); field.setAccessible(true); DispatchManager processorManager = (DispatchManager) field.get(messageBusService); Class processorManagerClass = processorManager.getClass(); Field handlerMapField = processorManagerClass.getDeclaredField("handlerMap"); handlerMapField.setAccessible(true); Map<String, NulsMessageHandler> handlerMap = (Map<String, NulsMessageHandler>) handlerMapField.get(processorManager); assertNull(handlerMap.get(handlerId)); }
|
MessageBusServiceImpl implements MessageBusService { @Override public void receiveMessage(BaseMessage message, Node node) { try { this.processorManager.offer(new ProcessData(message, node)); } catch (Exception e) { Log.error(e); } } @Override String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler); @Override void unsubscribeMessage(String subscribeId); @Override void receiveMessage(BaseMessage message, Node node); void shutdown(); @Override Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent); @Override Result sendToNode(BaseMessage message, Node node, boolean aysn); @Override Result<? extends BaseMessage> getMessageInstance(short moduleId, int type); }
|
@Test public void receiveMessage() { BlockMessage blockMessage = new BlockMessage(); Node node = new Node("192.168.1.90",8003,1); messageBusService.receiveMessage(blockMessage, node); }
|
MessageBusServiceImpl implements MessageBusService { @Override public Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent) { BroadcastResult result = networkService.sendToAllNode(message, excludeNode, aysn, percent); return getNodeIdListResult(result); } @Override String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler); @Override void unsubscribeMessage(String subscribeId); @Override void receiveMessage(BaseMessage message, Node node); void shutdown(); @Override Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent); @Override Result sendToNode(BaseMessage message, Node node, boolean aysn); @Override Result<? extends BaseMessage> getMessageInstance(short moduleId, int type); }
|
@Test public void broadcastAndCache() { BlockMessage blockMessage = new BlockMessage(); Node node = new Node("192.168.1.90",8003,1); boolean aysn = true; Result<List<String>> result = messageBusService.broadcast(blockMessage, node, aysn,100); assertTrue(result.isSuccess()); assertTrue(result.getData().size()>0); }
|
TemporaryCacheManager { public void destroy() { this.smallBlockCacheMap.clear(); this.txCacheMap.clear(); } private TemporaryCacheManager(); static TemporaryCacheManager getInstance(); void cacheSmallBlock(SmallBlock smallBlock); void cacheSmallBlockWithRequest(NulsDigestData requestHash, SmallBlock smallBlock); SmallBlock getSmallBlockByRequest(NulsDigestData requestHash); SmallBlock getSmallBlockByHash(NulsDigestData blockHash); boolean cacheTx(Transaction tx); Transaction getTx(NulsDigestData hash); void removeSmallBlock(NulsDigestData hash); void clear(); void destroy(); boolean containsTx(NulsDigestData txHash); int getSmallBlockCount(); int getTxCount(); }
|
@Test public void destroy() { manager.destroy(); assertNull(EhCacheManager.getInstance().getCache("temp-small-block-cache")); assertNull(EhCacheManager.getInstance().getCache("temp-tx-cache")); }
|
MessageBusServiceImpl implements MessageBusService { @Override public Result sendToNode(BaseMessage message, Node node, boolean aysn) { BroadcastResult result = networkService.sendToNode(message, node, aysn); if (!result.isSuccess()) { Log.error("send to node fail reason: " + result.getErrorCode().getMsg() + "::::" + node.getId()); } return new Result(result.isSuccess(), result.getErrorCode(), null); } @Override String subscribeMessage(Class<? extends BaseMessage> messageClass, NulsMessageHandler<? extends BaseMessage> messageHandler); @Override void unsubscribeMessage(String subscribeId); @Override void receiveMessage(BaseMessage message, Node node); void shutdown(); @Override Result<List<String>> broadcast(BaseMessage message, Node excludeNode, boolean aysn, int percent); @Override Result sendToNode(BaseMessage message, Node node, boolean aysn); @Override Result<? extends BaseMessage> getMessageInstance(short moduleId, int type); }
|
@Test public void sendToNode() { BlockMessage blockMessage = new BlockMessage(); Node node = new Node("192.168.1.90",8003,1); boolean aysn = true; assertTrue(messageBusService.sendToNode(blockMessage, node, aysn).isSuccess()); }
|
MessageBusModuleBootstrap extends AbstractMessageBusModule { @Override public void start() { DispatchManager.getInstance().init(true); } @Override void init(); @Override void start(); @Override void shutdown(); @Override void destroy(); @Override String getInfo(); }
|
@Test public void start() { messageBusModuleBootstrap.start(); }
|
MessageBusModuleBootstrap extends AbstractMessageBusModule { @Override public void shutdown() { DispatchManager.getInstance().shutdown(); } @Override void init(); @Override void start(); @Override void shutdown(); @Override void destroy(); @Override String getInfo(); }
|
@Test public void shutdown() { messageBusModuleBootstrap.shutdown(); }
|
MessageBusModuleBootstrap extends AbstractMessageBusModule { @Override public void destroy() { } @Override void init(); @Override void start(); @Override void shutdown(); @Override void destroy(); @Override String getInfo(); }
|
@Test public void destroy() { messageBusModuleBootstrap.destroy(); }
|
AccountBaseService { public Result getPrivateKey(String address, String password) { if (!AddressTool.validAddress(address)) { return Result.getFailed(AccountErrorCode.ADDRESS_ERROR); } Account account = accountService.getAccount(address).getData(); if (null == account) { return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST); } if (account.isEncrypted()) { try { byte[] priKeyBytes = priKeyBytes = account.getPriKey(password); return Result.getSuccess().setData(Hex.encode(priKeyBytes)); } catch (NulsException e) { return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG); } } return Result.getFailed(AccountErrorCode.ACCOUNT_UNENCRYPTED); } Result setRemark(String address, String remark); Result getPrivateKey(String address, String password); Result getAllPrivateKey(String password); Result getAllPrivateKey(); Result setPassword(String address, String password); Result changePassword(String address, String oldPassword, String newPassword); }
|
@Test public void getPrivateKeyTest() { List<Account> accounts = this.accountService.createAccount(1, "nuls123456").getData(); Account account = accounts.get(0); Result result = accountBaseService.getPrivateKey(account.getAddress().toString(), "nuls123456"); assertTrue(result.isSuccess()); try { account.unlock("nuls123456"); } catch (NulsException e) { e.printStackTrace(); } assertArrayEquals(Hex.decode((String)result.getData()), account.getPriKey()); List<Account> accounts2 = this.accountService.createAccount(1, "").getData(); Account account2 = accounts2.get(0); Result result2 = accountBaseService.getPrivateKey(account2.getAddress().toString(), ""); assertTrue(result2.isSuccess()); assertArrayEquals(Hex.decode((String)result2.getData()), account2.getPriKey()); }
|
AccountBaseService { public Result setPassword(String address, String password) { if (!AddressTool.validAddress(address)) { return Result.getFailed(AccountErrorCode.ADDRESS_ERROR); } if (StringUtils.isBlank(password)) { return Result.getFailed(AccountErrorCode.NULL_PARAMETER); } if (!StringUtils.validPassword(password)) { return Result.getFailed(AccountErrorCode.PASSWORD_FORMAT_WRONG); } Account account = accountService.getAccount(address).getData(); if (null == account) { return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST); } if (account.isEncrypted()) { return Result.getFailed(AccountErrorCode.ACCOUNT_IS_ALREADY_ENCRYPTED); } try { account.encrypt(password); Result result = accountStorageService.updateAccount(new AccountPo(account)); if (result.isFailed()) { return Result.getFailed(AccountErrorCode.FAILED); } accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } catch (NulsException e) { Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); } Result setRemark(String address, String remark); Result getPrivateKey(String address, String password); Result getAllPrivateKey(String password); Result getAllPrivateKey(); Result setPassword(String address, String password); Result changePassword(String address, String oldPassword, String newPassword); }
|
@Test public void setPassword() { List<Account> accounts = this.accountService.createAccount(1, "").getData(); Account account = accounts.get(0); accountBaseService.setPassword(account.getAddress().toString(),"nuls123456"); Account acc = accountService.getAccount(account.getAddress()).getData(); try { assertTrue(acc.unlock("nuls123456")); assertArrayEquals(acc.getPriKey(), account.getPriKey()); } catch (NulsException e) { e.printStackTrace(); } }
|
AccountBaseService { public Result changePassword(String address, String oldPassword, String newPassword) { if (!AddressTool.validAddress(address)) { return Result.getFailed(AccountErrorCode.ADDRESS_ERROR); } if (StringUtils.isBlank(oldPassword)) { return Result.getFailed(AccountErrorCode.PARAMETER_ERROR); } if (StringUtils.isBlank(newPassword)) { return Result.getFailed(AccountErrorCode.PARAMETER_ERROR); } if (!StringUtils.validPassword(oldPassword)) { return Result.getFailed(AccountErrorCode.PASSWORD_FORMAT_WRONG); } if (!StringUtils.validPassword(newPassword)) { return Result.getFailed(AccountErrorCode.PASSWORD_FORMAT_WRONG); } Account account = accountService.getAccount(address).getData(); if (null == account) { return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST); } try { if (!account.isEncrypted()) { return Result.getFailed(AccountErrorCode.ACCOUNT_UNENCRYPTED); } if (!account.validatePassword(oldPassword)) { return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG); } account.unlock(oldPassword); account.encrypt(newPassword, true); AccountPo po = new AccountPo(account); Result result = accountStorageService.updateAccount(po); if (result.isFailed()) { return Result.getFailed(AccountErrorCode.FAILED); } accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); return result.setData(true); } catch (NulsException e) { Log.error(e); return Result.getFailed(e.getErrorCode()); } } Result setRemark(String address, String remark); Result getPrivateKey(String address, String password); Result getAllPrivateKey(String password); Result getAllPrivateKey(); Result setPassword(String address, String password); Result changePassword(String address, String oldPassword, String newPassword); }
|
@Test public void changePassword() { List<Account> accounts = this.accountService.createAccount(1, "nuls123456").getData(); Account account = accounts.get(0); accountBaseService.changePassword(account.getAddress().toString(),"nuls123456", "nuls111111"); Account acc = accountService.getAccount(account.getAddress()).getData(); try { assertFalse(acc.unlock("nuls123456")); assertTrue(acc.unlock("nuls111111")); assertArrayEquals(acc.getPriKey(), account.getPriKey()); } catch (NulsException e) { } }
|
AliasService { public Result<String> setAlias(String addr, String aliasName, String password) { if (!AddressTool.validAddress(addr)) { return Result.getFailed(AccountErrorCode.ADDRESS_ERROR); } Account account = accountService.getAccount(addr).getData(); if (null == account) { return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST); } if (account.isEncrypted() && account.isLocked()) { if (!account.validatePassword(password)) { return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG); } } if (!account.isOk()) { return Result.getFailed(AccountErrorCode.IMPORTING_ACCOUNT); } if (StringUtils.isNotBlank(account.getAlias())) { return Result.getFailed(AccountErrorCode.ACCOUNT_ALREADY_SET_ALIAS); } if (!StringUtils.validAlias(aliasName)) { return Result.getFailed(AccountErrorCode.ALIAS_FORMAT_WRONG); } if (!isAliasUsable(aliasName)) { return Result.getFailed(AccountErrorCode.ALIAS_EXIST); } byte[] addressBytes = account.getAddress().getAddressBytes(); try { AliasTransaction tx = new AliasTransaction(); tx.setTime(TimeService.currentTimeMillis()); Alias alias = new Alias(addressBytes, aliasName); tx.setTxData(alias); CoinDataResult coinDataResult = accountLedgerService.getCoinData(addressBytes, AccountConstant.ALIAS_NA, tx.size(), TransactionFeeCalculator.OTHER_PRICE_PRE_1024_BYTES); if (!coinDataResult.isEnough()) { return Result.getFailed(AccountErrorCode.INSUFFICIENT_BALANCE); } CoinData coinData = new CoinData(); coinData.setFrom(coinDataResult.getCoinList()); Coin change = coinDataResult.getChange(); if (null != change) { List<Coin> toList = new ArrayList<>(); toList.add(change); coinData.setTo(toList); } Coin coin = new Coin(NulsConstant.BLACK_HOLE_ADDRESS, AccountConstant.ALIAS_NA, 0); coinData.addTo(coin); tx.setCoinData(coinData); tx.setHash(NulsDigestData.calcDigestData(tx.serializeForHash())); List<ECKey> signEckeys = new ArrayList<>(); List<ECKey> scriptEckeys = new ArrayList<>(); ; ECKey eckey = account.getEcKey(password); if ((coinDataResult.getSignType() & 0x01) == 0x01) { signEckeys.add(eckey); } if ((coinDataResult.getSignType() & 0x02) == 0x02) { scriptEckeys.add(eckey); } SignatureUtil.createTransactionSignture(tx, scriptEckeys, signEckeys); Result saveResult = accountLedgerService.verifyAndSaveUnconfirmedTransaction(tx); if (saveResult.isFailed()) { if (KernelErrorCode.DATA_SIZE_ERROR.getCode().equals(saveResult.getErrorCode().getCode())) { Result rs = accountLedgerService.getMaxAmountOfOnce(account.getAddress().getAddressBytes(), tx, TransactionFeeCalculator.OTHER_PRICE_PRE_1024_BYTES); if (rs.isSuccess()) { Na maxAmount = (Na) rs.getData(); rs = Result.getFailed(KernelErrorCode.DATA_SIZE_ERROR_EXTEND); rs.setMsg(rs.getMsg() + maxAmount.toDouble()); } return rs; } return saveResult; } this.transactionService.newTx(tx); Result sendResult = this.transactionService.broadcastTx(tx); if (sendResult.isFailed()) { accountLedgerService.deleteTransaction(tx); return sendResult; } String hash = tx.getHash().getDigestHex(); return Result.getSuccess().setData(hash); } catch (Exception e) { Log.error(e); return Result.getFailed(KernelErrorCode.SYS_UNKOWN_EXCEPTION); } } Result<String> setAlias(String addr, String aliasName, String password); Result saveAlias(AliasPo aliaspo); Alias getAlias(String alias); boolean isAliasUsable(String alias); Result rollbackAlias(AliasPo aliasPo); Result<Na> getAliasFee(String address, String aliasName); Result<Na> getMultiAliasFee(String address, String aliasName); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password, List<String> pubKeys, int m, String txdata); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password); Result signMultiAliasTransaction(String signAddr, String password, String txdata); boolean isMutilAliasUsable(byte[] address, String aliasName); Result<String> txMutilProcessing(Transaction tx, List<P2PHKSignature> p2PHKSignatures, List<Script> scripts, TransactionSignature transactionSignature, byte[] fromAddr); List<AliasPo> getAllAlias(); }
|
@Test public void setAlias() { List<Account> accounts = accountService.createAccount(1, "nuls123456").getData(); Account account = accounts.get(0); Result result = aliasService.setAlias(account.getAddress().toString(), "nuls123456", "Charlie555"); assertTrue(result.isSuccess()); }
|
AliasService { public Result saveAlias(AliasPo aliaspo) throws NulsException { try { Result result = aliasStorageService.saveAlias(aliaspo); if (result.isFailed()) { this.rollbackAlias(aliaspo); } AccountPo po = accountStorageService.getAccount(aliaspo.getAddress()).getData(); if (null != po) { po.setAlias(aliaspo.getAlias()); Result resultAcc = accountStorageService.updateAccount(po); if (resultAcc.isFailed()) { this.rollbackAlias(aliaspo); } Account account = po.toAccount(); accountCacheService.localAccountMaps.put(account.getAddress().getBase58(), account); } } catch (Exception e) { this.rollbackAlias(aliaspo); Log.error(e); return Result.getFailed(AccountErrorCode.FAILED); } return Result.getSuccess().setData(true); } Result<String> setAlias(String addr, String aliasName, String password); Result saveAlias(AliasPo aliaspo); Alias getAlias(String alias); boolean isAliasUsable(String alias); Result rollbackAlias(AliasPo aliasPo); Result<Na> getAliasFee(String address, String aliasName); Result<Na> getMultiAliasFee(String address, String aliasName); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password, List<String> pubKeys, int m, String txdata); Result<String> setMutilAlias(String addr, String signAddr, String aliasName, String password); Result signMultiAliasTransaction(String signAddr, String password, String txdata); boolean isMutilAliasUsable(byte[] address, String aliasName); Result<String> txMutilProcessing(Transaction tx, List<P2PHKSignature> p2PHKSignatures, List<Script> scripts, TransactionSignature transactionSignature, byte[] fromAddr); List<AliasPo> getAllAlias(); }
|
@Test public void saveAlias() { List<Account> accounts = accountService.createAccount(1, "nuls123456").getData(); Account account = accounts.get(0); Alias alias = new Alias(account.getAddress().getAddressBytes(), "lichao"); try { assertTrue(aliasService.saveAlias(new AliasPo(alias)).isSuccess()); } catch (NulsException e) { e.printStackTrace(); } }
|
CallContractData extends TransactionLogicData implements ContractData { public String[][] getArgs() { return args; } @Override int size(); @Override void parse(NulsByteBuffer byteBuffer); @Override byte[] getSender(); void setSender(byte[] sender); @Override byte[] getContractAddress(); void setContractAddress(byte[] contractAddress); @Override long getValue(); void setValue(long value); @Override long getGasLimit(); void setGasLimit(long gasLimit); @Override long getPrice(); void setPrice(long price); String getMethodName(); void setMethodName(String methodName); String getMethodDesc(); void setMethodDesc(String methodDesc); byte getArgsCount(); void setArgsCount(byte argsCount); String[][] getArgs(); void setArgs(String[][] args); @Override Set<byte[]> getAddresses(); }
|
@Test public void test1() { try { byte[] key = LedgerUtil.asBytes("aasdasdasdasda"); dbService.putModel(area, key, data); CallContractData dataConvert = dbService.getModel(area, key, CallContractData.class); System.out.println(dataConvert.toString()); String[][] strings = dataConvert.getArgs(); for(String[] bbb : strings) System.out.println(Arrays.toString(bbb)); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } }
|
BlockResource { @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); } @GET @Path("/header/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
@PathParam("height") Integer height); @GET @Path("/header/txHash/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHashesByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
@PathParam("height") Integer height); @GET @Path("/header/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeader(@ApiParam(name = "hash", value = "区块hash", required = true)
@PathParam("hash") String hash); @GET @Path("/header/txHash/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHash(@ApiParam(name = "hash", value = "区块hash", required = true)
@PathParam("hash") String hash); @GET @Path("/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块hash查询区块,包含区块打包的所有交易信息,此接口返回数据量较多,谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult loadBlock(@ApiParam(name = "hash", value = "区块hash", required = true)
@PathParam("hash") String hash); @GET @Path("/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块,包含区块打包的所有交易信息,此接口返回数据量较多,谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlock(@ApiParam(name = "height", value = "区块高度", required = true)
@PathParam("height") Long height); @GET @Path("/newest") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块头信息", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBestBlockHeader(); @GET @Path("/newest/height") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块高度") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHight(); @GET @Path("/newest/hash") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块的hash") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHash(); @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("hash") String hash); @GET @Path("/bytes/height") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("height") long height); @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块列表,包含区块打包的所有交易信息,此接口返回数据量较多,谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlockList(@QueryParam("startHeight") Long startHeight, @QueryParam("size") Long size); @GET() @Path("/info") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("查询最近五块区块的基本信息(用于开发调试)") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockInfoDto.class) }) RpcClientResult getBlockInfoList(); }
|
@Test public void getBlockBytes() { assertTrue(true); }
|
ECKey { public static ECKey signedMessageToKey(String message, String signatureBase64) throws SignatureException { byte[] signatureEncoded; try { signatureEncoded = Base64.decode(signatureBase64); } catch (RuntimeException e) { throw new SignatureException("Could not decode base64", e); } if (signatureEncoded.length < 65) throw new SignatureException("Signature truncated, expected 65 bytes and got " + signatureEncoded.length); int header = signatureEncoded[0] & 0xFF; if (header < 27 || header > 34) throw new SignatureException("Header byte out of range: " + header); BigInteger r = new BigInteger(1, Arrays.copyOfRange(signatureEncoded, 1, 33)); BigInteger s = new BigInteger(1, Arrays.copyOfRange(signatureEncoded, 33, 65)); ECDSASignature sig = new ECDSASignature(r, s); byte[] messageBytes = formatMessageForSigning(message); Sha256Hash messageHash = Sha256Hash.twiceOf(messageBytes); boolean compressed = false; if (header >= 31) { compressed = true; header -= 4; } int recId = header - 27; ECKey key = ECKey.recoverFromSignature(recId, sig, messageHash, compressed); if (key == null) throw new SignatureException("Could not recover public key from signature"); return key; } ECKey(); ECKey(SecureRandom secureRandom); private ECKey(BigInteger priv, ECPoint pub); static ECKey fromPrivate(BigInteger privKey); static ECKey fromPrivate(BigInteger privKey, boolean compressed); static ECKey fromPublicOnly(byte[] pubKey); static ECKey fromPublicOnly(ECPoint pub); static ECPoint publicPointFromPrivate(BigInteger privKey); static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, byte[] pubKey); byte[] getPubKey(); @JsonIgnore BigInteger getPrivKey(); @JsonIgnore byte[] getPrivKeyBytes(); @JsonIgnore String getPrivateKeyAsHex(); String getPublicKeyAsHex(); String getPublicKeyAsHex(boolean compressed); static boolean verify(byte[] data, ECDSASignature signature, byte[] pub); static boolean verify(byte[] data, byte[] signature, byte[] pub); boolean verify(byte[] hash, byte[] signature); byte[] sign(byte[] hash); byte[] sign(Sha256Hash hash, BigInteger aesKey); byte[] sign(byte[] hash, BigInteger aesKey); boolean hasPrivKey(); boolean isCompressed(); void setCreationTimeSeconds(long creationTimeSeconds); long getCreationTimeSeconds(); EncryptedData getEncryptedPrivateKey(); void setEncryptedPrivateKey(EncryptedData encryptedPrivateKey); static boolean isValidPrivteHex(String privateHex); static ECKey signedMessageToKey(String message, String signatureBase64); @Nullable static ECKey recoverFromSignature(int recId, ECDSASignature sig, Sha256Hash message, boolean compressed); String signMessage(String message, @Nullable KeyParameter aesKey); byte findRecoveryId(Sha256Hash hash, ECDSASignature sig); static final ECDomainParameters CURVE; static final BigInteger HALF_CURVE_ORDER; static final Comparator<ECKey> PUBKEY_COMPARATOR; }
|
@Test public void signedMessageToKeyTest() throws SignatureException { ECKey key = new ECKey(); System.out.println(key.getPrivateKeyAsHex()); System.out.println(key.getPublicKeyAsHex()); String message = "Nuls Signed Message:\nHello,I'am test case!@##$%998877"; String signatureBase64 = key.signMessage(message,null); System.out.println(signatureBase64); System.out.println(Base64.decode(signatureBase64).length); ECKey recoveryECKey = ECKey.signedMessageToKey(message, signatureBase64); Assert.assertEquals(recoveryECKey.getPublicKeyAsHex(),key.getPublicKeyAsHex()); }
|
VersionUtils { public static boolean higherThan(String version0, String version1) { if (StringUtils.isBlank(version0) || StringUtils.isBlank(version1)) { throw new RuntimeException("version is null"); } Integer[] intArr0 = strArrayToInt(version0); Integer[] intArr1 = strArrayToInt(version1); boolean result = false; for (int i = 0; i < intArr0.length; i++) { Integer val1 = intArr0[i]; if (intArr1.length <= i && val1 > 0) { result = true; break; } Integer val2 = intArr1[i]; if (val1 > val2) { result = true; break; } } if (!result && intArr1.length > intArr0.length) { result = intArr1[intArr0.length] > 0; } return result; } static boolean higherThan(String version0, String version1); static boolean equalsWith(String version0, String version1); static boolean lowerThan(String version0, String version1); }
|
@Test public void higherThan() { String v1 = "1.1.0"; String v2 = "1.1.0-beta"; String v3 = "1.1.1"; String v4 = "1.1.1-beta1"; String v5 = "1.1.1-beta2"; String v6 = "1.1.2-beta1"; String v7 = "1.2.0"; assertTrue(!VersionUtils.higherThan(v2, v1)); assertTrue(VersionUtils.higherThan(v3, v2)); assertTrue(VersionUtils.higherThan(v4, v3)); assertTrue(VersionUtils.higherThan(v5, v4)); assertTrue(VersionUtils.higherThan(v6, v5)); assertTrue(VersionUtils.higherThan(v7, v1)); assertTrue(VersionUtils.higherThan(v7, v2)); assertTrue(VersionUtils.higherThan(v7, v6)); assertTrue(VersionUtils.lowerThan(v2, v3)); assertTrue(VersionUtils.lowerThan(v3, v4)); assertTrue(VersionUtils.lowerThan(v4, v5)); assertTrue(VersionUtils.lowerThan(v5, v6)); assertTrue(VersionUtils.lowerThan(v1, v7)); assertTrue(VersionUtils.lowerThan(v2, v7)); assertTrue(VersionUtils.lowerThan(v6, v7)); assertTrue(!VersionUtils.lowerThan(v2, v1)); assertTrue(VersionUtils.equalsWith(v1, v2)); }
|
FileUtil { public static boolean deleteFolder(File folder) { if (!folder.exists()) { return true; } File[] files = folder.listFiles(); for (File file : files) { if (file.isFile()) { try { boolean b = file.delete(); if (!b) { Log.info("delete " + file.getName() + " result:" + b); mkNullToFile(file); } } catch (Exception e) { Log.error(e); } } else { deleteFolder(file); } } try { boolean b = folder.delete(); } catch (Exception e) { Log.error(e); } return true; } static File compress(File source, File target); static void decompress(String zipPath, String targetPath); static void copyFile(File source, File target); static void copyFolder(File source, File target); static void writeText(String text, String path); static boolean writeFile(byte[] bytes, String filePath); static boolean deleteFolder(File folder); static void deleteFolder(String path); }
|
@Test public void deleteFolder() { FileUtil.deleteFolder("C:\\Users\\Administrator\\Desktop\\release\\NULS-Wallet-0.9.10-windows-x64-for-test\\conf\\client-web"); }
|
UpgradeThread implements Runnable { private boolean download(String url, String filePath, String signature) throws IOException { if (!upgrading) { setFailedMessage("The upgrade has stopped"); return false; } byte[] bytes = HttpDownloadUtils.download(url); if (!verifySig(bytes, Hex.decode(signature))) { setFailedMessage("Signature verification is incorrect:" + url); return false; } boolean result = FileUtil.writeFile(bytes, filePath); if (!result) { setFailedMessage("Write file failed:" + filePath); } return result; } private UpgradeThread(); static UpgradeThread getInstance(); @Override void run(); boolean start(); boolean stop(); boolean isUpgrading(); UpgradeProcessDTO getProcess(); }
|
@Test public void download() { System.out.print("abcdefg"); System.out.print("\b"); System.out.print("\b"); System.out.print("\b"); }
|
PoConvertUtil { public static String getAgentId(NulsDigestData hash) { String hashHex = hash.getDigestHex(); return hashHex.substring(hashHex.length() - 8).toUpperCase(); } static Agent poToAgent(AgentPo agentPo); static AgentPo agentToPo(Agent agent); static Deposit poToDeposit(DepositPo po); static DepositPo depositToPo(Deposit deposit); static String getAgentId(NulsDigestData hash); }
|
@Test public void getAgentId() { NulsDigestData hash = NulsDigestData.calcDigestData("123123".getBytes()); System.out.println(PoConvertUtil.getAgentId(hash)); System.out.println(hash); assertTrue(true); }
|
ChainManager { public void newOrphanChain(Block block) { Chain orphanChain = new Chain(); orphanChain.initData(block); ChainContainer orphanChainContainer = new ChainContainer(orphanChain); orphanChains.add(orphanChainContainer); } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains(); }
|
@Test public void testNewOrphanChain() { assertNotNull(chainManager); Block block = createBlock(); chainManager.newOrphanChain(block); assertEquals(1, chainManager.getOrphanChains().size()); }
|
ChainManager { public long getBestBlockHeight() { if(masterChain == null || masterChain.getChain() == null || masterChain.getChain().getEndBlockHeader() == null) { return 0L; } return masterChain.getChain().getEndBlockHeader().getHeight(); } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains(); }
|
@Test public void testGetBestBlockHeight() { assertNotNull(chainManager); Block block = createBlock(); ChainContainer masterChain = new ChainContainer(new Chain()); chainManager.setMasterChain(masterChain); masterChain.getChain().addBlock(block); assertEquals(0L, chainManager.getBestBlockHeight()); }
|
ChainManager { public boolean checkIsBeforeOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); boolean success = false; for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getHash().equals(chain.getStartBlockHeader().getPreHash())) { success = true; chain.addPreBlock(block); } } return success; } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains(); }
|
@Test public void testCheckIsBeforeOrphanChainAndAdd() { testGetBestBlockHeight(); Block block = createBlock(); Block block1 = createBlock(); block1.getHeader().setHeight(1L); block1.getHeader().setPreHash(block.getHeader().getHash()); ChainContainer orphanChain = new ChainContainer(new Chain()); orphanChain.getChain().addBlock(block1); chainManager.getOrphanChains().add(orphanChain); assertEquals(1, chainManager.getOrphanChains().size()); boolean success = chainManager.checkIsBeforeOrphanChainAndAdd(block); assertTrue(success); }
|
ChainManager { public boolean checkIsAfterOrphanChainAndAdd(Block block) { BlockHeader header = block.getHeader(); for(ChainContainer chainContainer : orphanChains) { Chain chain = chainContainer.getChain(); if(header.getPreHash().equals(chain.getEndBlockHeader().getHash())) { chain.addBlock(block); return true; } } return false; } ChainManager(); void newOrphanChain(Block block); boolean checkIsBeforeOrphanChainAndAdd(Block block); boolean checkIsAfterOrphanChainAndAdd(Block block); long getBestBlockHeight(); void clear(); ChainContainer getMasterChain(); void setMasterChain(ChainContainer masterChain); List<ChainContainer> getChains(); Block getBestBlock(); List<ChainContainer> getOrphanChains(); }
|
@Test public void testCheckIsAfterOrphanChainAndAdd() { testGetBestBlockHeight(); Block block = createBlock(); Block block1 = createBlock(); block1.getHeader().setHeight(1L); block1.getHeader().setPreHash(block.getHeader().getHash()); ChainContainer orphanChain = new ChainContainer(new Chain()); orphanChain.getChain().addBlock(block); chainManager.getOrphanChains().add(orphanChain); assertEquals(1, chainManager.getOrphanChains().size()); boolean success = chainManager.checkIsAfterOrphanChainAndAdd(block1); assertTrue(success); }
|
RoundManager { public void addRound(MeetingRound meetingRound) { roundList.add(meetingRound); } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }
|
@Test public void testAddRound() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); assertEquals(0, roundManager.getRoundList().size()); MeetingRound round = new MeetingRound(); roundManager.addRound(round); assertEquals(1, roundManager.getRoundList().size()); assertEquals(round, roundManager.getCurrentRound()); MeetingRound round2 = new MeetingRound(); roundManager.addRound(round2); assertEquals(2, roundManager.getRoundList().size()); assertNotEquals(round, roundManager.getCurrentRound()); assertEquals(round2, roundManager.getCurrentRound()); }
|
Attribute implements Cloneable, Matchable<Attribute<?>> { public T get() { return value; } Attribute(AttributeDefinition<T> definition); String name(); T get(); T getInitialValue(); void validate(); Attribute<T> protect(); void set(T value); T computeIfAbsent(Supplier<T> supplier); boolean isImmutable(); boolean isPersistent(); boolean isModified(); K asObject(); void addListener(AttributeListener<T> listener); void removeListener(AttributeListener<T> listener); boolean isNull(); AttributeDefinition<T> getAttributeDefinition(); void read(Attribute<T> other); @Override int hashCode(); @Override boolean equals(Object obj); boolean matches(Attribute<?> other); @Override String toString(); void reset(); }
|
@Test public void testAttributeInitializer() { AttributeDefinition<Properties> def = AttributeDefinition.builder("props", null, Properties.class).initializer(new AttributeInitializer<Properties>() { @Override public Properties initialize() { return new Properties(); } }).build(); Attribute<Properties> attribute1 = def.toAttribute(); Attribute<Properties> attribute2 = def.toAttribute(); assertTrue(attribute1.get() != attribute2.get()); }
|
StandardConversions { public static byte[] convertJavaToOctetStream(Object source, MediaType sourceMediaType, Marshaller marshaller) throws IOException, InterruptedException { if (source == null) return null; if (!sourceMediaType.match(MediaType.APPLICATION_OBJECT)) { throw new EncodingException("sourceMediaType not conforming to application/x-java-object!"); } Object decoded = decodeObjectContent(source, sourceMediaType); if (decoded instanceof byte[]) return (byte[]) decoded; if (decoded instanceof String && isJavaString(sourceMediaType)) return ((String) decoded).getBytes(StandardCharsets.UTF_8); return marshaller.objectToByteBuffer(source); } static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType); static byte[] convertTextToOctetStream(Object source, MediaType sourceType); static String convertTextToObject(Object source, MediaType sourceType); static String convertTextToUrlEncoded(Object source, MediaType sourceType); static byte[] convertOctetStreamToText(byte[] source, MediaType destination); static Object convertOctetStreamToJava(byte[] source, MediaType destination, Marshaller marshaller); static byte[] convertJavaToOctetStream(Object source, MediaType sourceMediaType, Marshaller marshaller); static byte[] convertJavaToProtoStream(Object source, MediaType sourceMediaType, ImmutableSerializationContext ctx); static byte[] convertJavaToText(Object source, MediaType sourceMediaType, MediaType destinationMediaType); static Object decodeObjectContent(Object content, MediaType contentMediaType); static byte[] convertCharset(Object content, Charset fromCharset, Charset toCharset); static byte[] decodeOctetStream(Object input, MediaType octetStream); static String bytesToHex(byte[] bytes); static byte[] hexToBytes(String hex); static Object convertUrlEncodedToObject(Object content); static Object convertUrlEncodedToText(Object content, MediaType destinationType); static Object convertUrlEncodedToOctetStream(Object content); static String urlEncode(Object content, MediaType mediaType); static Object urlDecode(Object content); static Object convertOctetStreamToUrlEncoded(Object content, MediaType contentType); }
|
@Test public void testJavaToOctetStreamConversion() throws IOException, InterruptedException { Marshaller marshaller = new ProtoStreamMarshaller(); String string = "I've seen things you people wouldn't believe."; Double number = 12.1d; Instant complex = Instant.now(); byte[] binary = new byte[]{1, 2, 3}; MediaType stringType = APPLICATION_OBJECT.withParameter("type", "java.lang.String"); byte[] result = StandardConversions.convertJavaToOctetStream(string, stringType, marshaller); assertArrayEquals(string.getBytes(UTF_8), result); MediaType doubleType = APPLICATION_OBJECT.withParameter("type", "java.lang.Double"); result = StandardConversions.convertJavaToOctetStream(number, doubleType, marshaller); assertArrayEquals(marshaller.objectToByteBuffer(number), result); MediaType customType = APPLICATION_OBJECT.withParameter("type", complex.getClass().getName()); result = StandardConversions.convertJavaToOctetStream(complex, customType, marshaller); assertArrayEquals(marshaller.objectToByteBuffer(complex), result); MediaType byteArrayType = APPLICATION_OBJECT.withParameter("type", "ByteArray"); result = StandardConversions.convertJavaToOctetStream(binary, byteArrayType, marshaller); assertArrayEquals(result, binary); }
|
KeyTransformationHandler { public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass); }
|
@Test(expectedExceptions = CacheException.class) public void testStringToUnknownKey() { keyTransformationHandler.stringToKey("Z:someKey"); }
@Test(expectedExceptions = CacheException.class) public void testStringToKeyWithInvalidTransformer() { keyTransformationHandler.stringToKey("T:org.infinispan.InexistentTransformer:key1"); }
|
KeyTransformationHandler { public String keyToString(Object key) { if (key instanceof byte[]) return "A:" + Base64.getEncoder().encodeToString((byte[]) key); if (key instanceof String) return "S:" + key; else if (key instanceof Integer) return "I:" + key; else if (key instanceof Boolean) return "B:" + key; else if (key instanceof Long) return "L:" + key; else if (key instanceof Float) return "F:" + key; else if (key instanceof Double) return "D:" + key; else if (key instanceof Short) return "X:" + key; else if (key instanceof Byte) return "Y:" + key; else if (key instanceof Character) return "C:" + key; else if (key instanceof UUID) return "U:" + key; else { Transformer t = getTransformer(key.getClass()); if (t != null) { return "T:" + key.getClass().getName() + ":" + t.toString(key); } else { throw CONTAINER.noTransformerForKey(key.getClass().getName()); } } } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass); }
|
@Test(expectedExceptions = IllegalArgumentException.class) public void testKeyToStringWithDefaultTransformerForNonSerializableObject() { NonSerializableKey key = new NonSerializableKey("test"); keyTransformationHandler.keyToString(key); }
|
HibernateSearchPropertyHelper extends ReflectionPropertyHelper { @Override public Object convertToPropertyType(Class<?> entityType, String[] propertyPath, String value) { IndexValueFieldDescriptor fieldDescriptor = getValueFieldDescriptor(entityType, propertyPath); if (fieldDescriptor == null) { return super.convertToPropertyType(entityType, propertyPath, value); } Class<?> type = fieldDescriptor.type().dslArgumentClass(); if (!(Date.class.equals(type))) { return super.convertToPropertyType(entityType, propertyPath, value); } try { return DateTools.stringToDate(value); } catch (ParseException e) { throw new ParsingException(e); } } HibernateSearchPropertyHelper(SearchMapping searchMapping, EntityNameResolver<Class<?>> entityNameResolver); @Override Object convertToPropertyType(Class<?> entityType, String[] propertyPath, String value); @Override Class<?> getPrimitivePropertyType(Class<?> entityType, String[] propertyPath); @Override boolean isRepeatedProperty(Class<?> entityType, String[] propertyPath); @Override boolean hasEmbeddedProperty(Class<?> entityType, String[] propertyPath); @Override boolean hasProperty(Class<?> entityType, String[] propertyPath); @Override IndexedFieldProvider<Class<?>> getIndexedFieldProvider(); static String KEY; static String VALUE; }
|
@Test public void testConvertIdProperty() { assertThat(convertToPropertyType(TestEntity.class, "id", "42")).isEqualTo("42"); }
@Test public void testConvertStringProperty() { assertThat(convertToPropertyType(TestEntity.class, "name", "42")).isEqualTo("42"); }
@Test public void testConvertIntProperty() { assertThat(convertToPropertyType(TestEntity.class, "i", "42")).isEqualTo(42); }
@Test public void testConvertLongProperty() { assertThat(convertToPropertyType(TestEntity.class, "l", "42")).isEqualTo(42L); }
@Test public void testConvertFloatProperty() { assertThat(convertToPropertyType(TestEntity.class, "f", "42.0")).isEqualTo(42.0F); }
@Test public void testConvertDoubleProperty() { assertThat(convertToPropertyType(TestEntity.class, "d", "42.0")).isEqualTo(42.0D); }
|
EmptyIntSet extends AbstractImmutableIntSet { @Override public boolean containsAll(IntSet set) { return set.isEmpty(); } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterator.OfInt iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean containsAll(Collection<?> c); @Override IntStream intStream(); @Override boolean equals(Object obj); @Override String toString(); }
|
@Test public void testContainsAll1() throws Exception { Set<Integer> hashSet = new HashSet<>(); hashSet.add(3); assertFalse(es.containsAll(hashSet)); assertTrue(hashSet.containsAll(es)); hashSet.remove(3); assertTrue(hashSet.containsAll(es)); assertTrue(es.containsAll(hashSet)); }
@Test public void testContainsAll() throws Exception { IntSet sis2 = new SingletonIntSet(3); assertFalse(es.containsAll(sis2)); assertTrue(sis2.containsAll(es)); IntSet sis3 = new RangeSet(0); assertTrue(sis3.containsAll(es)); assertTrue(es.containsAll(sis3)); }
|
HibernateSearchPropertyHelper extends ReflectionPropertyHelper { @Override public IndexedFieldProvider<Class<?>> getIndexedFieldProvider() { return entityType -> { IndexDescriptor indexDescriptor = getIndexDescriptor(entityType); if (indexDescriptor == null) { return IndexedFieldProvider.NO_INDEXING; } return new SearchFieldIndexingMetadata(indexDescriptor); }; } HibernateSearchPropertyHelper(SearchMapping searchMapping, EntityNameResolver<Class<?>> entityNameResolver); @Override Object convertToPropertyType(Class<?> entityType, String[] propertyPath, String value); @Override Class<?> getPrimitivePropertyType(Class<?> entityType, String[] propertyPath); @Override boolean isRepeatedProperty(Class<?> entityType, String[] propertyPath); @Override boolean hasEmbeddedProperty(Class<?> entityType, String[] propertyPath); @Override boolean hasProperty(Class<?> entityType, String[] propertyPath); @Override IndexedFieldProvider<Class<?>> getIndexedFieldProvider(); static String KEY; static String VALUE; }
|
@Test public void testRecognizeAnalyzedField() { assertThat(propertyHelper.getIndexedFieldProvider().get(TestEntity.class).isAnalyzed(new String[]{"description"})).isTrue(); }
@Test public void testRecognizeStoredField() { assertThat(propertyHelper.getIndexedFieldProvider().get(TestEntity.class).isStored(new String[]{"description"})).isTrue(); }
@Test public void testRecognizeUnanalyzedField() { assertThat(propertyHelper.getIndexedFieldProvider().get(TestEntity.class).isAnalyzed(new String[]{"i"})).isFalse(); }
|
ReflectionHelper { public static PropertyAccessor getAccessor(Class<?> clazz, String propertyName) throws ReflectiveOperationException { if (propertyName == null || propertyName.length() == 0) { throw new IllegalArgumentException("Property name cannot be null or empty"); } if (propertyName.indexOf('.') != -1) { throw new IllegalArgumentException("The argument cannot be a nested property name"); } String propertyNameSuffix = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); Class<?> c = clazz; while (c != null) { PropertyAccessor m = getAccessor(c, propertyName, propertyNameSuffix); if (m != null) { return m; } c = c.getSuperclass(); } throw new ReflectiveOperationException("Property not found: " + propertyName); } private ReflectionHelper(); static PropertyAccessor getAccessor(Class<?> clazz, String propertyName); }
|
@Test public void testGetSimpleProperty() throws Exception { assertEquals(int.class, ReflectionHelper.getAccessor(Base.class, "prop1").getPropertyType()); assertEquals(float.class, ReflectionHelper.getAccessor(Base.class, "prop2").getPropertyType()); }
@Test public void testPropertyNotFound() throws Exception { expectedException.expect(ReflectiveOperationException.class); expectedException.expectMessage("Property not found: unknown"); ReflectionHelper.getAccessor(Base.class, "unknown"); }
@Test public void testGetNestedProperty() throws Exception { ReflectionHelper.PropertyAccessor prop3 = ReflectionHelper.getAccessor(Base.class, "prop3"); assertEquals(Base.class, prop3.getPropertyType()); assertEquals(int.class, prop3.getAccessor("prop1").getPropertyType()); }
@Test public void testGetMultipleProperty() throws Exception { assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "array").getPropertyType()); assertEquals(Float.class, ReflectionHelper.getAccessor(A.class, "array2").getPropertyType()); assertEquals(float.class, ReflectionHelper.getAccessor(A.class, "array3").getPropertyType()); assertEquals(Collection.class, ReflectionHelper.getAccessor(A.class, "array4").getPropertyType()); assertEquals(Integer.class, ReflectionHelper.getAccessor(A.class, "list").getPropertyType()); assertEquals(List.class, ReflectionHelper.getAccessor(A.class, "list2").getPropertyType()); assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "list3").getPropertyType()); assertEquals(Integer.class, ReflectionHelper.getAccessor(A.class, "map").getPropertyType()); assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "map2").getPropertyType()); assertEquals(Long.class, ReflectionHelper.getAccessor(A.class, "y").getPropertyType()); assertEquals(Long.class, ReflectionHelper.getAccessor(A.class, "z").getPropertyType()); assertEquals(Double.class, ReflectionHelper.getAccessor(A.class, "q").getPropertyType()); assertEquals(Double.class, ReflectionHelper.getAccessor(A.class, "w").getPropertyType()); }
|
Interval { public boolean contains(K value) { return (includeLower ? low.compareTo(value) <= 0 : low.compareTo(value) < 0) && (includeUpper ? up.compareTo(value) >= 0 : up.compareTo(value) > 0); } Interval(K low, boolean includeLower, K up, boolean includeUpper); static K getMinusInf(); static K getPlusInf(); boolean contains(K value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final K low; final boolean includeLower; final K up; final boolean includeUpper; }
|
@Test public void testContains() { assertTrue(new Interval(Interval.<Integer>getMinusInf(), false, 1000, false).contains(20)); assertFalse(new Interval(Interval.<Integer>getMinusInf(), false, 1000, false).contains(1000)); assertFalse(new Interval(Interval.<Integer>getMinusInf(), false, 1000, false).contains(1001)); assertTrue(new Interval(1000, false, Interval.<Integer>getPlusInf(), false).contains(2000)); assertFalse(new Interval(1000, false, Interval.<Integer>getPlusInf(), false).contains(1000)); assertFalse(new Interval(1000, false, Interval.<Integer>getPlusInf(), false).contains(999)); }
|
DoubleStat { Double getSum() { if (count == 0) { return null; } double tmp = sum + sumCompensation; if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) { return simpleSum; } else { return tmp; } } }
|
@Test public void testEmptySum() { DoubleStat sum = new DoubleStat(); assertNull(sum.getSum()); }
|
DoubleStat { Double getAvg() { return count == 0 ? null : getSum() / count; } }
|
@Test public void testEmptyAvg() { DoubleStat avg = new DoubleStat(); assertNull(avg.getAvg()); }
|
EmptyIntSet extends AbstractImmutableIntSet { @Override public IntStream intStream() { return IntStream.empty(); } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterator.OfInt iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean containsAll(Collection<?> c); @Override IntStream intStream(); @Override boolean equals(Object obj); @Override String toString(); }
|
@Test public void testIntStream() throws Exception { assertEquals(0, es.intStream().count()); }
|
LikeCondition implements Condition<String> { @Override public boolean match(String attributeValue) { if (attributeValue == null) { return false; } switch (type) { case Equals: return attributeValue.equals(value); case StartsWith: return (length == -1 || length == attributeValue.length()) && attributeValue.startsWith(value); case EndsWith: return (length == -1 || length == attributeValue.length()) && attributeValue.endsWith(value); case Contains: return attributeValue.contains(value); case Regexp: return regexPattern.matcher(attributeValue).matches(); default: throw new IllegalStateException("Unexpected type " + type); } } LikeCondition(String likePattern); LikeCondition(String likePattern, char escapeCharacter); @Override boolean match(String attributeValue); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
|
@Test public void testDegeneratedEquals() { LikeCondition likeCondition = new LikeCondition("ab"); assertTrue(likeCondition.match("ab")); assertFalse(likeCondition.match("ac")); assertFalse(likeCondition.match("XabY")); }
@Test public void testDegeneratedContains() { LikeCondition likeCondition = new LikeCondition("%ab%"); assertTrue(likeCondition.match("ab")); assertTrue(likeCondition.match("xabxx")); assertFalse(likeCondition.match("axb")); }
@Test public void testDegeneratedStartsWith() { assertTrue(new LikeCondition("ab%").match("ab")); assertTrue(new LikeCondition("ab%").match("abx")); assertTrue(new LikeCondition("ab%").match("abxx")); assertFalse(new LikeCondition("ab%").match("xab")); assertFalse(new LikeCondition("ab%").match("axb")); assertTrue(new LikeCondition("ab_").match("abc")); assertFalse(new LikeCondition("ab_").match("ab")); assertFalse(new LikeCondition("ab_").match("abxx")); assertFalse(new LikeCondition("ab_").match("xab")); assertFalse(new LikeCondition("ab_").match("xaby")); }
@Test public void testDegeneratedEndsWith() { assertTrue(new LikeCondition("%ab").match("ab")); assertTrue(new LikeCondition("%ab").match("xab")); assertTrue(new LikeCondition("%ab").match("xxab")); assertFalse(new LikeCondition("%ab").match("abx")); assertFalse(new LikeCondition("%ab").match("axb")); assertTrue(new LikeCondition("_ab").match("cab")); assertFalse(new LikeCondition("_ab").match("ab")); assertFalse(new LikeCondition("_ab").match("xxab")); assertFalse(new LikeCondition("_ab").match("abc")); assertFalse(new LikeCondition("_ab").match("xabc")); }
@Test public void testSingleCharWildcard() { LikeCondition likeCondition = new LikeCondition("a_b_c"); assertTrue(likeCondition.match("aXbYc")); assertTrue(likeCondition.match("a_b_c")); assertTrue(likeCondition.match("a%b%c")); assertFalse(likeCondition.match("abc")); assertFalse(likeCondition.match("aXXbYYc")); }
@Test public void testMultipleCharWildcard() { LikeCondition likeCondition = new LikeCondition("a%b%c"); assertTrue(likeCondition.match("abc")); assertTrue(likeCondition.match("aXbc")); assertTrue(likeCondition.match("aXYbZc")); assertTrue(likeCondition.match("a_b_c")); assertTrue(likeCondition.match("a%b%c")); assertFalse(likeCondition.match("a")); assertFalse(likeCondition.match("aX")); assertFalse(likeCondition.match("a%")); }
@Test public void testEscapeChar() { assertTrue(new LikeCondition("a\\%b").match("a%b")); assertFalse(new LikeCondition("a\\%b").match("aXb")); assertFalse(new LikeCondition("a\\%b").match("ab")); assertTrue(new LikeCondition("a\\\\b").match("a\\b")); assertTrue(new LikeCondition("a~%b", '~').match("a%b")); assertFalse(new LikeCondition("a~%b", '~').match("aXb")); assertFalse(new LikeCondition("a~%b", '~').match("ab")); assertTrue(new LikeCondition("a~~b", '~').match("a~b")); }
@Test public void testPlusEscaping() { LikeCondition likeCondition = new LikeCondition("a%aZ+"); assertTrue(likeCondition.match("aaaZ+")); assertFalse(likeCondition.match("aaa")); assertFalse(likeCondition.match("aaaZ")); assertFalse(likeCondition.match("aaaZZ")); assertFalse(likeCondition.match("aaaZZZ")); }
@Test public void testAsteriskEscaping() { LikeCondition likeCondition = new LikeCondition("a%aZ*"); assertTrue(likeCondition.match("aaaZ*")); assertFalse(likeCondition.match("aaa")); assertFalse(likeCondition.match("aaaZ")); assertFalse(likeCondition.match("aaaZZ")); assertFalse(likeCondition.match("aaaZZZ")); }
@Test public void testGeneralMetacharEscaping() { assertTrue(new LikeCondition("a%(b").match("aaa(b")); assertTrue(new LikeCondition("a%)b").match("aaa)b")); assertTrue(new LikeCondition("a%[b").match("aaa[b")); assertTrue(new LikeCondition("a%]b").match("aaa]b")); assertTrue(new LikeCondition("a%{b").match("aaa{b")); assertTrue(new LikeCondition("a%}b").match("aaa}b")); assertTrue(new LikeCondition("a%$b").match("aaa$b")); assertTrue(new LikeCondition("a%^b").match("aaa^b")); assertTrue(new LikeCondition("a%.b").match("aaa.b")); assertTrue(new LikeCondition("a%|b").match("aaa|b")); assertTrue(new LikeCondition("a%\\b").match("aaa\\b")); }
|
EmptyIntSet extends AbstractImmutableIntSet { @Override public boolean equals(Object obj) { if (obj instanceof Set) { return ((Set) obj).size() == 0; } return false; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterator.OfInt iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean containsAll(Collection<?> c); @Override IntStream intStream(); @Override boolean equals(Object obj); @Override String toString(); }
|
@Test public void testEquals() throws Exception { IntSet sis2 = new SingletonIntSet(4); assertNotEquals(es, sis2); assertNotEquals(sis2, es); IntSet sis3 = new SmallIntSet(2); assertEquals(sis3, es); assertEquals(es, sis3); }
|
Configuration { public int maxRetries() { return maxRetries; } Configuration(ExecutorFactoryConfiguration asyncExecutorFactory, Supplier<FailoverRequestBalancingStrategy> balancingStrategyFactory, ClassLoader classLoader,
ClientIntelligence clientIntelligence, ConnectionPoolConfiguration connectionPool, int connectionTimeout, Class<? extends ConsistentHash>[] consistentHashImpl, boolean forceReturnValues, int keySizeEstimate,
Marshaller marshaller, Class<? extends Marshaller> marshallerClass,
ProtocolVersion protocolVersion, List<ServerConfiguration> servers, int socketTimeout, SecurityConfiguration security, boolean tcpNoDelay, boolean tcpKeepAlive,
int valueSizeEstimate, int maxRetries, NearCacheConfiguration nearCache,
List<ClusterConfiguration> clusters, List<String> serialAllowList, int batchSize,
TransactionConfiguration transaction, StatisticsConfiguration statistics, Features features,
List<SerializationContextInitializer> contextInitializers,
Map<String, RemoteCacheConfiguration> remoteCaches); ExecutorFactoryConfiguration asyncExecutorFactory(); Supplier<FailoverRequestBalancingStrategy> balancingStrategyFactory(); @Deprecated ClassLoader classLoader(); ClientIntelligence clientIntelligence(); ConnectionPoolConfiguration connectionPool(); int connectionTimeout(); Class<? extends ConsistentHash>[] consistentHashImpl(); Class<? extends ConsistentHash> consistentHashImpl(int version); boolean forceReturnValues(); @Deprecated int keySizeEstimate(); Marshaller marshaller(); Class<? extends Marshaller> marshallerClass(); @Deprecated NearCacheConfiguration nearCache(); ProtocolVersion version(); List<ServerConfiguration> servers(); List<ClusterConfiguration> clusters(); int socketTimeout(); SecurityConfiguration security(); boolean tcpNoDelay(); boolean tcpKeepAlive(); @Deprecated int valueSizeEstimate(); int maxRetries(); @Deprecated List<String> serialWhitelist(); List<String> serialAllowList(); @Deprecated ClassAllowList getClassWhiteList(); ClassAllowList getClassAllowList(); int batchSize(); Map<String, RemoteCacheConfiguration> remoteCaches(); RemoteCacheConfiguration addRemoteCache(String name, Consumer<RemoteCacheConfigurationBuilder> builderConsumer); void removeRemoteCache(String name); StatisticsConfiguration statistics(); TransactionConfiguration transaction(); Features features(); List<SerializationContextInitializer> getContextInitializers(); @Override String toString(); Properties properties(); }
|
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN(\\d)*: Invalid max_retries \\(value=-1\\). " + "Value should be greater or equal than zero.") public void testNegativeRetriesPerServer() { ConfigurationBuilder builder = HotRodClientTestingUtil.newRemoteConfigurationBuilder(); builder.maxRetries(-1); builder.build(); }
|
Configuration { public SecurityConfiguration security() { return security; } Configuration(ExecutorFactoryConfiguration asyncExecutorFactory, Supplier<FailoverRequestBalancingStrategy> balancingStrategyFactory, ClassLoader classLoader,
ClientIntelligence clientIntelligence, ConnectionPoolConfiguration connectionPool, int connectionTimeout, Class<? extends ConsistentHash>[] consistentHashImpl, boolean forceReturnValues, int keySizeEstimate,
Marshaller marshaller, Class<? extends Marshaller> marshallerClass,
ProtocolVersion protocolVersion, List<ServerConfiguration> servers, int socketTimeout, SecurityConfiguration security, boolean tcpNoDelay, boolean tcpKeepAlive,
int valueSizeEstimate, int maxRetries, NearCacheConfiguration nearCache,
List<ClusterConfiguration> clusters, List<String> serialAllowList, int batchSize,
TransactionConfiguration transaction, StatisticsConfiguration statistics, Features features,
List<SerializationContextInitializer> contextInitializers,
Map<String, RemoteCacheConfiguration> remoteCaches); ExecutorFactoryConfiguration asyncExecutorFactory(); Supplier<FailoverRequestBalancingStrategy> balancingStrategyFactory(); @Deprecated ClassLoader classLoader(); ClientIntelligence clientIntelligence(); ConnectionPoolConfiguration connectionPool(); int connectionTimeout(); Class<? extends ConsistentHash>[] consistentHashImpl(); Class<? extends ConsistentHash> consistentHashImpl(int version); boolean forceReturnValues(); @Deprecated int keySizeEstimate(); Marshaller marshaller(); Class<? extends Marshaller> marshallerClass(); @Deprecated NearCacheConfiguration nearCache(); ProtocolVersion version(); List<ServerConfiguration> servers(); List<ClusterConfiguration> clusters(); int socketTimeout(); SecurityConfiguration security(); boolean tcpNoDelay(); boolean tcpKeepAlive(); @Deprecated int valueSizeEstimate(); int maxRetries(); @Deprecated List<String> serialWhitelist(); List<String> serialAllowList(); @Deprecated ClassAllowList getClassWhiteList(); ClassAllowList getClassAllowList(); int batchSize(); Map<String, RemoteCacheConfiguration> remoteCaches(); RemoteCacheConfiguration addRemoteCache(String name, Consumer<RemoteCacheConfigurationBuilder> builderConsumer); void removeRemoteCache(String name); StatisticsConfiguration statistics(); TransactionConfiguration transaction(); Features features(); List<SerializationContextInitializer> getContextInitializers(); @Override String toString(); Properties properties(); }
|
@Test(expectedExceptions = CacheConfigurationException.class) public void testInvalidAuthenticationConfig() { ConfigurationBuilder builder = HotRodClientTestingUtil.newRemoteConfigurationBuilder(); builder.security().authentication().enable().saslMechanism("PLAIN"); builder.build(); }
|
RocksDBStore implements NonBlockingStore<K, V> { @Override public CompletionStage<Void> write(int segment, MarshallableEntry<? extends K, ? extends V> entry) { return handler.write(segment, entry); } @Override CompletionStage<Void> start(InitializationContext ctx); @Override CompletionStage<Void> stop(); @Override Set<Characteristic> characteristics(); @Override CompletionStage<Boolean> isAvailable(); @Override CompletionStage<Void> clear(); @Override CompletionStage<Long> size(IntSet segments); @Override CompletionStage<Long> approximateSize(IntSet segments); @Override CompletionStage<Boolean> containsKey(int segment, Object key); @Override Publisher<K> publishKeys(IntSet segments, Predicate<? super K> filter); @Override Publisher<MarshallableEntry<K, V>> publishEntries(IntSet segments, Predicate<? super K> filter, boolean includeValues); @Override CompletionStage<Boolean> delete(int segment, Object key); @Override CompletionStage<Void> write(int segment, MarshallableEntry<? extends K, ? extends V> entry); @Override CompletionStage<MarshallableEntry<K, V>> load(int segment, Object key); @Override CompletionStage<Void> batch(int publisherCount, Publisher<SegmentedPublisher<Object>> removePublisher,
Publisher<SegmentedPublisher<MarshallableEntry<K, V>>> writePublisher); @Override Publisher<MarshallableEntry<K, V>> purgeExpired(); @Override CompletionStage<Void> addSegments(IntSet segments); @Override CompletionStage<Void> removeSegments(IntSet segments); }
|
@Test(groups = "stress") public void testConcurrentWrite() throws InterruptedException { final int THREADS = 8; final AtomicBoolean run = new AtomicBoolean(true); final AtomicInteger written = new AtomicInteger(); final CountDownLatch started = new CountDownLatch(THREADS); final CountDownLatch finished = new CountDownLatch(THREADS); for (int i = 0; i < THREADS; ++i) { final int thread = i; fork(() -> { try { started.countDown(); int i1 = 0; while (run.get()) { InternalCacheEntry entry = TestInternalCacheEntryFactory.create("k" + i1, "v" + i1); MarshallableEntry me = MarshalledEntryUtil.create(entry, getMarshaller()); try { store.write(me); ++i1; int prev; do { prev = written.get(); if ((prev & (1 << thread)) != 0) break; } while (written.compareAndSet(prev, prev | (1 << thread))); } catch (PersistenceException e) { } } } catch (Exception e) { log.error("Failed", e); throw new RuntimeException(e); } finally { finished.countDown(); } }); } if (finished.await(1, TimeUnit.SECONDS)) { fail("Test shouldn't have finished yet"); } run.set(false); if (!finished.await(30, TimeUnit.SECONDS)) { fail("Test should have finished!"); } assertEquals(written.get(), (1 << THREADS) - 1, "pre"); }
|
L1ConfigurationBuilder extends AbstractClusteringConfigurationChildBuilder implements Builder<L1Configuration>, ConfigurationBuilderInfo { public L1ConfigurationBuilder enable() { attributes.attribute(ENABLED).set(true); return this; } L1ConfigurationBuilder(ClusteringConfigurationBuilder builder); @Override ElementDefinition getElementDefinition(); @Override AttributeSet attributes(); L1ConfigurationBuilder invalidationThreshold(int invalidationThreshold); L1ConfigurationBuilder lifespan(long lifespan); L1ConfigurationBuilder lifespan(long lifespan, TimeUnit unit); L1ConfigurationBuilder cleanupTaskFrequency(long frequencyMillis); L1ConfigurationBuilder cleanupTaskFrequency(long frequencyMillis, TimeUnit unit); L1ConfigurationBuilder enable(); L1ConfigurationBuilder disable(); L1ConfigurationBuilder enabled(boolean enabled); @Override void validate(); @Override void validate(GlobalConfiguration globalConfig); @Override L1Configuration create(); @Override L1ConfigurationBuilder read(L1Configuration template); @Override String toString(); }
|
@Test(expectedExceptions = CacheConfigurationException.class) public void testL1WithExceptionEviction() { Configuration config = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.DIST_SYNC) .l1().enable() .memory() .evictionStrategy(EvictionStrategy.EXCEPTION) .size(10) .transaction() .transactionMode(org.infinispan.transaction.TransactionMode.TRANSACTIONAL) .build(); assertNotNull(config); }
|
DependencyGraph { public List<T> topologicalSort() throws CyclicDependencyException { lock.readLock().lock(); try { ArrayList<T> result = new ArrayList<>(); Deque<T> noIncomingEdges = new ArrayDeque<>(); Map<T, Integer> temp = new HashMap<>(); for (Map.Entry<T, Set<T>> incoming : incomingEdges.entrySet()) { int size = incoming.getValue().size(); T key = incoming.getKey(); temp.put(key, size); if (size == 0) { noIncomingEdges.add(key); } } while (!noIncomingEdges.isEmpty()) { T n = noIncomingEdges.poll(); result.add(n); temp.remove(n); Set<T> elements = outgoingEdges.get(n); if (elements != null) { for (T m : elements) { Integer count = temp.get(m); temp.put(m, --count); if (count == 0) { noIncomingEdges.add(m); } } } } if (!temp.isEmpty()) { throw new CyclicDependencyException("Cycle detected"); } else { return result; } } finally { lock.readLock().unlock(); } } List<T> topologicalSort(); void addDependency(T from, T to); void removeDependency(T from, T to); void clearAll(); boolean hasDependent(T element); Set<T> getDependents(T element); void remove(T element); }
|
@Test public void testEmpty() throws CyclicDependencyException { assertTrue(new DependencyGraph().topologicalSort().isEmpty()); }
@Test public void testConcurrentAccess() throws Exception { DependencyGraph<String> graph = new DependencyGraph<>(); ExecutorService service = Executors.newCachedThreadPool(getTestThreadFactory("Worker")); try { CountDownLatch startLatch = new CountDownLatch(1); int threads = 20; ArrayList<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < threads; i++) { futures.add(submitTask("A", "B", startLatch, service, graph)); futures.add(submitTask("A", "C", startLatch, service, graph)); futures.add(submitTask("A", "D", startLatch, service, graph)); futures.add(submitTask("A", "B", startLatch, service, graph)); futures.add(submitTask("D", "B", startLatch, service, graph)); futures.add(submitTask("D", "C", startLatch, service, graph)); futures.add(submitTask("C", "B", startLatch, service, graph)); } startLatch.countDown(); awaitAll(futures); } finally { service.shutdownNow(); } assertEquals(graph.topologicalSort(), Arrays.asList("A", "D", "C", "B")); }
|
DependencyGraph { public void removeDependency(T from, T to) { lock.writeLock().lock(); try { Set<T> dependencies = outgoingEdges.get(from); if (dependencies == null || !dependencies.contains(to)) { throw new IllegalArgumentException("Inexistent dependency"); } dependencies.remove(to); incomingEdges.get(to).remove(from); } finally { lock.writeLock().unlock(); } } List<T> topologicalSort(); void addDependency(T from, T to); void removeDependency(T from, T to); void clearAll(); boolean hasDependent(T element); Set<T> getDependents(T element); void remove(T element); }
|
@Test public void testRemoveDependency() throws CyclicDependencyException { DependencyGraph<String> g = new DependencyGraph<>(); g.addDependency("E", "B"); g.addDependency("E", "C"); g.addDependency("E", "D"); g.addDependency("B", "D"); g.addDependency("B", "C"); g.addDependency("C", "D"); assertEquals(g.topologicalSort(), Arrays.asList("E", "B", "C", "D")); g.removeDependency("E", "B"); g.addDependency("B", "E"); assertEquals(g.topologicalSort(), Arrays.asList("B", "E", "C", "D")); g.clearAll(); assertTrue(g.topologicalSort().isEmpty()); }
|
DependencyGraph { public void addDependency(T from, T to) { if (from == null || to == null || from.equals(to)) { throw new IllegalArgumentException("Invalid parameters"); } lock.writeLock().lock(); try { if (addOutgoingEdge(from, to)) { addIncomingEdge(to, from); } } finally { lock.writeLock().unlock(); } } List<T> topologicalSort(); void addDependency(T from, T to); void removeDependency(T from, T to); void clearAll(); boolean hasDependent(T element); Set<T> getDependents(T element); void remove(T element); }
|
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddSelf() { new DependencyGraph<>().addDependency("N", "N"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAdNull() { new DependencyGraph<>().addDependency("N", null); }
|
GridFile extends File { @Override public boolean createNewFile() throws IOException { if (exists()) return false; if (!checkParentDirs(getAbsolutePath(), false)) throw new IOException("Cannot create file " + getAbsolutePath() + " (parent dir does not exist)"); metadataCache.put(getAbsolutePath(), new Metadata(0, System.currentTimeMillis(), chunkSize, Metadata.FILE)); return true; } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(File parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); @Override String getName(); @Override String getPath(); @Override String getAbsolutePath(); @Override File getAbsoluteFile(); @Override String getCanonicalPath(); @Override File getCanonicalFile(); @Override boolean isAbsolute(); @Override boolean renameTo(File dest); @Override void deleteOnExit(); @Override long length(); int getChunkSize(); @Override boolean createNewFile(); @Override boolean delete(); @Override boolean mkdir(); @Override boolean mkdirs(); @Override boolean exists(); @Override String getParent(); @Override File getParentFile(); @Override long lastModified(); @Override boolean setLastModified(long time); @Override String[] list(); @Override String[] list(FilenameFilter filter); @Override File[] listFiles(); @Override File[] listFiles(FilenameFilter filter); @Override File[] listFiles(FileFilter filter); @Override boolean isDirectory(); @Override boolean isFile(); @Override boolean equals(Object obj); @Override boolean canRead(); @Override boolean canWrite(); @Override boolean isHidden(); @Override boolean canExecute(); @Override int compareTo(File file); @Override int hashCode(); @Override String toString(); @Override URL toURL(); @Override URI toURI(); @Override boolean setReadOnly(); @Override boolean setWritable(boolean writable, boolean ownerOnly); @Override boolean setWritable(boolean writable); @Override boolean setReadable(boolean readable, boolean ownerOnly); @Override boolean setReadable(boolean readable); @Override boolean setExecutable(boolean executable, boolean ownerOnly); @Override boolean setExecutable(boolean executable); @Override long getTotalSpace(); @Override long getFreeSpace(); @Override long getUsableSpace(); }
|
@Test(expectedExceptions = IOException.class) public void testCreateNewFileInNonExistentDir() throws IOException { File file = fs.getFile("nonExistent/file.txt"); file.createNewFile(); }
|
EmptyIntSet extends AbstractImmutableIntSet { @Override public int size() { return 0; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterator.OfInt iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean containsAll(Collection<?> c); @Override IntStream intStream(); @Override boolean equals(Object obj); @Override String toString(); }
|
@Test public void testForEachPrimitive() { Set<Integer> results = new HashSet<>(); es.forEach((IntConsumer) results::add); assertEquals(0, results.size()); }
@Test public void testForEachObject() { Set<Integer> results = new HashSet<>(); es.forEach((Consumer<? super Integer>) results::add); assertEquals(0, results.size()); }
@Test public void testIntSpliteratorForEachRemaining() { Set<Integer> results = new HashSet<>(); es.intSpliterator().forEachRemaining((IntConsumer) results::add); assertEquals(0, results.size()); }
@Test public void testIntSpliteratorSplitTryAdvance() { Set<Integer> results = new HashSet<>(); Spliterator.OfInt spliterator = es.intSpliterator(); Spliterator.OfInt split = spliterator.trySplit(); assertNull(split); IntConsumer consumer = results::add; while (spliterator.tryAdvance(consumer)) { } assertEquals(0, results.size()); }
@Test public void testSize() { assertEquals(0, es.size()); }
|
GridFile extends File { @Override public String getPath() { return path; } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(File parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); @Override String getName(); @Override String getPath(); @Override String getAbsolutePath(); @Override File getAbsoluteFile(); @Override String getCanonicalPath(); @Override File getCanonicalFile(); @Override boolean isAbsolute(); @Override boolean renameTo(File dest); @Override void deleteOnExit(); @Override long length(); int getChunkSize(); @Override boolean createNewFile(); @Override boolean delete(); @Override boolean mkdir(); @Override boolean mkdirs(); @Override boolean exists(); @Override String getParent(); @Override File getParentFile(); @Override long lastModified(); @Override boolean setLastModified(long time); @Override String[] list(); @Override String[] list(FilenameFilter filter); @Override File[] listFiles(); @Override File[] listFiles(FilenameFilter filter); @Override File[] listFiles(FileFilter filter); @Override boolean isDirectory(); @Override boolean isFile(); @Override boolean equals(Object obj); @Override boolean canRead(); @Override boolean canWrite(); @Override boolean isHidden(); @Override boolean canExecute(); @Override int compareTo(File file); @Override int hashCode(); @Override String toString(); @Override URL toURL(); @Override URI toURI(); @Override boolean setReadOnly(); @Override boolean setWritable(boolean writable, boolean ownerOnly); @Override boolean setWritable(boolean writable); @Override boolean setReadable(boolean readable, boolean ownerOnly); @Override boolean setReadable(boolean readable); @Override boolean setExecutable(boolean executable, boolean ownerOnly); @Override boolean setExecutable(boolean executable); @Override long getTotalSpace(); @Override long getFreeSpace(); @Override long getUsableSpace(); }
|
@Test(expectedExceptions = FileNotFoundException.class) public void testWritingToDirectoryThrowsException2() throws IOException { File dir = createDir(); fs.getOutput(dir.getPath()); }
@Test(expectedExceptions = FileNotFoundException.class) public void testReadingFromDirectoryThrowsException2() throws IOException { File dir = createDir(); fs.getInput(dir.getPath()); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.