protected void printParameter( String name, String value, String defaultValue, String description ) { if ( Utils.isEmpty( defaultValue ) ) { System.out.println( "Parameter: " + name + "=" + Const.NVL( value, "" ) + " : " + Const.NVL( description, "" ) ); } else { System.out.println( "Parameter: " + name + "=" + Const.NVL( value, "" ) + ", default=" + defaultValue + " : " + Const.NVL( description, "" ) ); } }
@Override public String getURL( String hostname, String port, String databaseName ) { if ( getAccessType() == DatabaseMeta.TYPE_ACCESS_ODBC ) { return "jdbc:odbc:" + databaseName; } else { if ( Const.isEmpty( port ) ) { return "jdbc:mariadb://" + hostname + "/" + databaseName; } else { return "jdbc:mariadb://" + hostname + ":" + port + "/" + databaseName; } } }
/** * @deprecated use {@link #getSplitEvery(VariableSpace)} or {@link #getSplitEveryRows()} * @return Returns the splitEvery. */ @Override public int getSplitEvery() { return Const.toInt( splitEveryRows, 0 ); }
/** * @return An array of all default conversion formats, to be used in dialogs etc. */ public static String[] getConversionFormats() { String[] dats = Const.getDateFormats(); String[] nums = Const.getNumberFormats(); int totsize = dats.length + nums.length; String[] formats = new String[totsize]; for ( int x = 0; x < dats.length; x++ ) { formats[x] = dats[x]; } for ( int x = 0; x < nums.length; x++ ) { formats[dats.length + x] = nums[x]; } return formats; }
public void guessTrimType() { boolean spaces_before = false; boolean spaces_after = false; for ( int i = 0; i < samples.length; i++ ) { spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0; spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0; samples[i] = Const.trim( samples[i] ); } trimtype = ValueMetaInterface.TRIM_TYPE_NONE; if ( spaces_before ) { trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT; } if ( spaces_after ) { trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT; } }
protected String trim( String string ) { switch ( getTrimType() ) { case TRIM_TYPE_NONE: break; case TRIM_TYPE_RIGHT: string = Const.rtrim( string ); break; case TRIM_TYPE_LEFT: string = Const.ltrim( string ); break; case TRIM_TYPE_BOTH: string = Const.trim( string ); break; default: break; } return string; }
private void setEncodings( ComboVar var ) { // Encoding of the text file: String encoding = Const.NVL( var.getText(), Const.getEnvironmentVariable( "file.encoding", "UTF-8" ) ); var.removeAll(); ArrayList<Charset> values = new ArrayList<Charset>( Charset.availableCharsets().values() ); for ( int i = 0; i < values.size(); i++ ) { Charset charSet = values.get( i ); var.add( charSet.displayName() ); } // Now select the default! int idx = Const.indexOfString( encoding, var.getItems() ); if ( idx >= 0 ) { var.select( idx ); } } }
protected void setComboBoxes() { // Something was changed in the row. // final Map<String, Integer> fields = new HashMap<String, Integer>(); // Add the currentMeta fields... fields.putAll( inputFields ); Set<String> keySet = fields.keySet(); List<String> entries = new ArrayList<String>( keySet ); String[] fieldNames = entries.toArray( new String[entries.size()] ); Const.sortStrings( fieldNames ); colinf[0].setComboValues( fieldNames ); }
@Override public void run() { try { cleanupJarFiles( jarFiles ); } catch ( Exception e ) { System.err.println( "Error cleaning up temporary Talend jar file extracts: " + Const.getStackTracker( e ) ); } } } );
public static final int getFileType( String fileTypeCode ) { int t = Const.indexOfString( fileTypeCode, FixedInputMeta.fileTypeCode ); if ( t >= 0 ) { return t; } t = Const.indexOfString( fileTypeCode, FixedInputMeta.fileTypeDesc ); if ( t >= 0 ) { return t; } return FILE_TYPE_NONE; }
public static final int getOperator( String description ) { if ( description == null ) { return OPERATOR_NONE; } for ( int i = 1; i < operators.length; i++ ) { if ( operators[i].equalsIgnoreCase( Const.trim( description ) ) ) { return i; } } return OPERATOR_NONE; }
string = Const.trim( string ); wInputString.setText( string ); wFormat.setItems( Const.getNumberFormats() ); int index = ( !Utils.isEmpty( formatString ) ) ? wFormat.indexOf( formatString ) : wFormat.indexOf( "#" ); wFormat.setItems( Const.getNumberFormats() ); index = ( !Utils.isEmpty( formatString ) ) ? wFormat.indexOf( formatString ) : wFormat.indexOf( "#.#" ); wFormat.setItems( Const.getDateFormats() ); index = ( !Utils.isEmpty( formatString ) ) ? wFormat.indexOf( formatString ) : wFormat
private String[] getComboValues( TableItem row, ColumnInfo colinfo ) { if ( colinfo.getType() == ColumnInfo.COLUMN_TYPE_FORMAT ) { int type = ValueMetaFactory.getIdForValueMeta( row.getText( colinfo.getFieldTypeColumn() ) ); switch ( type ) { case ValueMetaInterface.TYPE_DATE: return Const.getDateFormats(); case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: case ValueMetaInterface.TYPE_NUMBER: return Const.getNumberFormats(); case ValueMetaInterface.TYPE_STRING: return Const.getConversionFormats(); default: return new String[0]; } } return colinfo.getComboValues(); }
public StringEvaluator( boolean tryTrimming ) { this( tryTrimming, DEFAULT_NUMBER_FORMATS, Const.getDateFormats() ); }
protected void setComboBoxes() { // Something was changed in the row. // final Map<String, Integer> fields = new HashMap<String, Integer>(); // Add the currentMeta fields... fields.putAll( inputFields ); Set<String> keySet = fields.keySet(); List<String> entries = new ArrayList<String>( keySet ); String[] fieldNames = entries.toArray( new String[entries.size()] ); Const.sortStrings( fieldNames ); colinf[0].setComboValues( fieldNames ); }
public void showDocumentMap() { try { URL url = new URL( DOCUMENTATION_URL ); HelpUtils.openHelpDialog( shell, STRING_DOCUMENT_TAB_NAME, url.toString() ); } catch ( MalformedURLException e1 ) { log.logError( Const.getStackTracker( e1 ) ); } }
public String[] getComboValues( TableItem tableItem, int rowNr, int colNr ) { String[] comboValues = new String[] {}; int type = ValueMetaFactory.getIdForValueMeta( tableItem.getText( colNr - 1 ) ); switch ( type ) { case ValueMetaInterface.TYPE_DATE: comboValues = Const.getDateFormats(); break; case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: case ValueMetaInterface.TYPE_NUMBER: comboValues = Const.getNumberFormats(); break; default: break; } return comboValues; }
@Override public boolean matches( String id ) { return Const.indexOfString( id, ids ) >= 0; }
public static final int getFunction( String description ) { for ( int i = 1; i < functions.length; i++ ) { if ( functions[i].equalsIgnoreCase( Const.trim( description ) ) ) { return i; } } return FUNC_EQUAL; }
public void guessTrimType() { boolean spaces_before = false; boolean spaces_after = false; for ( int i = 0; i < samples.length; i++ ) { spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0; spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0; samples[i] = Const.trim( samples[i] ); } trimtype = ValueMetaInterface.TRIM_TYPE_NONE; if ( spaces_before ) { trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT; } if ( spaces_after ) { trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT; } }