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 17package android.text.method; 18 19import android.graphics.Rect; 20import android.text.GetChars; 21import android.text.Spanned; 22import android.text.SpannedString; 23import android.text.TextUtils; 24import android.view.View; 25 26/** 27 * This transformation method causes any carriage return characters (\r) 28 * to be hidden by displaying them as zero-width non-breaking space 29 * characters (\uFEFF). 30 */ 31public class HideReturnsTransformationMethod 32extends ReplacementTransformationMethod { 33 private static char[] ORIGINAL = new char[] { '\r' }; 34 private static char[] REPLACEMENT = new char[] { '\uFEFF' }; 35 36 /** 37 * The character to be replaced is \r. 38 */ 39 protected char[] getOriginal() { 40 return ORIGINAL; 41 } 42 43 /** 44 * The character that \r is replaced with is \uFEFF. 45 */ 46 protected char[] getReplacement() { 47 return REPLACEMENT; 48 } 49 50 public static HideReturnsTransformationMethod getInstance() { 51 if (sInstance != null) 52 return sInstance; 53 54 sInstance = new HideReturnsTransformationMethod(); 55 return sInstance; 56 } 57 58 private static HideReturnsTransformationMethod sInstance; 59} 60