View Javadoc

1   /*
2    * Copyright 2005,2009 Ivan SZKIBA
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.ini4j;
17  
18  import org.ini4j.Registry.Key;
19  
20  class BasicRegistryKey extends BasicProfileSection implements Registry.Key
21  {
22      private static final long serialVersionUID = -1390060044244350928L;
23      private static final String META_TYPE = "type";
24  
25      public BasicRegistryKey(BasicRegistry registry, String name)
26      {
27          super(registry, name);
28      }
29  
30      @Override public Key getChild(String key)
31      {
32          return (Key) super.getChild(key);
33      }
34  
35      @Override public Key getParent()
36      {
37          return (Key) super.getParent();
38      }
39  
40      @Override public Registry.Type getType(Object key)
41      {
42          return (Registry.Type) getMeta(META_TYPE, key);
43      }
44  
45      @Override public Registry.Type getType(Object key, Registry.Type defaultType)
46      {
47          Registry.Type type = getType(key);
48  
49          return (type == null) ? defaultType : type;
50      }
51  
52      @Override public Key addChild(String key)
53      {
54          return (Key) super.addChild(key);
55      }
56  
57      @Override public Key lookup(String... path)
58      {
59          return (Key) super.lookup(path);
60      }
61  
62      @Override public Registry.Type putType(String key, Registry.Type type)
63      {
64          return (Registry.Type) putMeta(META_TYPE, key, type);
65      }
66  
67      @Override public Registry.Type removeType(Object key)
68      {
69          return (Registry.Type) removeMeta(META_TYPE, key);
70      }
71  }