Add method to stringutil
This commit is contained in:
parent
783cbb3cf8
commit
53c23b8d9b
|
@ -27,6 +27,17 @@ import java.util.Arrays;
|
|||
|
||||
public class StringUtil {
|
||||
|
||||
/**
|
||||
* If a string ends with a given character, remove that character from the end of the string (as many times as it occurs at the end)
|
||||
*/
|
||||
public static String chompCharacter(String theInput, char theCharacter) {
|
||||
String retVal = theInput;
|
||||
while (retVal != null && retVal.length() > 0 && retVal.charAt(retVal.length() - 1) == theCharacter) {
|
||||
retVal = retVal.substring(0, retVal.length() - 1);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static String normalizeStringForSearchIndexing(String theString) {
|
||||
if (theString == null) {
|
||||
return null;
|
||||
|
@ -57,7 +68,6 @@ public class StringUtil {
|
|||
return new String(outBuffer.toCharArray()).toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
public static String toUtf8String(byte[] theBytes) {
|
||||
byte[] bytes = theBytes;
|
||||
if (theBytes.length >= 3) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ca.uhn.fhir.jpa.model.util;
|
||||
package ca.uhn.fhir.util;
|
||||
|
||||
import ca.uhn.fhir.util.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -42,4 +41,14 @@ public class StringUtilTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChompCharacter() {
|
||||
assertEquals(null, StringUtil.chompCharacter(null, '/'));
|
||||
assertEquals("", StringUtil.chompCharacter("", '/'));
|
||||
assertEquals("", StringUtil.chompCharacter("/", '/'));
|
||||
assertEquals("a", StringUtil.chompCharacter("a/", '/'));
|
||||
assertEquals("a/a", StringUtil.chompCharacter("a/a/", '/'));
|
||||
assertEquals("a/a", StringUtil.chompCharacter("a/a////", '/'));
|
||||
}
|
||||
|
||||
}
|
|
@ -117,7 +117,7 @@ The `$partition-management-update-partition` operation can be used to update an
|
|||
An HTTP POST to the following URL would be used to invoke this operation:
|
||||
|
||||
```url
|
||||
http://example.com/$partition-management-create-partition
|
||||
http://example.com/$partition-management-update-partition
|
||||
```
|
||||
|
||||
The following request body could be used:
|
||||
|
|
Loading…
Reference in New Issue