pub struct JavaString<'mc>(/* private fields */);Expand description
The String class represents character strings. All
string literals in Java programs, such as “abc”, are
implemented as instances of this class.
Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";
is equivalent to:
char data[] = {'a', 'b', 'c'};
String str = new String(data);
Here are some more examples of how strings can be used:
System.out.println("abc");
String cde = "cde";
System.out.println("abc" + cde);
String c = "abc".substring(2,3);
String d = cde.substring(1, 2);
The class String includes methods for examining
individual characters of the sequence, for comparing strings, for
searching strings, for extracting substrings, and for creating a
copy of a string with all characters translated to uppercase or to
lowercase. Case mapping is based on the Unicode Standard version
specified by the Character class.
The Java language provides special support for the string
concatenation operator ( + ), and for conversion of
other objects to strings. String concatenation is implemented
through the StringBuilder(or StringBuffer)
class and its append method.
String conversions are implemented through the method
toString, defined by Object and
inherited by all classes in Java. For additional information on
string concatenation and conversion, see Gosling, Joy, and Steele,
The Java Language Specification.
Unless otherwise noted, passing a null argument to a constructor
or method in this class will cause a NullPointerException to be
thrown.
A String represents a string in the UTF-16 format
in which supplementary characters are represented by surrogate
pairs (see the section Unicode
Character Representations in the Character class for
more information).
Index values refer to char code units, so a supplementary
character uses two positions in a String.
The String class provides methods for dealing with
Unicode code points (i.e., characters), in addition to those for
dealing with Unicode code units (i.e., char values).
Implementations§
Source§impl<'mc> JavaString<'mc>
impl<'mc> JavaString<'mc>
pub fn new_with_bytes( jni: &SharedJNIEnv<'mc>, arg0: Option<Vec<i8>>, arg1: Option<i32>, arg2: Option<i32>, arg3: Option<i32>, ) -> Result<JavaString<'mc>, Box<dyn Error>>
pub fn new_with_chars( jni: &SharedJNIEnv<'mc>, arg0: Option<Vec<u16>>, arg1: Option<i32>, arg2: Option<i32>, ) -> Result<JavaString<'mc>, Box<dyn Error>>
pub fn new_with_string( jni: &SharedJNIEnv<'mc>, arg0: Option<impl Into<String>>, ) -> Result<JavaString<'mc>, Box<dyn Error>>
pub fn new_with_ints( jni: &SharedJNIEnv<'mc>, arg0: Option<Vec<i32>>, arg1: Option<i32>, arg2: Option<i32>, ) -> Result<JavaString<'mc>, Box<dyn Error>>
pub fn equals(&self, arg0: JObject<'mc>) -> Result<bool, Box<dyn Error>>
pub fn length(&self) -> Result<i32, Box<dyn Error>>
pub fn hash_code(&self) -> Result<i32, Box<dyn Error>>
pub fn get_chars( &self, arg0: i32, arg1: i32, arg2: Vec<u16>, arg3: i32, ) -> Result<(), Box<dyn Error>>
pub fn compare_to_with_object( &self, arg0: JObject<'mc>, ) -> Result<i32, Box<dyn Error>>
pub fn index_of_with_string( &self, arg0: impl Into<String>, arg1: Option<i32>, ) -> Result<i32, Box<dyn Error>>
pub fn index_of_with_int( &self, arg0: i32, arg1: Option<i32>, ) -> Result<i32, Box<dyn Error>>
pub fn char_at(&self, arg0: i32) -> Result<u16, Box<dyn Error>>
pub fn code_point_at(&self, arg0: i32) -> Result<i32, Box<dyn Error>>
pub fn code_point_before(&self, arg0: i32) -> Result<i32, Box<dyn Error>>
pub fn code_point_count( &self, arg0: i32, arg1: i32, ) -> Result<i32, Box<dyn Error>>
pub fn offset_by_code_points( &self, arg0: i32, arg1: i32, ) -> Result<i32, Box<dyn Error>>
pub fn bytes(&self) -> Result<Vec<i8>, Box<dyn Error>>
pub fn region_matches_with_boolean( &self, arg0: bool, arg1: i32, arg2: impl Into<String>, arg3: i32, arg4: Option<i32>, ) -> Result<bool, Box<dyn Error>>
pub fn starts_with_with_string( &self, arg0: impl Into<String>, arg1: Option<i32>, ) -> Result<bool, Box<dyn Error>>
pub fn last_index_of_with_int( &self, arg0: i32, arg1: Option<i32>, ) -> Result<i32, Box<dyn Error>>
pub fn last_index_of_with_string( &self, arg0: impl Into<String>, arg1: Option<i32>, ) -> Result<i32, Box<dyn Error>>
pub fn substring_with_int( &self, arg0: i32, arg1: Option<i32>, ) -> Result<String, Box<dyn Error>>
pub fn is_empty(&self) -> Result<bool, Box<dyn Error>>
pub fn matches(&self, arg0: impl Into<String>) -> Result<bool, Box<dyn Error>>
pub fn replace_first( &self, arg0: impl Into<String>, arg1: impl Into<String>, ) -> Result<String, Box<dyn Error>>
pub fn replace_all( &self, arg0: impl Into<String>, arg1: impl Into<String>, ) -> Result<String, Box<dyn Error>>
pub fn split_with_string( &self, arg0: impl Into<String>, arg1: Option<i32>, ) -> Result<Vec<String>, Box<dyn Error>>
pub fn to_lower_case_with_locale( &self, arg0: Option<impl Into<JavaLocale<'mc>>>, ) -> Result<String, Box<dyn Error>>
pub fn to_upper_case_with_locale( &self, arg0: Option<impl Into<JavaLocale<'mc>>>, ) -> Result<String, Box<dyn Error>>
pub fn trim(&self) -> Result<String, Box<dyn Error>>
pub fn strip(&self) -> Result<String, Box<dyn Error>>
pub fn strip_leading(&self) -> Result<String, Box<dyn Error>>
pub fn strip_trailing(&self) -> Result<String, Box<dyn Error>>
pub fn repeat(&self, arg0: i32) -> Result<String, Box<dyn Error>>
pub fn is_blank(&self) -> Result<bool, Box<dyn Error>>
pub fn to_char_array(&self) -> Result<Vec<u16>, Box<dyn Error>>
pub fn format_with_locale( jni: &SharedJNIEnv<'mc>, arg0: impl Into<JavaLocale<'mc>>, arg1: impl Into<String>, arg2: Option<Vec<JObject<'mc>>>, ) -> Result<String, Box<dyn Error>>
pub fn equals_ignore_case( &self, arg0: impl Into<String>, ) -> Result<bool, Box<dyn Error>>
pub fn compare_to_ignore_case( &self, arg0: impl Into<String>, ) -> Result<i32, Box<dyn Error>>
pub fn ends_with(&self, arg0: impl Into<String>) -> Result<bool, Box<dyn Error>>
pub fn concat(&self, arg0: impl Into<String>) -> Result<String, Box<dyn Error>>
pub fn indent(&self, arg0: i32) -> Result<String, Box<dyn Error>>
pub fn strip_indent(&self) -> Result<String, Box<dyn Error>>
pub fn translate_escapes(&self) -> Result<String, Box<dyn Error>>
pub fn transform( &self, arg0: impl Into<JavaFunction<'mc>>, ) -> Result<JObject<'mc>, Box<dyn Error>>
pub fn formatted( &self, arg0: Vec<JObject<'mc>>, ) -> Result<String, Box<dyn Error>>
pub fn copy_value_of_with_chars( jni: &SharedJNIEnv<'mc>, arg0: Vec<u16>, arg1: Option<i32>, arg2: Option<i32>, ) -> Result<String, Box<dyn Error>>
pub fn intern(&self) -> Result<String, Box<dyn Error>>
pub fn describe_constable(&self) -> Result<JavaOptional<'mc>, Box<dyn Error>>
pub fn instance_of(&self, other: impl Into<String>) -> Result<bool, Error>
Trait Implementations§
Source§impl<'mc> JNIInstantiatable<'mc> for JavaString<'mc>
impl<'mc> JNIInstantiatable<'mc> for JavaString<'mc>
Source§impl<'mc> JNIRaw<'mc> for JavaString<'mc>
impl<'mc> JNIRaw<'mc> for JavaString<'mc>
fn jni_ref(&self) -> SharedJNIEnv<'mc>
fn jni_object(&self) -> JObject<'mc>
Auto Trait Implementations§
impl<'mc> !Freeze for JavaString<'mc>
impl<'mc> !RefUnwindSafe for JavaString<'mc>
impl<'mc> !Send for JavaString<'mc>
impl<'mc> !Sync for JavaString<'mc>
impl<'mc> Unpin for JavaString<'mc>
impl<'mc> UnwindSafe for JavaString<'mc>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more