KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > filter > parser > LdapFilterToken


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.core.model.filter.parser;
22
23
24 public class LdapFilterToken implements Comparable JavaDoc
25 {
26
27     public static final int NEW = Integer.MIN_VALUE;
28
29     public static final int ERROR = -2;
30
31     public static final int EOF = -1;
32
33     public static final int UNKNOWN = 0;
34
35     public static final int WHITESPACE = 1;
36
37     public static final int LPAR = 11;
38
39     public static final int RPAR = 12;
40
41     public static final int AND = 21;
42
43     public static final int OR = 22;
44
45     public static final int NOT = 23;
46
47     public static final int ATTRIBUTE = 31;
48
49     public static final int EQUAL = 41;
50
51     public static final int APROX = 42;
52
53     public static final int GREATER = 43;
54
55     public static final int LESS = 44;
56
57     public static final int PRESENT = 45;
58
59     public static final int VALUE = 51;
60
61     public static final int ASTERISK = 52;
62
63     private int offset;
64
65     private int type;
66
67     private String JavaDoc value;
68
69
70     public LdapFilterToken( int type, String JavaDoc value, int offset )
71     {
72         this.type = type;
73         this.value = value;
74         this.offset = offset;
75     }
76
77
78     /**
79      * Returns the start position of the token in the original filter
80      *
81      * @return the start positon of the token
82      */

83     public int getOffset()
84     {
85         return this.offset;
86     }
87
88
89     /**
90      * Returns the length of the token in the original filter
91      *
92      * @return the length of the token
93      */

94     public int getLength()
95     {
96         return this.value.length();
97     }
98
99
100     public int getType()
101     {
102         return this.type;
103     }
104
105
106     public String JavaDoc getValue()
107     {
108         return this.value;
109     }
110
111
112     public String JavaDoc toString()
113     {
114         return "(" + this.offset + ") " + "(" + this.type + ") " + this.value;
115     }
116
117
118     public int compareTo( Object JavaDoc o )
119     {
120         if ( o instanceof LdapFilterToken )
121         {
122             LdapFilterToken token = ( LdapFilterToken ) o;
123             return this.offset - token.offset;
124         }
125         else
126         {
127             throw new ClassCastException JavaDoc( "Not instanceof LapFilterToken: " + o.getClass().getName() );
128         }
129     }
130
131 }
132
Popular Tags