KickJava   Java API By Example, From Geeks To Geeks.

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


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;
22
23
24 public final class LdifInvalidPart implements LdifPart
25 {
26
27     private static final long serialVersionUID = 3107136058896890735L;
28
29     private int offset;
30
31     private String JavaDoc unknown;
32
33
34     protected LdifInvalidPart()
35     {
36     }
37
38
39     public LdifInvalidPart( int offset, String JavaDoc unknown )
40     {
41         this.offset = offset;
42         this.unknown = unknown;
43     }
44
45
46     public final int getOffset()
47     {
48         return this.offset;
49     }
50
51
52     public final int getLength()
53     {
54         return this.toRawString().length();
55     }
56
57
58     public final String JavaDoc toRawString()
59     {
60         return this.unknown;
61     }
62
63
64     public final String JavaDoc toFormattedString()
65     {
66         return this.unknown;
67     }
68
69
70     public final String JavaDoc toString()
71     {
72         String JavaDoc text = toRawString();
73         text = text.replaceAll( "\n", "\\\\n" );
74         text = text.replaceAll( "\r", "\\\\r" );
75         return getClass().getName() + " (" + getOffset() + "," + getLength() + "): '" + text + "'";
76     }
77
78
79     public final boolean isValid()
80     {
81         return false;
82     }
83
84
85     public String JavaDoc getInvalidString()
86     {
87         return "Unexpected Token";
88     }
89
90
91     public final void adjustOffset( int adjust )
92     {
93         this.offset += adjust;
94     }
95
96 }
97
Popular Tags