KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > lexer > TokenUtilities


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.lexer;
21
22 import org.netbeans.lib.editor.util.CharSequenceUtilities;
23
24 /**
25  * Various utility methods related to token text.
26  *
27  * @author Miloslav Metelka
28  * @version 1.00
29  */

30
31 public final class TokenUtilities {
32
33     private TokenUtilities() {
34         // no instances
35
}
36
37     /**
38      * Test whether the given character sequences represent
39      * the same text content.
40      *
41      * @param text1 non-null text to be compared to the other text parameter.
42      * @param text2 non-null text to be compared to the previous text parameter.
43      * @return <code>true</code> if the given character sequences represent
44      * the same text content.
45      */

46     public static boolean equals(CharSequence JavaDoc text1, CharSequence JavaDoc text2) {
47         return CharSequenceUtilities.textEquals(text1, text2);
48     }
49     
50     /**
51      * Implementation of {@link String#indexOf(int)} for character sequences.
52      */

53     public static int indexOf(CharSequence JavaDoc text, int ch) {
54         return CharSequenceUtilities.indexOf(text, ch);
55     }
56
57     /**
58      * Implementation of {@link String#indexOf(int,int)} for character sequences.
59      */

60     public static int indexOf(CharSequence JavaDoc text, int ch, int fromIndex) {
61         return CharSequenceUtilities.indexOf(text, ch, fromIndex);
62     }
63     
64     /**
65      * Implementation of {@link String#indexOf(String)} for character sequences.
66      */

67     public static int indexOf(CharSequence JavaDoc text, CharSequence JavaDoc seq) {
68         return CharSequenceUtilities.indexOf(text, seq);
69     }
70
71     /**
72      * Implementation of {@link String#indexOf(String,int)} for character sequences.
73      */

74     public static int indexOf(CharSequence JavaDoc text, CharSequence JavaDoc seq, int fromIndex) {
75         return CharSequenceUtilities.indexOf(text, seq, fromIndex);
76     }
77
78     /**
79      * Implementation of {@link String#lastIndexOf(String)} for character sequences.
80      */

81     public static int lastIndexOf(CharSequence JavaDoc text, CharSequence JavaDoc seq) {
82         return CharSequenceUtilities.lastIndexOf(text, seq);
83     }
84     
85     /**
86      * Implementation of {@link String#lastIndexOf(String,int)} for character sequences.
87      */

88     public static int lastIndexOf(CharSequence JavaDoc text, CharSequence JavaDoc seq, int fromIndex) {
89         return CharSequenceUtilities.lastIndexOf(text, seq, fromIndex);
90     }
91
92     /**
93      * Implementation of {@link String#lastIndexOf(int)} for character sequences.
94      */

95     public static int lastIndexOf(CharSequence JavaDoc text, int ch) {
96     return CharSequenceUtilities.lastIndexOf(text, ch);
97     }
98
99     /**
100      * Implementation of {@link String#lastIndexOf(int,int)} for character sequences.
101      */

102     public static int lastIndexOf(CharSequence JavaDoc text, int ch, int fromIndex) {
103         return CharSequenceUtilities.lastIndexOf(text, ch, fromIndex);
104     }
105
106     /**
107      * Implementation of {@link String#startsWith(String)} for character sequences.
108      */

109     public static boolean startsWith(CharSequence JavaDoc text, CharSequence JavaDoc prefix) {
110         return CharSequenceUtilities.startsWith(text, prefix);
111     }
112     
113     /**
114      * Implementation of {@link String#endsWith(String)} for character sequences.
115      */

116     public static boolean endsWith(CharSequence JavaDoc text, CharSequence JavaDoc suffix) {
117         return CharSequenceUtilities.endsWith(text, suffix);
118     }
119
120     /**
121      * Implementation of {@link String#trim()} for character sequences.
122      */

123     public static CharSequence JavaDoc trim(CharSequence JavaDoc text) {
124         return CharSequenceUtilities.trim(text);
125     }
126
127     /**
128      * Return the given text as String
129      * translating the special characters (and '\') into escape sequences.
130      *
131      * @param text non-null text to be debugged.
132      * @return non-null string containing the debug text.
133      */

134     public static String JavaDoc debugText(CharSequence JavaDoc text) {
135         return CharSequenceUtilities.debugText(text);
136     }
137
138 }
139
Popular Tags