This documentation is for an old version of fiftyfive-wicket (2.0.9).


fiftyfive.wicket.js.locator
Class DependencyCollection

java.lang.Object
  extended by fiftyfive.wicket.js.locator.DependencyCollection
All Implemented Interfaces:
Iterable<ResourceReference>

public class DependencyCollection
extends Object
implements Iterable<ResourceReference>

Holds a tree of JavaScript dependencies as they are traversed, ensuring that the ordering is properly maintained and duplicates are ignored. Once traversal is complete, the dependencies can be iterated in the order they should appear in the <head> by calling iterator().

A property is also maintained to indicate whether CSS is needed by the JavaScript dependencies. Currently this is only used to indicate the need for jQuery UI's CSS theme, based on whether or not jQuery UI is a script dependency. An arbitrary number of CSS dependencies is not supported.

Since:
2.0

Constructor Summary
DependencyCollection()
          Creates an empty collection.
 
Method Summary
 boolean add(ResourceReference ref)
          Adds a resource to the collection at the current level of the tree.
 void ascend()
          Inform the collection that we are finished adding descendent resources.
 void copyTo(DependencyCollection other)
          Copy internal state to another instance.
 void descend()
          Inform the collection that subsequent calls to add() should be treated as descendents of the most recently added resource.
 void freeze()
          Make this object immutable so that any modifications will cause IllegalStateException to be thrown.
 ResourceReference getCss()
          Returns a reference to the jQuery UI CSS theme, if it is needed by one of the JavaScript dependencies.
 ResourceReference getRootReference()
           
 boolean isEmpty()
          Returns true if this collection does not contain any script references.
 Iterator<ResourceReference> iterator()
          Iterate over all dependencies in the order they should appear in the <head>.
 void setCss(ResourceReference css)
          Sets the CSS resource that should accompany these JavaScript dependencies, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyCollection

public DependencyCollection()
Creates an empty collection.

Method Detail

add

public boolean add(ResourceReference ref)
Adds a resource to the collection at the current level of the tree. The level of the tree can be adjusted by first calling descend() and ascend().

Returns:
true if the resource did not already exist in the collection, and was therefore added successfully; false if the resource already existed (or was null) and was ignored.

descend

public void descend()
Inform the collection that subsequent calls to add() should be treated as descendents of the most recently added resource. Once all descendents have been added, ascend() should be called to move the insertion cursor back "up" the tree. Calls to descend() can be nested, as long as they are balanced with an equal number of calls to ascend().


ascend

public void ascend()
Inform the collection that we are finished adding descendent resources. Subsequent calls to add() will be treated as siblings, as opposed to children.

See Also:
ascend()

getCss

public ResourceReference getCss()
Returns a reference to the jQuery UI CSS theme, if it is needed by one of the JavaScript dependencies. Otherwise returns null.


setCss

public void setCss(ResourceReference css)
Sets the CSS resource that should accompany these JavaScript dependencies, if any. The default is null.


iterator

public Iterator<ResourceReference> iterator()
Iterate over all dependencies in the order they should appear in the <head>.

Specified by:
iterator in interface Iterable<ResourceReference>

getRootReference

public ResourceReference getRootReference()

isEmpty

public boolean isEmpty()
Returns true if this collection does not contain any script references.


freeze

public void freeze()
Make this object immutable so that any modifications will cause IllegalStateException to be thrown.


copyTo

public void copyTo(DependencyCollection other)
Copy internal state to another instance. The frozen status will not be copied.



Copyright © 2011 55 Minutes. All Rights Reserved.