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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears (removes) all layouts from the cache.Downloads the specification of theLayout
with the givenname
.Returns aLayout
with the specifiedname
.layouts()
Returns an unmodifiable collection with the layouts contained in thisLayoutLoader
.void
Adds a layout to the collection of layouts of thisLayoutLoader
.
-
Constructor Details
-
LayoutLoader
Constructs a newLayoutLoader
instance.- Parameters:
layoutURI
- the URI used to download layouts.- Throws:
NullPointerException
- iflayoutURI
isnull
.IllegalArgumentException
- iflayoutURI
is 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 aLayout
with the specifiedname
. If theLayout
is not in the cache, it downloads its specification, compiles it, verifies its MD5 signature (or checksum), and then stores the resultingLayout
in the cache.- Parameters:
name
- name of the requiredLayout
.- Returns:
- the required
Layout
. - Throws:
NullPointerException
- ifname
is null or empty.Exception
- if an error occurs while loading the layout.
-
putLayout
Adds a layout to the collection of layouts of thisLayoutLoader
. Thelayout
must be non-null and complete as defined by theLayout.isComplete()
method.- Parameters:
layout
- the layout to add to thisLayoutLoader
.- Throws:
NullPointerException
- iflayout
is null.IllegalStateException
- iflayout
is not complete.
-
download
Downloads the specification of theLayout
with 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
- ifname
isnull
.Exception
- if an error occurs while loading the layout.
-