initial commit
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / string / CuttableString.java
1 package eu.svjatoslav.commons.string;
2
3 public class CuttableString {
4
5         private String value;
6
7         public CuttableString(final String value) {
8                 this.value = value;
9         }
10
11         /**
12          * Cut given amount of characters from the left of the string. Return cutted
13          * part.
14          */
15         public String cutLeft(final int cutAmount) {
16
17                 int actualCutAmount = cutAmount;
18
19                 if (actualCutAmount > value.length())
20                         actualCutAmount = value.length();
21
22                 final String result = value.substring(0, actualCutAmount);
23
24                 value = value.substring(actualCutAmount);
25
26                 return result;
27         }
28
29         public boolean isEmpty() {
30                 return value.length() == 0;
31         };
32
33 }