KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > registry > ResettableContext


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.registry;
21
22 import org.netbeans.api.registry.ContextException;
23
24 /**
25  * {@link BasicContext} extension supporting default values. If the implementation of
26  * backend storage has concept of default values it should implement also
27  * this context extension which allows examination of whether the
28  * bound object has some default value, whether current value is modified
29  * or the original one and also allows to revert the modified value to the
30  * default one.
31  *
32  * <p>If the binding name is <code>null</code> then the context is examined. The context
33  * should be considered as modified if following condition is true for it or
34  * for any of its subcontexts: some binding in the context is modified or list
35  * of subcontext is different from default one. Reverting context means that
36  * all modified bindings in the context (including the subcontexts) are reverted
37  * and all nondefault subcontexts are destroyed.
38  *
39  * @author David Konecny
40  */

41 public interface ResettableContext extends BasicContext {
42
43     /**
44      * Exist a default value?
45      *
46      * @param bindingName the binding name or null for the context
47      * @return true if there is a default
48      */

49     boolean hasDefault(String JavaDoc bindingName);
50
51     /**
52      * Check whether the value is modified.
53      * For existing binding for which there is no default value
54      * (that is {@link #hasDefault} is false) returns this method
55      * always true.
56      *
57      * @param bindingName the binding name or null for the context
58      * @return true if default value is modified; always returns true if
59      * default value does not exist
60      */

61     boolean isModified(String JavaDoc bindingName);
62
63     /**
64      * Revert modification. Will do something only if value is modified
65      * (ie. {@link #isModified} returns true). If there is no default
66      * value (ie. {@link #hasDefault} returns false) the revert operation
67      * is identical to unbinding of object or destroying of context
68      * content.
69      *
70      * @param bindingName the binding name or null for the context
71      * @throws ContextException can throw exception if there were problems
72      * during removal of modified values
73      */

74     void revert(String JavaDoc bindingName) throws ContextException;
75
76 }
77
Popular Tags