KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.Serializable JavaDoc;
25
26 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
27 import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
28
29
30 public class LdifAttrValLine extends LdifValueLineBase implements Serializable JavaDoc
31 {
32
33     private static final long serialVersionUID = 2818131653565822685L;
34
35
36     protected LdifAttrValLine()
37     {
38     }
39
40
41     public LdifAttrValLine( int offset, String JavaDoc attributeDescripton, String JavaDoc valueType, String JavaDoc value, String JavaDoc newLine )
42     {
43         super( offset, attributeDescripton, valueType, value, newLine );
44     }
45
46
47     public String JavaDoc getRawAttributeDescription()
48     {
49         return super.getRawLineStart();
50     }
51
52
53     public String JavaDoc getUnfoldedAttributeDescription()
54     {
55         return super.getUnfoldedLineStart();
56     }
57
58
59     public boolean isValid()
60     {
61         return super.isValid();
62     }
63
64
65     public String JavaDoc getInvalidString()
66     {
67         if ( this.getUnfoldedAttributeDescription().length() == 0 )
68         {
69             return "Missing attribute name";
70         }
71         else
72         {
73             return super.getInvalidString();
74         }
75     }
76
77
78     public static LdifAttrValLine create( String JavaDoc name, String JavaDoc value )
79     {
80         if ( LdifUtils.mustEncode( value ) )
81         {
82             return create( name, LdifUtils.utf8encode( value ) );
83         }
84         else
85         {
86             return new LdifAttrValLine( 0, name, ":", value, BrowserCoreConstants.LINE_SEPARATOR );
87         }
88     }
89
90
91     public static LdifAttrValLine create( String JavaDoc name, byte[] value )
92     {
93         return new LdifAttrValLine( 0, name, "::", LdifUtils.base64encode( value ), BrowserCoreConstants.LINE_SEPARATOR );
94     }
95
96 }
97
Popular Tags