Package org.python.core.util
Class StringUtil
java.lang.Object
org.python.core.util.StringUtil
String Utility methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
decapitalize
(String string) Decapitalize a String if it begins with a capital letter, e.g.:decapitalize("FooBar") == "fooBar"
static String
fromBytes
(byte[] buf) Return a new String with chars corresponding to buf.static String
fromBytes
(byte[] buf, int off, int len) Return a new String with chars corresponding to buf from off to off + len.static String
fromBytes
(ByteBuffer buf) Return a new String with chars corresponding to buf.static String
Return a new String with chars corresponding to b.static String
Return a new String with chars corresponding to buf, which is a byte-oriented buffer obtained through the buffer API.static byte[]
Encodes this String into a sequence of bytes.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
toBytes
Encodes this String into a sequence of bytes. Each byte contains the low-order bits of its corresponding char.- Parameters:
string
- a String value- Returns:
- a byte array with one byte for each char in string
-
fromBytes
Return a new String with chars corresponding to buf from off to off + len.- Parameters:
buf
- an array of bytesoff
- the initial offsetlen
- the length- Returns:
- a new String corresponding to the bytes in buf
-
fromBytes
Return a new String with chars corresponding to buf.- Parameters:
buf
- an array of bytes- Returns:
- a new String corresponding to the bytes in buf
-
fromBytes
Return a new String with chars corresponding to buf.- Parameters:
buf
- a ByteBuffer of bytes- Returns:
- a new String corresponding to the bytes in buf
-
fromBytes
Return a new String with chars corresponding to buf, which is a byte-oriented buffer obtained through the buffer API. It depends on the implementation ofPyBuffer.toString()
provided by each buffer implementation.- Parameters:
buf
- a PyBuffer of bytes- Returns:
- a new String corresponding to the bytes in buf
-
fromBytes
Return a new String with chars corresponding to b.- Parameters:
b
- a BaseBytes containing bytes- Returns:
- a new String corresponding to the bytes in b
-
decapitalize
Decapitalize a String if it begins with a capital letter, e.g.:decapitalize("FooBar") == "fooBar"
- Parameters:
string
- a String- Returns:
- a decapitalized String
-