KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > internal > model > Entry


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.internal.model;
22
23
24 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
25 import org.apache.directory.ldapstudio.browser.core.model.DN;
26 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
27 import org.apache.directory.ldapstudio.browser.core.model.IEntry;
28 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
29 import org.apache.directory.ldapstudio.browser.core.model.RDN;
30
31
32 public class Entry extends AbstractEntry
33 {
34
35     private static final long serialVersionUID = -4718107307581983276L;
36
37     protected RDN rdn;
38
39     protected IEntry parent;
40
41
42     protected Entry()
43     {
44     }
45
46
47     public Entry( IEntry parent, RDN rdn ) throws ModelModificationException
48     {
49         super();
50
51         if ( parent == null )
52         {
53             throw new ModelModificationException( BrowserCoreMessages.model__empty_entry );
54         }
55         if ( rdn == null )
56         {
57             throw new ModelModificationException( BrowserCoreMessages.model__empty_rdn );
58         }
59         if ( "".equals( rdn.toString() ) ) { //$NON-NLS-1$
60
throw new ModelModificationException( BrowserCoreMessages.model__empty_rdn );
61         }
62
63         this.parent = parent;
64         this.rdn = rdn;
65     }
66
67
68     // performance opt.
69
public RDN getRdn()
70     {
71         return this.rdn;
72     }
73
74
75     public DN getDn()
76     {
77         DN dn = new DN( new RDN( this.rdn ), this.parent.getDn() );
78         return dn;
79     }
80
81
82     public IEntry getParententry()
83     {
84         return this.parent;
85     }
86
87
88     public IConnection getConnection()
89     {
90         return this.getParententry().getConnection();
91     }
92
93
94     protected void setRdn( RDN newRdn )
95     {
96         this.rdn = newRdn;
97     }
98
99
100     protected void setParent( IEntry newParent )
101     {
102         this.parent = newParent;
103     }
104
105 }
106
Popular Tags