站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

CookieSet (Nodes API) - NetBeans API Javadoc (Current Development Version)

org.openide.nodes 7.0

org.openide.nodes
Class CookieSet

java.lang.Object
  extended by org.openide.nodes.CookieSet
All Implemented Interfaces:
Lookup.Provider

public final class CookieSet
extends Object
implements Lookup.Provider

Support class for storing cookies and retriving them by representation class. Provides simple notifications about changes in cookies.


Nested Class Summary
static interface CookieSet.Before
          Allows to update content of the cookie set just before a query for a given class is made.
static interface CookieSet.Factory
          Factory for creating cookies of given Class
 
Constructor Summary
CookieSet()
          Default constructor.
 
Method Summary
 void add(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory)
          Registers a Factory for given cookie classes
 void add(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory)
          Registers a Factory for given cookie class
 void add(Node.Cookie cookie)
          Add a new cookie to the set.
 void addChangeListener(ChangeListener l)
          Add a listener to changes in the cookie set.
<T> void
assign(Class<? extends T> clazz, T... instances)
          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>
T
getCookie(Class<T> clazz)
          Get a cookie.
 Lookup getLookup()
          The lookup associated with this cookie set.
 void remove(Class<? extends Node.Cookie>[] cookieClass, CookieSet.Factory factory)
          Unregisters a Factory for given cookie classes
 void remove(Class<? extends Node.Cookie> cookieClass, CookieSet.Factory factory)
          Unregisters a Factory for given cookie class
 void remove(Node.Cookie cookie)
          Remove a cookie from the set.
 void removeChangeListener(ChangeListener l)
          Remove a listener to changes in the cookie set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieSet

public CookieSet()
Default constructor.

Method Detail

createGeneric

public static CookieSet createGeneric(CookieSet.Before before)
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 using getLookup() and queries on the returned Lookup. The before object can be passed in if one wants to do a lazy initialization of the CookieSet 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:
assign(java.lang.Class, T...)

getLookup

public 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 interface Lookup.Provider
Returns:
the lookup representing this cookie set
Since:
7.0

add

public void add(Node.Cookie cookie)
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

public void remove(Node.Cookie cookie)
Remove a cookie from the set.

Parameters:
cookie - the cookie to remove

getCookie

public <T extends Node.Cookie> T getCookie(Class<T> clazz)
Get a cookie.

Parameters:
clazz - the representation class
Returns:
a cookie assignable to the representation class, or null if there is none

addChangeListener

public void addChangeListener(ChangeListener l)
Add a listener to changes in the cookie set.

Parameters:
l - the listener to add

removeChangeListener

public void removeChangeListener(ChangeListener l)
Remove a listener to changes in the cookie set.

Parameters:
l - the listener to remove

add

public void add(Class<? extends Node.Cookie> cookieClass,
                CookieSet.Factory factory)
Registers a Factory for given cookie class


add

public void add(Class<? extends Node.Cookie>[] cookieClass,
                CookieSet.Factory factory)
Registers a Factory for given cookie classes


remove

public void remove(Class<? extends Node.Cookie> cookieClass,
                   CookieSet.Factory factory)
Unregisters a Factory for given cookie class

Since:
2.6

remove

public void remove(Class<? extends Node.Cookie>[] cookieClass,
                   CookieSet.Factory factory)
Unregisters a Factory for given cookie classes

Since:
2.6

assign

public <T> void assign(Class<? extends T> clazz,
                       T... instances)
Removes all instances of clazz from the set and replaces them with newly provided instance(s).

Parameters:
clazz - the root clazz for cookies to remove
instances - the one or more instances to put into the lookup
Since:
7.0

org.openide.nodes 7.0

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.