/** * Returns true if the given string is not null and does not represents the empty string * * @param str the string; may be null or empty * @return true if the string is not null and not empty, false otherwise */ public static boolean notBlank( String str ) { return !isBlank(str); }
@Override public void debug( Throwable t, String message, Object... params ) { if (StringUtil.isBlank(message)) { return; } if (!isDebugEnabled()) return; logger.debug(StringUtil.createString(message, params), t); }
/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
@Override public String text( Locale locale, Object... arguments ) { return StringUtil.createString(text, arguments); } }
protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), 4, ' '); } }
public void compareSeparatedLines( Object... lines ) { ByteArrayOutputStream content = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(content); for (Object line : lines) { stream.println(line); } List<String> actualLines = StringUtil.splitLines(content.toString()); assertArrayEquals(lines, actualLines.toArray()); }
@Override public String text( Locale locale, Object... arguments ) { return StringUtil.createString(text, arguments); } }
protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), 4, ' '); } }
@Test public void shouldPrintToStringBuilderAllResultsWhenMaxRowParameterIsLargerThanNumberOfTuples() { tuples.clear(); results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb, 3); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim } }
/** * @param udfPath the absolute path of the root node where UDF files are sequenced (can be <code>null</code> or empty if * {@link #UDF_PATH_PROPERTY} or the default path should be used) */ public void setUdfPath( final String udfPath ) { this.udfPath = ( StringUtil.isBlank( udfPath ) ? null : udfPath ); }
@Override public void trace( String message, Object... params ) { if (StringUtil.isBlank(message)) { return; } if (!isTraceEnabled()) return; logger.trace(StringUtil.createString(message, params)); }
@Override public String text( Locale locale, Object... arguments ) { return StringUtil.createString(text, arguments); } }
/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), widthOfRowNumber, ' '); }
@Test public void shouldPrintToStringBuilderAllResults() { results = new QueryResults(columns, statistics, tuples, context.getProblems(), null); StringBuilder sb = new StringBuilder(); results.toString(typeSystem, sb); List<String> lines = StringUtil.splitLines(sb.toString()); assertThat(lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim }
/** * {@inheritDoc} * * @see org.teiid.modeshape.sequencer.Result#wasSuccessful() */ @Override public boolean wasSuccessful() { return ( ( this.error == null ) && StringUtil.isBlank( this.errorMsg ) ); }
@Override public void trace( Throwable t, String message, Object... params ) { if (StringUtil.isBlank(message)) { return; } if (!isTraceEnabled()) return; logger.trace(StringUtil.createString(message, params), t); }
/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { return language + " -> " + statement + "\n" + StringUtil.createString(' ', Math.min(language.length() - 3, 0)) + "AQM -> " + query; }
/** * Get the string representation of the supplied binary hash. * * @param hash the binary hash * @return the hex-encoded representation of the binary hash, or null if the hash is null */ public static String asHexString( byte[] hash ) { return hash != null ? StringUtil.getHexString(hash) : null; }
@Test public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() { assertEquals(" This", StringUtil.justifyRight("This", 10, ' ')); }