KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > misc > TokenizerParams


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/util/misc/TokenizerParams.java,v 1.3 2005/12/25 03:51:56 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:51:56 $
28  */

29  
30 package com.sun.appserv.management.util.misc;
31
32
33 /**
34     Parameters that TokenizerImpl accepts.
35  */

36 public class TokenizerParams
37 {
38     /**
39         Delimiters are characters that separate tokens.
40      */

41     public String JavaDoc mDelimiters;
42     
43     /**
44         When multiple delimiters abut each other, are they all treated as
45         a single delimiter, or as multiples with implied empty tokens
46         between them?
47      */

48     public boolean mMultipleDelimsCountAsOne;
49     
50     /**
51         The escape char, allowed to be anything, but typically should
52         be BACKSLASH.
53      */

54     public char mEscapeChar;
55     
56     /**
57         Characters which may be escaped over and above the standard ones.
58      */

59     public String JavaDoc mEscapableChars;
60     
61     /**
62         When an invalid escape sequence is encountered, either an exception
63         may be thrown, or the sequence may be emitted literally.
64      */

65     public boolean mEmitInvalidEscapeSequencesLiterally;
66     
67     public final static char BACKSLASH = '\\';
68     public final static char COMMA = ',';
69     public final static char DEFAULT_ESCAPE_CHAR = BACKSLASH;
70     public final static String JavaDoc DEFAULT_DELIMITERS = "" + COMMA;
71     
72         public
73     TokenizerParams()
74     {
75         mDelimiters = DEFAULT_DELIMITERS;
76         mMultipleDelimsCountAsOne = true;
77         mEscapeChar = DEFAULT_ESCAPE_CHAR;
78         mEscapableChars = "" + DEFAULT_ESCAPE_CHAR;
79         mEmitInvalidEscapeSequencesLiterally = false;
80     }
81     
82         public void
83     ensureDelimitersEscapable()
84     {
85         for( int i = 0; i < mDelimiters.length(); ++i )
86         {
87             final char delim = mDelimiters.charAt( i );
88             
89             if ( mEscapableChars.indexOf( delim ) < 0 )
90             {
91                 mEscapableChars = mEscapableChars + delim;
92             }
93         }
94     }
95 }
96
97
Popular Tags