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  package org.apache.directory.server.core.schema;
21  
22  
23  import org.apache.directory.server.constants.ServerDNConstants;
24  import org.apache.directory.server.schema.bootstrap.Schema;
25  
26  
27  /**
28   * An abstract schema class.
29   *
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   * @version $Rev$
32   */
33  public abstract class AbstractSchema implements Schema
34  {
35      private static final String[] NONE = new String[0];
36      private static final String DEFAULT_OWNER = ServerDNConstants.ADMIN_SYSTEM_DN;
37      
38      private boolean disabled;
39      private String[] dependencies;
40      private String owner;
41      private String name;
42      
43      
44      public AbstractSchema( String name )
45      {
46          this( name, null, null, false );
47      }
48      
49          
50      public AbstractSchema( String name, String owner )
51      {
52          this( name, owner, null, false );
53      }
54      
55          
56      public AbstractSchema( String name, String owner, String[] dependencies )
57      {
58          this( name, owner, dependencies, false );
59      }
60      
61          
62      public AbstractSchema( String name, String owner, String[] dependencies, boolean disabled )
63      {
64          if ( name == null )
65          {
66              throw new NullPointerException( "name cannot be null" );
67          }
68          
69          this.name = name;
70          
71          if ( owner != null )
72          {
73              this.owner = owner;
74          }
75          else
76          {
77              this.owner = DEFAULT_OWNER;
78          }
79          
80          if ( dependencies != null )
81          {
82              this.dependencies = dependencies;
83          }
84          else
85          {
86              this.dependencies = NONE;
87          }
88          
89          this.disabled = disabled;
90      }
91      
92      
93      public String[] getDependencies()
94      {
95          String[] copy = new String[dependencies.length];
96          System.arraycopy( dependencies, 0, copy, 0, dependencies.length );
97          return copy;
98      }
99  
100     
101     public String getOwner()
102     {
103         return owner;
104     }
105 
106     
107     public String getSchemaName()
108     {
109         return name;
110     }
111     
112     
113     public boolean isDisabled()
114     {
115         return disabled;
116     }
117 }