projects
/
Macaco
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5cfdf35
)
Added repeat() method to MText.
author
Marco Zanon
<info@marcozanon.com>
Thu, 5 Apr 2012 21:16:18 +0000
(21:16 +0000)
committer
Marco Zanon
<info@marcozanon.com>
Thu, 5 Apr 2012 21:16:18 +0000
(21:16 +0000)
src/java/com/marcozanon/macaco/text/MText.java
patch
|
blob
|
history
diff --git
a/src/java/com/marcozanon/macaco/text/MText.java
b/src/java/com/marcozanon/macaco/text/MText.java
index 6500fe3688bff63160202b2bcc59857484c5bc89..2bed7140663b41b65a8a9c3d958267513405ba33 100644
(file)
--- a/
src/java/com/marcozanon/macaco/text/MText.java
+++ b/
src/java/com/marcozanon/macaco/text/MText.java
@@
-10,7
+10,7
@@
import com.marcozanon.macaco.MObject;
public class MText extends MObject {
- /* */
+ /*
Checks
*/
public static boolean isBlank(String x) {
if ((null == x) || ("".equals(x))) {
@@
-19,4
+19,18
@@
public class MText extends MObject {
return false;
}
+ /* Utility methods */
+
+ public static String repeat(String x, int times) {
+ if (times < 1) {
+ throw new IllegalArgumentException(String.format("Invalid 'times': %s.", times));
+ }
+ //
+ StringBuilder y = new StringBuilder("");
+ for (int i = 0; i < times; i++) {
+ y = y.append(x);
+ }
+ return y.toString();
+ }
+
}