View Javadoc
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.api.ldap.model.schema.syntaxCheckers;
22  
23  
24  /**
25   * An OpenLDAP object identifier macro. 
26   * See http://www.openldap.org/doc/admin24/schema.html#OID%20Macros
27   * <br/>
28   * <code>objectIdentifier &lt;name&gt; { &lt;oid&gt; | &lt;name&gt;[:&lt;suffix&gt;] }</code>
29   * 
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   */
32  public class OpenLdapObjectIdentifierMacro
33  {
34      private String name;
35  
36      private String rawOidOrNameSuffix;
37  
38      private String resolvedOid;
39  
40  
41      /**
42       * Instantiates a new OpenLDAP object identifier macro.
43       */
44      public OpenLdapObjectIdentifierMacro()
45      {
46          name = null;
47          rawOidOrNameSuffix = null;
48          resolvedOid = null;
49      }
50  
51  
52      /**
53       * Gets the name.
54       * 
55       * @return the name
56       */
57      public String getName()
58      {
59          return name;
60      }
61  
62  
63      /**
64       * Sets the name.
65       * 
66       * @param name the new name
67       */
68      public void setName( String name )
69      {
70          this.name = name;
71      }
72  
73  
74      /**
75       * Gets the raw OID or name plus suffix.
76       * 
77       * @return the raw OID or name plus suffix
78       */
79      public String getRawOidOrNameSuffix()
80      {
81          return rawOidOrNameSuffix;
82      }
83  
84  
85      /**
86       * Sets the raw OID or name plus suffix.
87       * 
88       * @param rawOidOrNameSuffix the new raw OID or name plus suffix
89       */
90      public void setRawOidOrNameSuffix( String rawOidOrNameSuffix )
91      {
92          this.rawOidOrNameSuffix = rawOidOrNameSuffix;
93      }
94  
95  
96      /**
97       * Gets the resolved OID, null if not yet resolved.
98       * 
99       * @return the resolved OID
100      */
101     public String getResolvedOid()
102     {
103         return resolvedOid;
104     }
105 
106 
107     /**
108      * Checks if is resolved.
109      * 
110      * @return true, if is resolved
111      */
112     public boolean isResolved()
113     {
114         return getResolvedOid() != null;
115     }
116 
117 
118     /**
119      * Sets the resolved OID.
120      * 
121      * @param resolvedOid the new resolved OID
122      */
123     public void setResolvedOid( String resolvedOid )
124     {
125         this.resolvedOid = resolvedOid;
126     }
127 
128 
129     public String toString()
130     {
131         if ( isResolved() )
132         {
133             return "resolved: " + name + " " + resolvedOid;
134         }
135         else
136         {
137             return "unresolved: " + name + " " + rawOidOrNameSuffix;
138         }
139     }
140 
141 }