KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > ldif > parser > LdifToken


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.ldif.parser;
22
23
24 public class LdifToken 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 COMMENT = 1;
36
37     public static final int SEP = 2;
38
39     public static final int VERSION_SPEC = 4;
40
41     public static final int NUMBER = 5;
42
43     public static final int OID = 6;
44
45     public static final int DN_SPEC = 11;
46
47     public static final int DN = 12;
48
49     public static final int ATTRIBUTE = 21;
50
51     public static final int VALUE_TYPE_SAFE = 22;
52
53     public static final int VALUE_TYPE_BASE64 = 23;
54
55     public static final int VALUE_TYPE_URL = 24;
56
57     public static final int VALUE = 27;
58
59     public static final int CHANGETYPE_SPEC = 30;
60
61     public static final int CHANGETYPE_ADD = 31;
62
63     public static final int CHANGETYPE_DELETE = 32;
64
65     public static final int CHANGETYPE_MODIFY = 33;
66
67     public static final int CHANGETYPE_MODDN = 34;
68
69     public static final int MODTYPE_ADD_SPEC = 41;
70
71     public static final int MODTYPE_DELETE_SPEC = 42;
72
73     public static final int MODTYPE_REPLACE_SPEC = 43;
74
75     public static final int MODTYPE_SEP = 45; //
76

77     public static final int CONTROL_SPEC = 51; // control:FILL
78

79     public static final int CONTROL_LDAPOID = 52; //
80

81     public static final int CONTROL_CRITICALITY_TRUE = 53; // FILLtrue
82

83     public static final int CONTROL_CRITICALITY_FALSE = 54; // FILLfalse
84

85     public static final int MODDN_NEWRDN_SPEC = 61;
86
87     public static final int MODDN_DELOLDRDN_SPEC = 63;
88
89     public static final int MODDN_NEWSUPERIOR_SPEC = 65;
90
91     private int offset;
92
93     private int type;
94
95     private String JavaDoc value;
96
97
98     public LdifToken( int type, String JavaDoc value, int offset )
99     {
100         this.type = type;
101         this.value = value;
102         this.offset = offset;
103     }
104
105
106     /**
107      * Returns the start position of the token in the original ldif
108      *
109      * @return the start positon of the token
110      */

111     public int getOffset()
112     {
113         return this.offset;
114     }
115
116
117     /**
118      * Returns the length of the token in the original ldif
119      *
120      * @return the length of the token
121      */

122     public int getLength()
123     {
124         return this.value.length();
125     }
126
127
128     public int getType()
129     {
130         return this.type;
131     }
132
133
134     public String JavaDoc getValue()
135     {
136         return this.value;
137     }
138
139
140     public String JavaDoc toString()
141     {
142         return "(type=" + this.type + ") " + "(offset=" + this.offset + ") " + "(length=" + this.getLength() + ") '"
143             + this.value + "'";
144     }
145
146
147     public int compareTo( Object JavaDoc o )
148     {
149         if ( o instanceof LdifToken )
150         {
151             LdifToken token = ( LdifToken ) o;
152             return this.offset - token.offset;
153         }
154         else
155         {
156             throw new ClassCastException JavaDoc( "Not instanceof LdifToken: " + o.getClass().getName() );
157         }
158     }
159
160 }
161
Popular Tags