/** * Determines if the string is empty or <code>null</code>. * * @param source the string to check * @return <code>true</code> if the source string is <code>null</code> or an emptry string, <code>false</code> * otherwise. */ public static boolean isEmpty( final String source ) { return isEmpty( source, true ); }
/** * Creates a new support instance. * * @param safeTags the tags that are safe for line breaks. * @param indentString the indent string. */ public XmlWriterSupport( final TagDescription safeTags, final String indentString ) { this( safeTags, indentString, StringUtils.getLineSeparator() ); }
private boolean isSupportedFormat( final URL sourceURL ) { final String file = sourceURL.getFile(); if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) || StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( file, ".bmp" ) || StringUtils.endsWithIgnoreCase( file, ".ico" ) ) { return true; } return false; }
/** * Splits a given string on any whitespace character. Duplicate separators will be merged into a single separator * occurance. This implementation provides the same functionality as the REGEXP-based String.split(..) operation but * does not use Regular expressions and therefore it is faster and less memory consuming. * * @param string the text to be split. * @return the text elements as array. */ public static String[] split(final String string) { return split(string, " \t\n\r\f"); }
for ( int i = 0; i < statements.length; i++ ) { stat = statements[ i ]; if ( !StringUtils.onlySpaces( stat ) ) { String sql = StringUtils.trim( stat );
/** * Checks whether or not a String consists only of spaces. * * @param str The string to check * @return true if the string has nothing but spaces. */ public static final boolean onlySpaces( String str ) { for ( int i = 0; i < str.length(); i++ ) { if ( !isSpace( str.charAt( i ) ) ) { return false; } } return true; }
/** * Splits a given string on any whitespace character. Duplicate separators will be merged into a single separator * occurance. This implementation provides the same functionality as the REGEXP-based String.split(..) operation but * does not use Regular expressions and therefore it is faster and less memory consuming. * * @param string the text to be split. * @return the text elements as array. */ public static String[] split( final String string ) { return split( string, " \t\n\r\f" ); }
if (!StringUtils.onlySpaces(stat)) String sql = StringUtils.trim(stat);
/** * Checks whether or not a String consists only of spaces. * * @param str The string to check * @return true if the string has nothing but spaces. */ public static final boolean onlySpaces(String str) { for (int i = 0; i < str.length(); i++) { if (!isSpace(str.charAt(i))) { return false; } } return true; }
private String setNull( final String value ) { if ( StringUtils.isEmpty( value ) ) { return null; } return value; } }
private int getImageFormat( final ResourceKey key ) { final URL url = resourceManager.toURL( key ); if ( url == null ) { return -1; } final String file = url.getFile(); if ( StringUtils.endsWithIgnoreCase( file, ".png" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_PNG; } if ( StringUtils.endsWithIgnoreCase( file, ".jpg" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".jpeg" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_JPEG; } if ( StringUtils.endsWithIgnoreCase( file, ".bmp" ) || // NON-NLS StringUtils.endsWithIgnoreCase( file, ".ico" ) ) { // NON-NLS return Workbook.PICTURE_TYPE_DIB; } return -1; }
public GlobalStyleManager() { this.styles = new HashMap<StoredStyle, String>(); this.stylesText = new HashSet<String>(); this.lineSeparator = StringUtils.getLineSeparator(); }
public Object toPropertyValue( final String s ) throws BeanException { final String[] parsedResult = StringUtils.split( s, ":" ); if ( parsedResult.length < 6 ) { throw new BeanException( "ParsedResult length: " + parsedResult.length ); final String[] dashArrayText = StringUtils.split( parsedResult[6], "," ); dashArray = new float[dashArrayText.length]; for ( int i = 0; i < dashArrayText.length; i++ ) {
/** * Trims a string: removes the leading and trailing spaces of a String. * * @param str The string to trim * @return The trimmed string. */ public static final String trim( String str ) { if ( str == null ) { return null; } int max = str.length() - 1; int min = 0; while ( min <= max && isSpace( str.charAt( min ) ) ) { min++; } while ( max >= 0 && isSpace( str.charAt( max ) ) ) { max--; } if ( max < min ) { return ""; } return str.substring( min, max + 1 ); } }
/** * Determines if the string is empty or <code>null</code>. * * @param source the string to check * @return <code>true</code> if the source string is <code>null</code> or an emptry string, * <code>false</code> otherwise. */ public static boolean isEmpty(final String source) { return isEmpty(source, true); }
/** * Tests whether or not the specified abstract pathname should be included in a pathname list. * * @param pathname The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> should be included */ public boolean accept( final File pathname ) { if ( pathname.canRead() == false ) { return false; } if ( pathname.isDirectory() ) { return true; } final String name = pathname.getName(); if ( StringUtils.endsWithIgnoreCase( name, ".ttf" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( name, ".ttc" ) ) { return true; } if ( StringUtils.endsWithIgnoreCase( name, ".otf" ) ) { return true; } return false; }
public DefaultStyleBuilder( ) { this.lineSeparator = StringUtils.getLineSeparator(); this.cachedBorderStyle = new LFUMap<BorderEdge, String>( 30 ); this.cachedCornerStyle = new LFUMap<BorderCorner, String>( 30 ); this.buffer = new StringBuffer( 100 ); this.usedStyles = new StyleCarrier[CSSKeys.values().length]; if ( "true".equals( ClassicEngineBoot.getInstance().getGlobalConfig().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.html.SafariLengthHack" ) ) ) { pointConverter = new DecimalFormat( "0", new DecimalFormatSymbols( Locale.US ) ); } else { pointConverter = new DecimalFormat( "0.####", new DecimalFormatSymbols( Locale.US ) ); } }
public void setAsText( final String text ) throws IllegalArgumentException { final String[] strings = StringUtils.split( text, "," ); if ( strings.length == 0 ) { setValue( null );
private static SimpleDateFormat createSafely( final String pattern, final String defaultPattern, final Locale locale ) { try { if ( StringUtils.isEmpty( pattern ) == false ) { return new SimpleDateFormat( pattern, locale ); } } catch ( Exception e ) { logger.warn( "Invalid format string found in locale settings", e ); // NON-NLS } return new SimpleDateFormat( defaultPattern, locale ); }