1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.text.method; 18 19 /** 20 * This transformation method causes any newline characters (\n) to be 21 * displayed as spaces instead of causing line breaks, and causes 22 * carriage return characters (\r) to have no appearance. 23 */ 24 @android.ravenwood.annotation.RavenwoodKeepWholeClass 25 public class SingleLineTransformationMethod 26 extends ReplacementTransformationMethod { 27 private static char[] ORIGINAL = new char[] { '\n', '\r' }; 28 private static char[] REPLACEMENT = new char[] { ' ', '\uFEFF' }; 29 30 /** 31 * The characters to be replaced are \n and \r. 32 */ getOriginal()33 protected char[] getOriginal() { 34 return ORIGINAL; 35 } 36 37 /** 38 * The character \n is replaced with is space; 39 * the character \r is replaced with is FEFF (zero width space). 40 */ getReplacement()41 protected char[] getReplacement() { 42 return REPLACEMENT; 43 } 44 getInstance()45 public static SingleLineTransformationMethod getInstance() { 46 if (sInstance != null) 47 return sInstance; 48 49 sInstance = new SingleLineTransformationMethod(); 50 return sInstance; 51 } 52 53 private static SingleLineTransformationMethod sInstance; 54 } 55