Java Char Lower Case toLowerCase(char[] word, char[] buffer)

Here you can find the source of toLowerCase(char[] word, char[] buffer)

Description

Convert to lower case (character-by-character) and save the result into buffer.

License

Open Source License

Parameter

Parameter Description
word The word to be converted to lower case.
buffer The buffer where the result should be saved.

Exception

Parameter Description
AssertionError If <code>buffer</code> is smaller than <code>word</code>.

Return

Returns true if at least one character was changed between word and buffer. false indicates an identical copy.

Declaration

public static boolean toLowerCase(char[] word, char[] buffer) 

Method Source Code

//package com.java2s;
/*// w  w w  . j  a  v  a  2s.  c om
 * Carrot2 project.
 *
 * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski.
 * All rights reserved.
 *
 * Refer to the full license file "carrot2.LICENSE"
 * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */

public class Main {
    /**
     * Convert to lower case (character-by-character) and save the result
     * into <code>buffer</code>. 
     * 
     * @param word The word to be converted to lower case.
     * @param buffer The buffer where the result should be saved.
     * @return Returns <code>true</code> if at least one character was changed
     * between <code>word</code> and <code>buffer</code>. <code>false</code> indicates
     * an identical copy.
     * @throws AssertionError If <code>buffer</code> is smaller than <code>word</code>.
     */
    public static boolean toLowerCase(char[] word, char[] buffer) {
        return toLowerCase(word, buffer, 0, word.length);
    }

    /**
     * Convert to lower case (character-by-character) and save the result
     * into <code>buffer</code>. The buffer must have at least <code>length</code>
     * characters.
     * 
     * @param word The word to be converted to lower case.
     * @param buffer The buffer where the result should be saved.
     * @param start the index in the <code>word</code> at which to start
     * @param length the number of characters from <code>word</code> to process
     * @return Returns <code>true</code> if at least one character was changed
     * between <code>word</code> and <code>buffer</code>. <code>false</code> indicates
     * an identical copy.
     * @throws AssertionError If <code>buffer</code> is smaller than <code>length</code>.
     * @throws AssertionError If <code>start + length</code> is smaller than the length <code>word</code>.
     */
    public static boolean toLowerCase(char[] word, char[] buffer, int start, int length) {
        assert buffer.length >= length : "Buffer too small.";
        assert start + length <= word.length : "Word too short.";
        assert start >= 0 : "Start must be >= 0";

        boolean different = false;
        char in, out;
        for (int i = length; --i >= 0;) {
            buffer[i] = out = Character.toLowerCase(in = word[i + start]);
            different |= (in != out);
        }
        return different;
    }
}

Related

  1. toLowerCase(char ch)
  2. toLowerCase(char ch)
  3. toLowerCase(char[] chars)
  4. toLowerCase(char[] cs)
  5. toLowerCase(char[] input)
  6. toLowerCase(CharSequence chars)
  7. toLowerCase(CharSequence string)
  8. toLowerCase(final char a)
  9. toLowerCase(final char a)