_absolute = TextTools.startsWith( rawPath, '/' ); _directory = TextTools.endsWith( rawPath, '/' ); if ( TextTools.isEmpty( rawPath ) )
/** * Returns a string builder from the given character sequence. * * @param charSequence Character sequence. * * @return String builder. */ protected StringBuilder getStringBuilder( final CharSequence charSequence ) { final StringBuilder result; if ( charSequence instanceof StringBuilder ) { result = (StringBuilder)charSequence; } else { result = new StringBuilder(); if ( TextTools.isNonEmpty( charSequence ) ) { result.append( charSequence ); } } return result; }
/** * Show error message dialog. The error is also printed on {@link * System#err}. * * The message can contain HTML formatting codes. * * @param owner Parent component (if {@code null}, a default {@link Frame} * is used). * @param title Dialog title. * @param message Content message. */ public static void showErrorDialog( @Nullable final Component owner, @Nullable final String title, @Nullable final String message ) { System.err.println( TextTools.getFixed( "----[ " + title + ']', 80, false, '-' ) ); System.err.println( message ); System.err.println( TextTools.getFixed( 80, '-' ) ); showMessageDialog( owner, title, TextTools.plainTextToHTML( message ), JOptionPane.ERROR_MESSAGE, 0 ); }
for ( final String s : substring.split( "," ) ) if ( ( TextTools.startsWith( s, '\'' ) && TextTools.endsWith( s, '\'' ) ) || ( TextTools.startsWith( s, '"' ) && TextTools.endsWith( s, '"' ) ) )
final List<String> result = TextTools.tokenize( createStatement.replaceAll( "[\\t ]+", " " ), '\n', true ); TextTools.startsWith( line, ')' ) ) if ( TextTools.endsWith( sb, ',' ) )
@Override public String getPath( final String parent , final String name ) { return TextTools.endsWith( parent , '/' ) ? parent + name : parent + '/' + name; }
throws SQLException final List<String> oldTokens = TextTools.tokenize( oldCreateLine, ' ', true ); final String oldType = oldTokens.get( 1 ); final String oldBaseType = oldType.replaceAll( "\\(.*", "" ); final List<String> newTokens = TextTools.tokenize( newCreateLine, ' ', true ); final String newType = newTokens.get( 1 ); final String newBaseType = newType.replaceAll( "\\(.*", "" ); System.out.println( " (" + TextTools.getFixed( "old definition:", updatePrefix.length() - 2, true, '.' ) + ' ' + oldCreateLine + ')' );
/** * Listen to a port and dump incoming data. * * @param portName Name of port to listen to. * * @throws IOException if an I/O error occurs. */ private void listenToPort( final String portName ) throws IOException { final Javacomm jc = Javacomm.getInstance(); System.out.println( "Opening port '" + portName + '\'' ); final SerialPort port = jc.openSerialPort( portName, 9600, DataBits.EIGHT, Parity.NONE, StopBits.ONE ); System.out.println( "Listening" ); final InputStream is = port.getInputStream(); while ( true ) { final int b = is.read(); if ( b < 0 ) { break; } System.out.println( TextTools.toHexString( b, 2, true ) + ' ' + TextTools.getFixed( String.valueOf( b ), 3, true, ' ' ) + " '" + (char)b + '\'' ); } System.out.println( "Port closed" ); }
/** * Test if the specified CREATE line is a column definition. * * @param createLine CREATE line. * * @return {@code true} if the CREATE line is a column definition; {@code * false} otherwise. */ private static boolean isColumnDefinition( final CharSequence createLine ) { return TextTools.startsWith( createLine, '`' ); }
@Override public void getColumnData( @NotNull final Object object, @NotNull final ResultSet resultSet, final int columnIndex ) throws SQLException { final Collection<String> strings = getFieldValue( object ); strings.clear(); strings.addAll( TextTools.tokenize( resultSet.getString( columnIndex ), _separator, false ) ); }
if ( !TextTools.endsWith( path, '/' ) )
/** * Get builder for SET clause. A comma is appended to the existing SET clause * when needed. * * @return {@link StringBuilder} for SET clause. */ public StringBuilder getSetBuilder() { final StringBuilder result; final CharSequence set = _set; if ( set instanceof StringBuilder ) { result = (StringBuilder)set; } else { result = new StringBuilder(); _set = result; if ( TextTools.isNonEmpty( set ) ) { result.append( set ); } } if ( TextTools.isNonEmpty( result ) ) { result.append( ',' ); } return result; }
if ( TextTools.endsWith( initialFolder, '/' ) && !initialFolder.startsWith( rootFolder ) )
/** * Adds a sub-select to the SELECT clause. A comma is inserted before the element * when the existing SELECT clause is non-empty. * * @param selectQuery Sub-select that provides the value. * @param alias Alias assigned to value. */ public void select( @NotNull final SelectQuery<?> selectQuery, @NotNull final CharSequence alias ) { final StringBuilder sb = getSelectBuilder(); if ( !TextTools.isEmpty( sb ) ) { sb.append( ',' ); } sb.append( '(' ); sb.append( selectQuery.getQueryString() ); sb.append( ") AS " ); sb.append( alias ); addSelectParameters( selectQuery.getQueryParameters() ); }