Indicates if the given character is a comment text. - Java java.lang

Java examples for java.lang:char

Description

Indicates if the given character is a comment text.

Demo Code


//package com.java2s;

public class Main {
    /**//from   w w  w. j a va2  s.co  m
     * Indicates if the given character is a comment text. It means {@link #isText(int)} returns true and the character is not '(' or ')'.
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is a quoted text.
     */
    public static boolean isCommentText(int character) {
        return isText(character) && (character != '(')
                && (character != ')');
    }

    /**
     * Indicates if the given character is textual (ISO Latin 1 and not a control character).
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is textual.
     */
    public static boolean isText(int character) {
        return isLatin1Char(character) && !isControlChar(character);
    }

    /**
     * Indicates if the given character is in ISO Latin 1 (8859-1) range. Note that this range is a superset of ASCII and a subrange of Unicode (UTF-8).
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is in ISO Latin 1 range.
     */
    public static boolean isLatin1Char(int character) {
        return (character >= 0) && (character <= 255);
    }

    /**
     * Indicates if the given character is a control character.
     * 
     * @param character
     *            The character to test.
     * @return True if the given character is a control character.
     */
    public static boolean isControlChar(int character) {
        return ((character >= 0) && (character <= 31))
                || (character == 127);
    }
}

Related Tutorials