01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.apache.naming.core;
18:
19: import javax.naming.directory.DirContext;
20:
21: /**
22: * Utility class providing additional operations on DirContexts.
23: * Instead of extending DirContext we use a helper who will work
24: * on any context, including 'foreign' ones ( like JNDI, etc ).
25: *
26: * Typical methods - conversions ( int, boolean), etc.
27: *
28: * This code should check if the context extend our BaseDirContext
29: * and use specific features ( like notes - to cache the conversion
30: * results for example ), but fallback for external contexts.
31: *
32: * @author Costin Manolache
33: */
34: public class DirContextHelper {
35: static DirContextHelper instance = new DirContextHelper();
36:
37: public static DirContextHelper getInstance() {
38: return instance;
39: }
40:
41: /** Debugging string - the context, imediate childs and attributes
42: */
43: public String toString(DirContext ctx) {
44: return "";
45: }
46:
47: public int getIntAttribute(DirContext ctx, String name) {
48: return 0;
49: }
50:
51: public long getLongAttribute(DirContext ctx, String name) {
52: return 0;
53: }
54:
55: public String getStringAttribute(DirContext ctx, String name) {
56: return null;
57: }
58:
59: public boolean getBooleanAttribute(DirContext ctx, String name) {
60: return false;
61: }
62: }
|