KickJava   Java API By Example, From Geeks To Geeks.

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


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
26
27 public class LdifChangeTypeLine extends LdifValueLineBase
28 {
29
30     private static final long serialVersionUID = 8613980677301250589L;
31
32
33     protected LdifChangeTypeLine()
34     {
35     }
36
37
38     public LdifChangeTypeLine( int offset, String JavaDoc rawChangeTypeSpec, String JavaDoc rawValueType, String JavaDoc rawChangeType,
39         String JavaDoc rawNewLine )
40     {
41         super( offset, rawChangeTypeSpec, rawValueType, rawChangeType, rawNewLine );
42     }
43
44
45     public String JavaDoc getRawChangeTypeSpec()
46     {
47         return super.getRawLineStart();
48     }
49
50
51     public String JavaDoc getUnfoldedChangeTypeSpec()
52     {
53         return super.getUnfoldedLineStart();
54     }
55
56
57     public String JavaDoc getRawChangeType()
58     {
59         return super.getRawValue();
60     }
61
62
63     public String JavaDoc getUnfoldedChangeType()
64     {
65         return super.getUnfoldedValue();
66     }
67
68
69     public String JavaDoc toRawString()
70     {
71         return super.toRawString();
72     }
73
74
75     public boolean isAdd()
76     {
77         return this.getUnfoldedChangeType().equals( "add" );
78     }
79
80
81     public boolean isDelete()
82     {
83         return this.getUnfoldedChangeType().equals( "delete" );
84     }
85
86
87     public boolean isModify()
88     {
89         return this.getUnfoldedChangeType().equals( "modify" );
90     }
91
92
93     public boolean isModDn()
94     {
95         return this.getUnfoldedChangeType().equals( "moddn" ) || this.getUnfoldedChangeType().equals( "modrdn" );
96     }
97
98
99     public boolean isValid()
100     {
101         return super.isValid();
102     }
103
104
105     public String JavaDoc getInvalidString()
106     {
107         if ( this.getUnfoldedChangeTypeSpec().length() == 0 )
108         {
109             return "Missing spec 'changetype'";
110         }
111         else if ( this.getUnfoldedChangeType().length() == 0 )
112         {
113             return "Missing changetype";
114         }
115         else
116         {
117             return super.getInvalidString();
118         }
119     }
120
121
122     public static LdifChangeTypeLine createDelete()
123     {
124         return new LdifChangeTypeLine( 0, "changetype", ":", "delete", BrowserCoreConstants.LINE_SEPARATOR );
125     }
126
127
128     public static LdifChangeTypeLine createAdd()
129     {
130         return new LdifChangeTypeLine( 0, "changetype", ":", "add", BrowserCoreConstants.LINE_SEPARATOR );
131     }
132
133
134     public static LdifChangeTypeLine createModify()
135     {
136         return new LdifChangeTypeLine( 0, "changetype", ":", "modify", BrowserCoreConstants.LINE_SEPARATOR );
137     }
138
139
140     public static LdifChangeTypeLine createModDn()
141     {
142         return new LdifChangeTypeLine( 0, "changetype", ":", "moddn", BrowserCoreConstants.LINE_SEPARATOR );
143     }
144
145
146     public static LdifChangeTypeLine createModRdn()
147     {
148         return new LdifChangeTypeLine( 0, "changetype", ":", "modrdn", BrowserCoreConstants.LINE_SEPARATOR );
149     }
150
151 }
152
Popular Tags