Java Char Capitalized Check isCapitalized(char[] token, int start, int end)

Here you can find the source of isCapitalized(char[] token, int start, int end)

Description

Weak check if a token is capitalized - starts with capital letter and next letter is lower case

License

Open Source License

Parameter

Parameter Description
token a parameter
start a parameter
end a parameter

Declaration

public static boolean isCapitalized(char[] token, int start, int end) 

Method Source Code

//package com.java2s;
/**/*from   w  w w  .j  a  va  2  s . c o m*/
 *  ClusteringWiki - personalized and collaborative clustering of search results
 *  Copyright (C) 2010  Texas State University-San Marcos
 *  
 *  Contact: http://dmlab.cs.txstate.edu
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Check if token is capitalized - just first two chars
     * @param token
     * @return
     */
    public static boolean isCapitalized(char[] token) {
        return isCapitalized(token, 0, token.length);
    }

    /**
     * Check if token is capitalized - just first two chars
     * @param token
     * @return
     */
    public static boolean isCapitalized(String token) {
        return isCapitalized(token.toCharArray(), 0, token.length());
    }

    /**
     * Weak check if a token is capitalized - starts with capital letter
     * and next letter is lower case
     * @param token
     * @param start
     * @param end
     * @return
     */
    public static boolean isCapitalized(char[] token, int start, int end) {
        if (end - start < 2)
            return false;
        boolean cc = Character.isLowerCase(token[start + 1]);
        return cc && Character.isUpperCase(token[start]);
    }
}