forked from dom4j/dom4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
190 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Tue Aug 22 18:47:11 BST 2017 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip | ||
#Sat Sep 16 13:35:18 CEST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.dom4j.util; | ||
|
||
/** | ||
* Contains utilities related to strings. | ||
* | ||
* @author Marián Petráš | ||
*/ | ||
public final class StringUtils { | ||
|
||
private StringUtils() {} | ||
|
||
/** | ||
* Finds out if the given character sequence starts with a whitespace | ||
* character. | ||
* | ||
* @return {@code true} if the given character sequence is not empty | ||
* and starts with a whitespace character; {@code false} otherwise | ||
* @exception NullPointerException if the given character sequence is | ||
* {@code null} | ||
*/ | ||
public static boolean startsWithWhitespace(final CharSequence charSeq) { | ||
if (charSeq.length() == 0) { | ||
return false; | ||
} | ||
return Character.isWhitespace(charSeq.charAt(0)); | ||
} | ||
|
||
/** | ||
* Finds out if the given character sequence ends with a whitespace | ||
* character. | ||
* | ||
* @return {@code true} if the given character sequence is not empty | ||
* and ends with a whitespace character; {@code false} otherwise | ||
* @exception NullPointerException if the given character sequence is | ||
* {@code null} | ||
*/ | ||
public static boolean endsWithWhitespace(final CharSequence charSeq) { | ||
if (charSeq.length() == 0) { | ||
return false; | ||
} | ||
return Character.isWhitespace(charSeq.charAt(charSeq.length() - 1)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.dom4j.util; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import static org.dom4j.util.StringUtils.endsWithWhitespace; | ||
import static org.dom4j.util.StringUtils.startsWithWhitespace; | ||
import static org.testng.Assert.assertFalse; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* Test of utility class StringUtils. | ||
* | ||
* @author Marián Petráš | ||
*/ | ||
public class StringUtilsTest { | ||
|
||
@Test | ||
public void testStartsWithWhitespace_empty() { | ||
assertFalse(startsWithWhitespace("")); | ||
} | ||
|
||
@Test | ||
public void testStartsWithWhitespace_nonEmpty() { | ||
assertTrue (startsWithWhitespace(" ")); | ||
assertFalse(startsWithWhitespace("alpha")); | ||
assertTrue (startsWithWhitespace(" alpha")); | ||
assertFalse(startsWithWhitespace("alpha ")); | ||
assertTrue (startsWithWhitespace(" alpha ")); | ||
} | ||
|
||
@Test | ||
public void testEndsWithWhitespace_empty() { | ||
assertFalse(endsWithWhitespace("")); | ||
} | ||
|
||
@Test | ||
public void testEndsWithWhitespace_nonEmpty() { | ||
assertTrue (endsWithWhitespace(" ")); | ||
assertFalse(endsWithWhitespace("alpha")); | ||
assertFalse(endsWithWhitespace(" alpha")); | ||
assertTrue (endsWithWhitespace("alpha ")); | ||
assertTrue (endsWithWhitespace(" alpha ")); | ||
} | ||
|
||
} |