corda/classpath/java/lang/Character.java

94 lines
2.0 KiB
Java

/* Copyright (c) 2008, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package java.lang;
public final class Character implements Comparable<Character> {
public static final Class TYPE = Class.forCanonicalName("C");
private final char value;
public Character(char value) {
this.value = value;
}
public static Character valueOf(char value) {
return new Character(value);
}
public int compareTo(Character o) {
return value - o.value;
}
public boolean equals(Object o) {
return o instanceof Character && ((Character) o).value == value;
}
public int hashCode() {
return (int) value;
}
public String toString() {
return toString(value);
}
public static String toString(char v) {
return new String(new char[] { v });
}
public char charValue() {
return value;
}
public static char toLowerCase(char c) {
if (c >= 'A' && c <= 'Z') {
return (char) ((c - 'A') + 'a');
} else {
return c;
}
}
public static char toUpperCase(char c) {
if (c >= 'a' && c <= 'z') {
return (char) ((c - 'a') + 'A');
} else {
return c;
}
}
public static boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
public static boolean isLetter(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
public static boolean isLetterOrDigit(char c) {
return isDigit(c) || isLetter(c);
}
public static boolean isLowerCase(char c) {
return (c >= 'a' && c <= 'z');
}
public static boolean isUpperCase(char c) {
return (c >= 'A' && c <= 'Z');
}
public static boolean isWhitespace(char c) {
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
public static boolean isSpaceChar(char c) {
return isWhitespace(c);
}
}