KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > VariablesViewModelPresentation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui;
12
13
14 import java.util.StringTokenizer JavaDoc;
15
16 public class VariablesViewModelPresentation extends DelegatingModelPresentation {
17
18     /**
19      * @see DelegatingModelPresentation#getText(Object)
20      *
21      * Strips out control characters and replaces them with string representations
22      */

23     public String JavaDoc getText(Object JavaDoc element) {
24         StringBuffer JavaDoc string= new StringBuffer JavaDoc();
25         StringTokenizer JavaDoc tokenizer= new StringTokenizer JavaDoc(super.getText(element), "\b\f\n\r\t\\", true); //$NON-NLS-1$
26
String JavaDoc token;
27         while (tokenizer.hasMoreTokens()) {
28             token= tokenizer.nextToken();
29             if (token.length() > 1) {
30                 string.append(token);
31             } else {
32                 switch (token.charAt(0)) {
33                     case '\b':
34                         string.append("\\b"); //$NON-NLS-1$
35
break;
36                     case '\f':
37                         string.append("\\f"); //$NON-NLS-1$
38
break;
39                     case '\n':
40                         string.append("\\n"); //$NON-NLS-1$
41
break;
42                     case '\r':
43                         string.append("\\r"); //$NON-NLS-1$
44
break;
45                     case '\t':
46                         string.append("\\t"); //$NON-NLS-1$
47
break;
48                     case '\\':
49                         string.append("\\\\"); //$NON-NLS-1$
50
break;
51                     default:
52                         string.append(token);
53                 }
54             }
55         }
56         return string.toString();
57     }
58
59 }
60
Popular Tags