Here you can find the source of negate(String value)
Parameter | Description |
---|---|
value | the input string; may not be null |
protected static String negate(String value)
//package com.java2s; /*/*from ww w . j a v a2 s .c om*/ * ModeShape (http://www.modeshape.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Compute the "negated" string, which replaces the digits (0 becomes 9, 1 becomes 8, ... and 9 becomes 0). * * @param value the input string; may not be null * @return the negated string; never null * @see #negate(StringBuilder) */ protected static String negate(String value) { return negate(new StringBuilder(value)).toString(); } /** * Compute the "negated" string, which replaces the digits (0 becomes 9, 1 becomes 8, ... and 9 becomes 0). * * @param value the input string; may not be null * @return the negated string; never null * @see #negate(String) */ protected static StringBuilder negate(StringBuilder value) { for (int i = 0, len = value.length(); i != len; ++i) { char c = value.charAt(i); if (c == ' ' || c == '-') continue; value.setCharAt(i, (char) ('9' - c + '0')); } return value; } }