Class CookieSet
java.lang.Object
org.openide.nodes.CookieSet
- All Implemented Interfaces:
org.openide.util.Lookup.Provider
Support class for storing cookies and
retriving them by representation class.
Provides simple notifications about changes
in cookies.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Allows to update content of the cookie set just before a query for a given class is made.static interface
Factory for creating cookies of given Class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory) Registers a Factory for given cookie classesvoid
add
(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory) Registers a Factory for given cookie classvoid
add
(Node.Cookie cookie) Add a new cookie to the set.void
Add a listener to changes in the cookie set.<T> void
Removes all instances of clazz from the set and replaces them with newly provided instance(s).static CookieSet
createGeneric
(CookieSet.Before before) Factory method to create new, general purpose cookie set.<T extends Node.Cookie>
TGet a cookie.org.openide.util.Lookup
The lookup associated with this cookie set.void
remove
(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory) Unregisters a Factory for given cookie classesvoid
remove
(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory) Unregisters a Factory for given cookie classvoid
remove
(Node.Cookie cookie) Remove a cookie from the set.void
Remove a listener to changes in the cookie set.
-
Constructor Details
-
CookieSet
public CookieSet()Default constructor.
-
-
Method Details
-
createGeneric
Factory method to create new, general purpose cookie set. The general purpose means that it is possible to store any object, into the cookie set and then obtain it usinggetLookup()
and queries on the returnedLookup
. The before object can be passed in if one wants to do a lazy initialization of theCookieSet
content.- Parameters:
before
- the interface to support lazy initialization- Returns:
- new cookie set that can contain not only
Node.Cookie
but also any plain old java object - Since:
- 7.0
- See Also:
-
getLookup
public org.openide.util.Lookup getLookup()The lookup associated with this cookie set. Keeps track of the same things that are in the cookie set, but presents them as being inside the lookup.- Specified by:
getLookup
in interfaceorg.openide.util.Lookup.Provider
- Returns:
- the lookup representing this cookie set
- Since:
- 7.0
-
add
Add a new cookie to the set. If a cookie of the same actual (not representation!) class is already there, it is replaced.Cookies inserted earlier are given preference during lookup, in case a supplied representation class matches more than one cookie in the set.
- Parameters:
cookie
- cookie to add
-
remove
Remove a cookie from the set.- Parameters:
cookie
- the cookie to remove
-
getCookie
Get a cookie.- Parameters:
clazz
- the representation class- Returns:
- a cookie assignable to the representation class, or
null
if there is none
-
addChangeListener
Add a listener to changes in the cookie set.- Parameters:
l
- the listener to add
-
removeChangeListener
Remove a listener to changes in the cookie set.- Parameters:
l
- the listener to remove
-
add
Registers a Factory for given cookie class -
add
Registers a Factory for given cookie classes -
remove
Unregisters a Factory for given cookie class- Since:
- 2.6
-
remove
Unregisters a Factory for given cookie classes- Since:
- 2.6
-
assign
Removes all instances of clazz from the set and replaces them with newly provided instance(s).- Parameters:
clazz
- the root clazz for cookies to removeinstances
- the one or more instances to put into the lookup- Since:
- 7.0
-