Here you can find the source of toLowerCase(char[] word, char[] buffer)
buffer
.
Parameter | Description |
---|---|
word | The word to be converted to lower case. |
buffer | The buffer where the result should be saved. |
Parameter | Description |
---|---|
AssertionError | If <code>buffer</code> is smaller than <code>word</code>. |
true
if at least one character was changed between word
and buffer
. false
indicates an identical copy.
public static boolean toLowerCase(char[] word, char[] buffer)
//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; } }