Class PropertyDescription
- java.lang.Object
-
- org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
-
- org.apache.sling.feature.extension.apiregions.api.config.DescribableEntity
-
- org.apache.sling.feature.extension.apiregions.api.config.PropertyDescription
-
- Direct Known Subclasses:
FrameworkPropertyDescription
public class PropertyDescription extends DescribableEntity
Instances of this class represent a single configuration property This class is not thread safe.
-
-
Constructor Summary
Constructors Constructor Description PropertyDescription()
Create a new description
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the object and reset to defaultsprotected javax.json.JsonObjectBuilder
createJson()
Convert this object into JSONvoid
fromJSONObject(javax.json.JsonObject jsonObj)
Extract the metadata from the JSON object.int
getCardinality()
Get the cardinalityObject
getDefaultValue()
Get the optional default value.String[]
getExcludes()
Get the excludesString[]
getIncludes()
Get the includesMode
getMode()
Get the validation mode.List<Option>
getOptions()
Get the list of optionsPlaceholderPolicy
getPlaceholderPolicy()
Get the placeholder policy.String
getPlaceholderRegex()
Get the placeholder regexPattern
getPlaceholderRegexPattern()
Get the placeholder regex patternRange
getRange()
Get the rangeString
getRegex()
Get the regexPattern
getRegexPattern()
Get the regex patternPropertyType
getType()
Get the property typeString
getVariable()
Get the variableboolean
isRequired()
Is this property required?void
setCardinality(int value)
Set the cardinality The default cardinality is1
.protected void
setDefaults()
Apply the non-null default values.void
setDefaultValue(Object val)
Set the optional default value.void
setExcludes(String[] excludes)
Set the excludesvoid
setIncludes(String[] includes)
Set the includesvoid
setMode(Mode value)
Set the validation modevoid
setOptions(List<Option> options)
Set the list of optionsvoid
setPlaceholderPolicy(PlaceholderPolicy policy)
Set the placeholder policyvoid
setPlaceholderRegex(String regex)
Set the placeholder regexvoid
setRange(Range range)
Set the rangevoid
setRegex(String regex)
Set the regexvoid
setRequired(boolean flag)
Set whether this property is requiredvoid
setType(PropertyType type)
Set the property typevoid
setVariable(String variable)
Set the variable-
Methods inherited from class org.apache.sling.feature.extension.apiregions.api.config.DescribableEntity
getDeprecated, getDescription, getEnforceOn, getSince, getTitle, setDeprecated, setDescription, setEnforceOn, setSince, setTitle
-
Methods inherited from class org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
getAttributes, getBoolean, getInteger, getNumber, getString, getString, getStringArray, setString, setStringArray, toJSONObject
-
-
-
-
Method Detail
-
setDefaults
protected void setDefaults()
Description copied from class:AttributeableEntity
Apply the non-null default values.- Overrides:
setDefaults
in classAttributeableEntity
-
clear
public void clear()
Clear the object and reset to defaults- Overrides:
clear
in classDescribableEntity
-
fromJSONObject
public void fromJSONObject(javax.json.JsonObject jsonObj) throws IOException
Extract the metadata from the JSON object. This method first callsclear()
- Overrides:
fromJSONObject
in classDescribableEntity
- Parameters:
jsonObj
- The JSON Object- Throws:
IOException
- If JSON parsing fails
-
createJson
protected javax.json.JsonObjectBuilder createJson() throws IOException
Convert this object into JSON- Overrides:
createJson
in classDescribableEntity
- Returns:
- The json object builder
- Throws:
IOException
- If generating the JSON fails
-
getType
public PropertyType getType()
Get the property type- Returns:
- the type
-
setType
public void setType(PropertyType type)
Set the property type- Parameters:
type
- the type to set
-
getCardinality
public int getCardinality()
Get the cardinality- Returns:
- the cardinality
-
setCardinality
public void setCardinality(int value)
Set the cardinality The default cardinality is1
. If the value is greater than zero the property can contain up to that number of values. If the cardinality is-1
the property can hold an unlimited number of values.- Parameters:
value
- the cardinality to set- Throws:
IllegalArgumentException
- If the value is0
or below-1
.
-
getVariable
public String getVariable()
Get the variable- Returns:
- the variable or
null
-
setVariable
public void setVariable(String variable)
Set the variable- Parameters:
variable
- the variable to set
-
getRange
public Range getRange()
Get the range- Returns:
- the range or
null
-
setRange
public void setRange(Range range)
Set the range- Parameters:
range
- the range to set
-
getIncludes
public String[] getIncludes()
Get the includes- Returns:
- the includes or
null
-
setIncludes
public void setIncludes(String[] includes)
Set the includes- Parameters:
includes
- the includes to set
-
getExcludes
public String[] getExcludes()
Get the excludes- Returns:
- the excludes or
null
-
setExcludes
public void setExcludes(String[] excludes)
Set the excludes- Parameters:
excludes
- the excludes to set
-
setOptions
public void setOptions(List<Option> options)
Set the list of options- Parameters:
options
- the options to set
-
getRegex
public String getRegex()
Get the regex- Returns:
- the regex or
null
-
setRegex
public void setRegex(String regex)
Set the regex- Parameters:
regex
- the regex to set- Throws:
IllegalArgumentException
- If the pattern is not valid
-
getRegexPattern
public Pattern getRegexPattern()
Get the regex pattern- Returns:
- The pattern or
null
-
isRequired
public boolean isRequired()
Is this property required?- Returns:
true
if it is required
-
setRequired
public void setRequired(boolean flag)
Set whether this property is required- Parameters:
flag
- The new value
-
getDefaultValue
public Object getDefaultValue()
Get the optional default value.- Returns:
- The default value or
null
- Since:
- 1.2
-
setDefaultValue
public void setDefaultValue(Object val)
Set the optional default value.- Parameters:
val
- The default value- Since:
- 1.2
-
getMode
public Mode getMode()
Get the validation mode.- Returns:
- The mode or
null
- Since:
- 1.2
-
setMode
public void setMode(Mode value)
Set the validation mode- Parameters:
value
- The validation mode- Since:
- 1.2
-
getPlaceholderPolicy
public PlaceholderPolicy getPlaceholderPolicy()
Get the placeholder policy.- Returns:
- The policy
- Since:
- 1.3
-
setPlaceholderPolicy
public void setPlaceholderPolicy(PlaceholderPolicy policy)
Set the placeholder policy- Parameters:
policy
- The new policy- Since:
- 1.3
-
getPlaceholderRegex
public String getPlaceholderRegex()
Get the placeholder regex- Returns:
- the placeholder regex or
null
- Since:
- 1.3
-
setPlaceholderRegex
public void setPlaceholderRegex(String regex)
Set the placeholder regex- Parameters:
regex
- the placeholder regex to set- Throws:
IllegalArgumentException
- If the pattern is not valid- Since:
- 1.3
-
getPlaceholderRegexPattern
public Pattern getPlaceholderRegexPattern()
Get the placeholder regex pattern- Returns:
- The pattern or
null
- Since:
- 1.3
-
-