module JavaString: sig .. end
Utility functions for Java strings.
OCaml-compatible signature
module OCaml: sig .. end
Module providing functions that can be used as drop-in replacements
for function from
String
.
String operations
val char_at : t -> java_int -> java_char
Returns the character at the passed index; see
charAt(...).
Raises Java_exception
if index is invalid
val length : t -> java_int
Returns the length of the passed string; see
length(...).
val trim : t -> t
Returns a copy of the passed string, without leading and trailing
spaces; see
trim(...).
val matches : t -> t -> bool
matches s regexp
tests whether
s
matches regular expression
regexp
; see
matches(...).
Raises Java_exception
if
regexp
is invalid
val index_of : t -> t -> java_int
index_of s sub
returns the index of the first occurrence of
sub
in
s
if any,
-1l
otherwise; see
indexOf(...).
val last_index_of : t -> t -> java_int
last_index_of s sub
returns the index of the last occurrence of
sub
in
s
if any,
-1l
otherwise; see
lastIndexOf(...).
val starts_with : t -> t -> bool
starts_with s prefix
tests whether
s
starts with
prefix
; see
startsWith(...).
val ends_with : t -> t -> bool
ends_with s suffix
tests whether
s
ends with
suffix
; see
endsWith(...).
val substring : t -> java_int -> java_int -> t
substring s start_idx end_idx
returns the substring of
s
beginning at index
start_idx
(inclusive) and ending at index
end_idx
(exclusive); see
substring(...).
val to_char_array : t -> java_char java_char_array
val to_lower_case : t -> t
Returns a copy of the passed string with all characters converted to
lower case; see
toLowerCase(...).
val to_upper_case : t -> t
Returns a copy of the passed string with all characters converted to
upper case; see
toUpperCase(...).
val equals : t -> t -> bool
Tests whether the passed strings are equal; see
equals(...).
val equals_ignore_case : t -> t -> bool
val compare_to : t -> t -> java_int
val compare_to_ignore_case : t -> t -> java_int
Conversion from/to OCaml strings
val to_string : java'lang'String java_instance -> string
to_string s
converts the Java string s
into an OCaml string.
Raises Java_exeption
if s
is null
Null value
Output functions
val print_newline : unit -> unit
print_newline ()
prints a newline character onto the standard ouput.
val prerr_newline : unit -> unit
prerr_newline ()
prints a newline character onto the error ouput.
Miscellaneous
val unwrap : 'a java_instance option -> 'a java_instance
unwrap obj
unwraps the option
obj
into a bare reference:
Some x
is mapped to x
;
None
is mapped to null
.