Class LayoutLoader
java.lang.Object
cl.netswitch.lib.layout.LayoutLoader
Collection of reusable
Layout instances. If a required Layout
is not in the collection, it is loaded from the specified layoutURI and added to the collection.
The layoutURI must contain at least one occurrence of the marker
"*". Before each download, all occurrences of this marker are
replaced with the name of the layout. In this way, the resulting URL
gets targeted specifically to the required layout. Examples of valid URLs:
http://www.netswitch.cl/layouts/*.jsp file:///C:/netswitch/layouts/*.asp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears (removes) all layouts from the cache.Downloads the specification of theLayoutwith the givenname.Returns aLayoutwith the specifiedname.layouts()Returns an unmodifiable collection with the layouts contained in thisLayoutLoader.voidAdds a layout to the collection of layouts of thisLayoutLoader.
-
Constructor Details
-
LayoutLoader
Constructs a newLayoutLoaderinstance.- Parameters:
layoutURI- the URI used to download layouts.- Throws:
NullPointerException- iflayoutURIisnull.IllegalArgumentException- iflayoutURIis invalid.
-
-
Method Details
-
layouts
Returns an unmodifiable collection with the layouts contained in thisLayoutLoader.- Returns:
- an unmodifiable collection with the layouts contained in this
LayoutLoader.
-
clear
public void clear()Clears (removes) all layouts from the cache. -
getLayout
Returns aLayoutwith the specifiedname. If theLayoutis not in the cache, it downloads its specification, compiles it, verifies its MD5 signature (or checksum), and then stores the resultingLayoutin the cache.- Parameters:
name- name of the requiredLayout.- Returns:
- the required
Layout. - Throws:
NullPointerException- ifnameis null or empty.Exception- if an error occurs while loading the layout.
-
putLayout
Adds a layout to the collection of layouts of thisLayoutLoader. Thelayoutmust be non-null and complete as defined by theLayout.isComplete()method.- Parameters:
layout- the layout to add to thisLayoutLoader.- Throws:
NullPointerException- iflayoutis null.IllegalStateException- iflayoutis not complete.
-
download
Downloads the specification of theLayoutwith the givenname. The layout spacification will be downloaded from the location specified by the specifiedlayoutURI.- Parameters:
name- the name of the requiredLayout.- Returns:
- a string with the specification of the
Layout. - Throws:
NullPointerException- ifnameisnull.Exception- if an error occurs while loading the layout.
-