KickJava   Java API By Example, From Geeks To Geeks.

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


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.lines;
22
23
24 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
25 import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
26
27
28 public class LdifDnLine extends LdifValueLineBase
29 {
30
31     private static final long serialVersionUID = 6180172049870560007L;
32
33
34     protected LdifDnLine()
35     {
36     }
37
38
39     public LdifDnLine( int offset, String JavaDoc rawDnSpec, String JavaDoc rawValueType, String JavaDoc rawDn, String JavaDoc rawNewLine )
40     {
41         super( offset, rawDnSpec, rawValueType, rawDn, rawNewLine );
42     }
43
44
45     public String JavaDoc getRawDnSpec()
46     {
47         return super.getRawLineStart();
48     }
49
50
51     public String JavaDoc getUnfoldedDnSpec()
52     {
53         return super.getUnfoldedLineStart();
54     }
55
56
57     public String JavaDoc getRawDn()
58     {
59         return super.getRawValue();
60     }
61
62
63     public String JavaDoc getUnfoldedDn()
64     {
65         return super.getUnfoldedValue();
66     }
67
68
69     public String JavaDoc toRawString()
70     {
71         return super.toRawString();
72     }
73
74
75     public boolean isValid()
76     {
77         return super.isValid();
78     }
79
80
81     public String JavaDoc getInvalidString()
82     {
83         if ( this.getUnfoldedDnSpec().length() == 0 )
84         {
85             return "Missing DN spec 'dn'";
86         }
87         else if ( this.getUnfoldedDn().length() == 0 )
88         {
89             return "Missing DN";
90         }
91         else
92         {
93             return super.getInvalidString();
94         }
95     }
96
97
98     public static LdifDnLine create( String JavaDoc dn )
99     {
100         if ( LdifUtils.mustEncode( dn ) )
101         {
102             return new LdifDnLine( 0, "dn", "::", LdifUtils.base64encode( LdifUtils.utf8encode( dn ) ),
103                 BrowserCoreConstants.LINE_SEPARATOR );
104         }
105         else
106         {
107             return new LdifDnLine( 0, "dn", ":", dn, BrowserCoreConstants.LINE_SEPARATOR );
108         }
109     }
110
111 }
112
Popular Tags