Sharkysoft home

lava.clib
Class Ctype

java.lang.Object
  |
  +--lava.clib.Ctype

public final class Ctype
extends java.lang.Object

Ports of ctype functions.

Details: Ctype is port of the ctype library from the C programming language. By emulating many of the C language's ctype library functions, this class lets die-hard C programmers write Java code without completely converting to the Java API. Rather than wasting valuable time figuring out how to perform the Java equivalent of tasks that are easy in C, the programmer can simply use the methods in this class instead.

This class also contains some additional functions that have similar features.


Method Summary
static boolean isalnum(int c)
          Returns true if c is alphanumeric.
static boolean isalpha(int c)
          Returns true if c is a letter.
static boolean isascii(int c)
          Returns true if c is any ASCII character.
static boolean iscntrl(int c)
          Returns true if c is a control character.
static boolean isdigit(int c)
          Returns true if c is a decimal digit.
static boolean isendline(int c)
          Returns true if c is an ASCII end-of-line character.
static boolean isgraph(int c)
          Returns true if c is a visible character.
static boolean ishspace(int c)
          Tests for horizontal space.
static boolean islower(int c)
          Returns true if c is a lowercase letter.
static boolean isprint(int c)
          Returns true if c is a printing character.
static boolean ispunct(int c)
          Returns true if c is a punctuation character.
static boolean isspace(int c)
          Returns true if c is a character that creates "white space" in displayed text.
static boolean isupper(int c)
          Returns true if c is an uppercase letter.
static boolean isvspace(int c)
          Tests for vertical space.
static boolean isxdigit(int c)
          Returns true if c is a hexadecimal digit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isalpha

public static boolean isalpha(int c)
Returns true if c is a letter. Returns the result of Character.isLetter(c).

isupper

public static boolean isupper(int c)
Returns true if c is an uppercase letter. Returns the result of Character.isUpperCase(c).

islower

public static boolean islower(int c)
Returns true if c is a lowercase letter. Returns the result of Character.isLowerCase(c).

isdigit

public static boolean isdigit(int c)
Returns true if c is a decimal digit. Returns the result of Character.isDigit(c).

isxdigit

public static boolean isxdigit(int c)
Returns true if c is a hexadecimal digit. True if c is in {0-9, A-F, a-f}.

isalnum

public static boolean isalnum(int c)
Returns true if c is alphanumeric. Specifically, returns the result of Character.isLetterOrDigit(c).

isspace

public static boolean isspace(int c)
Returns true if c is a character that creates "white space" in displayed text. Specifically, returns Character.isWhitespace(c).

ispunct

public static boolean ispunct(int c)
Returns true if c is a punctuation character. For ASCII values, a punctuation mark is any printing character except the space character (040), digits, letters. For Unicode values, a punctuation mark is any character in the following classes (see java.lang.Character):


isprint

public static boolean isprint(int c)
Returns true if c is a printing character. For ASCII values, c is a printing character if and only if c is in {32..127}. This method does not support Unicode values, but it may in the future.

isgraph

public static boolean isgraph(int c)
Returns true if c is a visible character. For ASCII values, c is a printing character if and only if c is in {33..127}. This method does not support Unicode values, but it may in the future.

iscntrl

public static boolean iscntrl(int c)
Returns true if c is a control character. c is a control character if and only if c is in {0..31, 127}. This method does not support Unicode values, but it may in the future.

isascii

public static boolean isascii(int c)
Returns true if c is any ASCII character. c is an ASCII character if an only if c is in {0..127}.

isvspace

public static boolean isvspace(int c)
Tests for vertical space.

Details: isvspace returns true if the given character (c) is a vertical space. The criteria for determining this is as follows (in order of precedence):

  1. Characters '\n', '\v', '\f', '\r' are vertical spaces.
  2. Other characters below 256 are not.
  3. No character that is not a white space according to Character.isWhitespace can be a vertical space.
  4. Characters belonging to the unicode types:
    • LINE_SEPARATOR
    • PARAGRAPH_SEPARATOR
    are vertical spaces.
  5. All other characters are not vertical spaces.
Parameters:
c - the character to test
Returns:
true iff c is a vertical space
Since:
1998

ishspace

public static boolean ishspace(int c)
Tests for horizontal space.

Details: ishspace returns true if and only if the given character is a horizontal space. The test is conducted as follows:

  1. Characters ' ' and '\t' are horizontal spaces.
  2. All other characters, including the so-called no-break spaces, are not.

There may be other unicode characters that can be considered horizontal spaces. If you discover any, please let the author know and the test will be patched in a future release.

Parameters:
c - the character to test
Returns:
true iff c is a horizontal space
Since:
1998

isendline

public static boolean isendline(int c)
Returns true if c is an ASCII end-of-line character. An end-of-line character is one of {'\n', '\r'}.

Sharkysoft home