56599
|
1 |
/* Title: Pure/General/word.scala
|
|
2 |
Module: PIDE
|
|
3 |
Author: Makarius
|
|
4 |
|
|
5 |
Support for plain text words.
|
|
6 |
*/
|
|
7 |
|
|
8 |
package isabelle
|
|
9 |
|
|
10 |
|
|
11 |
import java.util.Locale
|
|
12 |
|
|
13 |
|
|
14 |
object Word
|
|
15 |
{
|
|
16 |
def lowercase(str: String): String = str.toLowerCase(Locale.ROOT)
|
|
17 |
def uppercase(str: String): String = str.toUpperCase(Locale.ROOT)
|
|
18 |
|
|
19 |
def capitalize(str: String): String =
|
|
20 |
if (str.length == 0) str
|
|
21 |
else uppercase(str.substring(0, 1)) + str.substring(1)
|
|
22 |
|
|
23 |
def is_capitalized(str: String): Boolean =
|
|
24 |
str.length > 0 &&
|
|
25 |
Character.isUpperCase(str(0)) && str.substring(1).forall(Character.isLowerCase(_))
|
|
26 |
|
|
27 |
def is_all_caps(str: String): Boolean =
|
|
28 |
str.length > 0 && str.forall(Character.isUpperCase(_))
|
|
29 |
|
|
30 |
def plain_words(str: String): String =
|
|
31 |
space_explode('_', str).mkString(" ")
|
|
32 |
}
|
|
33 |
|