package org.apache.sling.servlets.post.impl.helper;
import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.resource.ResourceUtil;
Encapsulates all infos from the respective request parameters that are needed
to create the repository property
private RequestParameter[] values;
assert path.startsWith("/"); this.path = ResourceUtil.normalize(path);
this.parentPath = ResourceUtil.getParent(path);
this.name = ResourceUtil.getName(path);
return this.hasMultiValueTypeHint;
if ( typeHint != null && typeHint.endsWith("[]") ) { this.typeHint = typeHint.substring(0, typeHint.length() - 2);
this.hasMultiValueTypeHint = true;
this.typeHint = typeHint;
this.hasMultiValueTypeHint = false;
if (useDefaultWhenMissing && defaultValues != null && defaultValues.length > 0) { return (values != null && getStringValues().length > 0);
public void setValues(RequestParameter[] values) { if (defaultValues == null) { this.defaultValues = EMPTY_PARAM_ARRAY;
this.defaultValues = defaultValues;
return values != null && !values[0].isFormField();
Checks if this property provides any values. this is the case if one of
the values is not empty or if the default handling is not 'ignore'
- Returns:
true if this property provides values
String[] sv = getStringValues();
Returns the assembled string array out of the provided request values and
default values.
- Returns:
- a String array or
null if the property needs to be
removed.
if (stringValues == null) { if (values == null && useDefaultWhenMissing) { stringValues = new String[] { defaultValues[0].getString() }; } else if (values.length > 1) { List<String> stringValueList = new ArrayList<String>(values.length);
for (int i = 0; i < values.length; i++) { String value = values[i].getString();
if ((!ignoreBlanks) || value.length() > 0) { stringValueList.add(value);
stringValues = stringValueList.toArray(new String[stringValueList.size()]);
String value = values[0].getString();
if (defaultValues.length == 1) { String defValue = defaultValues[0].getString();
if (defValue.equals(DEFAULT_IGNORE)) { } else if (defValue.equals(DEFAULT_NULL)) { stringValues = new String[] { value }; Specifies whether this property should be deleted before any new content
is to be set according to the values stored.
- Parameters:
isDelete true if the repository item described by
this is to be deleted before any other operation.
this.isDelete = isDelete;
Returns
true if the repository item described by this is
to be deleted before setting new content to it.
Sets the path of the repository item from which the content for this
property is to be copied or moved. The path may be relative in which case
it will be resolved relative to the absolute path of this property.
- Parameters:
sourcePath The path of the repository item to get the content fromisMove true if the source content is to be moved,
otherwise the source content is copied from the repository
item.
if (!sourcePath.startsWith("/")) { sourcePath = getParentPath() + "/" + sourcePath;
sourcePath = ResourceUtil.normalize(sourcePath);
this.repositoryResourcePath = sourcePath;
this.isRepositoryResourceMove = isMove;
Returns
true if the content of this property is to be set
by moving content from another repository item.
- See also:
- getRepositorySource()
return isRepositoryResourceMove;
Returns
true if the content of this property is to be set
by copying content from another repository item.
- See also:
- getRepositorySource()
return getRepositorySource() != null && !hasRepositoryMoveSource();
Returns the absolute path of the repository item from which the content
for this property is to be copied or moved.
- See also:
- hasRepositoryCopySource()
- hasRepositoryMoveSource()
- setRepositorySource(String, boolean)
return repositoryResourcePath;
useDefaultWhenMissing = b;