/** * Returns <code>true</code> if the host part of this URL and the given URL are equal. * The comparison is case-insensitive. * * @param url the URL to test for host equality * @return <code>true</code> if the host part of this URL and the given URL are equal */ public boolean hostEquals(FileURL url) { // Note: StringUtils#equals is null-safe return StringUtils.equals(this.host, url.host, false); }
/** * If we have passed the markSize reset the * mark so that the space can be used. * * @since ostermillerutils 1.00.00 */ private void ensureMark(){ if (marked() > markSize){ markPosition = readPosition; markSize = 0; } }
/** * Shorthand for {@link #flatten(String[], String)} invoked with a <code>" "</code> separator. * * @param s the string array to flatten * @return the flattened string array */ public static String flatten(String s[]) { return flatten(s, " "); }
public boolean accept(String value) { if(isCaseSensitive()) return value.endsWith(s); return StringUtils.endsWithIgnoreCase(value, s); } }
/** * Equivalent of <code>String.endsWith(String)</code> using a <code>char[]</code>. * @param a String to test. * @param b suffix to test. * @return <code>true</code> if <code>a</code> ends with <code>b</code>. */ public static boolean endsWith(String a, char[] b) { return matches(a, b, a.length()); }
@Test(dataProvider = "matchesIgnoreCase") public void testMatchesIgnoreCase(String a, String b, int pos, boolean expected) { assert StringUtils.matchesIgnoreCase(a, b, pos) == expected; }
/** * Tests the {@link StringUtils#parseIntDef(String, int)} method. * @param input string to parse. * @param def default value. * @param expected expected return value of {@link StringUtils#parseIntDef(String, int)}. */ @Test(dataProvider = "parseIntDef") public void testParseIntDef(String input, int def, int expected) { assert StringUtils.parseIntDef(input, def) == expected; }
/** * Tests {@link StringUtils#startsWithIgnoreCase(String, String)}. * @param a first string to compare. * @param b second string to compare. * @param expected expected return value of {@link StringUtils#startsWithIgnoreCase(String, String)}. */ @Test(dataProvider = "startsWithIgnoreCase") public void testStartsWithIgnoreCase(String a, String b, boolean expected) { assert StringUtils.startsWithIgnoreCase(a, b) == expected; }
/** * Read bytes into an array. * This method will block until some input is available, * an I/O error occurs, or the end of the stream is reached. * * @param cbuf Destination buffer. * @return The number of bytes read, or -1 if the end of * the stream has been reached * @throws IOException if the stream is closed. * * @since ostermillerutils 1.00.00 */ @Override public int read(byte[] cbuf) throws IOException { return read(cbuf, 0, cbuf.length); }
/** * Write an array of bytes. * If the buffer allows blocking writes, this method will block until * all the data has been written rather than throw an IOException. * * @param cbuf Array of bytes to be written * @throws BufferOverflowException if buffer does not allow blocking writes * and the buffer is full. If the exception is thrown, no data * will have been written since the buffer was set to be non-blocking. * @throws IOException if the stream is closed, or the write is interrupted. * * @since ostermillerutils 1.00.00 */ @Override public void write(byte[] cbuf) throws IOException { write(cbuf, 0, cbuf.length); }
/** * Get number of bytes that are available to be read. * <p> * Note that the number of bytes available plus * the number of bytes free may not add up to the * capacity of this buffer, as the buffer may reserve some * space for other purposes. * * @return the size in bytes of this buffer * * @since ostermillerutils 1.00.00 */ public int getAvailable(){ synchronized (this){ return available(); } }
/** * Get the number of bytes this buffer has free for * writing. * <p> * Note that the number of bytes available plus * the number of bytes free may not add up to the * capacity of this buffer, as the buffer may reserve some * space for other purposes. * * @return the available space in bytes of this buffer * * @since ostermillerutils 1.00.00 */ public int getSpaceLeft(){ synchronized (this){ return spaceLeft(); } }
/** * Close the stream, flushing it first. * This will cause the InputStream associated with this circular buffer * to read its last bytes once it empties the buffer. * Once a stream has been closed, further write() or flush() invocations * will cause an IOException to be thrown. Closing a previously-closed stream, * however, has no effect. * * @throws IOException never. * * @since ostermillerutils 1.00.00 */ @Override public void close() throws IOException { synchronized (CircularByteBuffer.this){ if (!outputStreamClosed && !inputStreamClosed){ flush(); } outputStreamClosed = true; } }
private void put(KeyStroke ks, String actionId, int acceleratorType) { if (ks != null) map.put(ks, new Pair<String, Integer>(actionId, acceleratorType)); }
/** * Returns <code>true</code> if the query part of this URL and the given URL are equal. * The comparison is case-sensitive. * * @param url the URL to test for query equality * @return <code>true</code> if the query part of this URL and the given URL are equal */ public boolean queryEquals(FileURL url) { return StringUtils.equals(this.query, url.query, true); }
/** * Test the {@link StringUtils#endsWithIgnoreCase(String, String)} method. * @param a first string to compare. * @param b second string to compare. * @param expected expected return value of {@link StringUtils#endsWithIgnoreCase(String, String)} */ @Test(dataProvider = "endsWithIgnoreCase") public void testEndsWithIgnoreCase(String a, String b, boolean expected) { assert StringUtils.endsWithIgnoreCase(a, b) == expected; }
/** * Tests the {@link StringUtils#equals(String, String, boolean)} method (case sensitive). * @param a first string to compare. * @param b second string to compare * @param expected expected return value of {@link StringUtils#equals(String, String, boolean)} */ @Test(dataProvider = "caseInsensitiveEquals") public void testCaseInsensitiveEquals(String a, String b, boolean expected) { assert StringUtils.equals(a, b, false) == expected; }
/** * Tests {@link StringUtils#flatten(String[], String)}. * @param expected expected returned value of {@link StringUtils#flatten(String[], String)}. * @param data data to flatten. * @param separator separator to use when flattening. */ @Test(dataProvider = "flatten") public void testFlatten(String expected, String[] data, String separator) { assert expected.equals(StringUtils.flatten(data, separator)); if(separator.equals(" ")) assert expected.equals(StringUtils.flatten(data)); }
/** * Tests the {@link StringUtils#equals(String, String, boolean)} method (case insensitive). * @param a first string to compare. * @param b second string to compare * @param expected expected return value of {@link StringUtils#equals(String, String, boolean)} */ @Test(dataProvider = "caseSensitiveEquals") public void testCaseSensitiveEquals(String a, String b, boolean expected) { assert StringUtils.equals(a, b, true) == expected; }