@DefaultKey(value="config")
public class SkinConfigTool
extends org.apache.velocity.tools.generic.SafeConfig
The tool is configured to access Maven site configuration of a skin inside <custom>
element of site descriptor. It supports global properties (defined at skin level) and per-page
properties (defined in <page><mypage>
element). The per-page properties override the
global ones.
A sample configuration would be like that:
<custom>
<msb4Skin>
<prop1>value1</prop1>
<prop2>
<prop21>value2</prop21>
</prop2>
<pages>
<mypage project="myproject">
<prop1>override value1</prop1>
</mypage>
</pages>
</msb4Skin>
</custom>
To get the value of prop1
, one would simply use $config.prop1
. This would return
"override value1". Then $config.prop2
would return "value2" - the global value.
The tool allows querying the value easily, falling back from page to global configuration to
null
, if none is available. It also provides convenience accessors for common values.
Note
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_KEY |
static String |
SKIN_KEY
By default use Msb4 skin configuration tag
|
Constructor and Description |
---|
SkinConfigTool() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(org.apache.velocity.tools.generic.ValueParser values) |
org.codehaus.plexus.util.xml.Xpp3Dom |
get(String property)
Default accessor for config properties.
|
String |
getFileId() |
String |
getKey()
Should return the key under which this tool has been configured.
|
String |
getProjectId() |
boolean |
is(String property)
A convenience method to check if the value of the
property is "true" . |
boolean |
isValue(String property,
String value)
A convenience method to check if the
property is set to a specific value. |
boolean |
not(String property)
A convenience method to check if the value of the
property is "false" . |
protected void |
setKey(String key)
Sets the key under which this tool has been configured.
|
String |
value(String property)
Retrieves the text value of the given
property , e.g. as in
<myprop>value</myprop> . |
public static final String DEFAULT_KEY
public static final String SKIN_KEY
protected void configure(org.apache.velocity.tools.generic.ValueParser values)
configure
in class org.apache.velocity.tools.generic.SafeConfig
SafeConfig.configure(ValueParser)
protected void setKey(String key)
key
- sets keypublic String getKey()
public org.codehaus.plexus.util.xml.Xpp3Dom get(String property)
$config.get("myproperty")
,
one can utilise Velocity fallback onto the default getter and use $config.myproperty
.property
- the property of interestnull
otherwisepublic String value(String property)
property
, e.g. as in
<myprop>value</myprop>
.property
- the property of interestnull
otherwise.get(String)
public boolean is(String property)
property
is "true"
.property
- the property of interesttrue
if the configuration value is set either in page or globally, and is
equal to "true"
.get(String)
public boolean not(String property)
property
is "false"
. Useful
for properties that are enabled by default - checks if the property is set to "false"
explicitly.property
- the property of interesttrue
if the configuration value is set either in page or globally, and is
equal to "false"
. Note that this will return false
if property is not
set at all.get(String)
public boolean isValue(String property, String value)
property
is set to a specific value.property
- the property of interestvalue
- the property value to checktrue
if the configuration value is set either in page or globally, and is
equal to value
.get(String)
public String getProjectId()
public String getFileId()
Copyright © 2015–2016 Marek Romanowski. All rights reserved.