Package com.composum.sling.core.util
Class PropertyUtil
- java.lang.Object
-
- com.composum.sling.core.util.PropertyUtil
-
public class PropertyUtil extends Object
Created by rw on 26.02.15.
-
-
Field Summary
Fields Modifier and Type Field Description static SetPropertyStrategy
DEFAULT_PROPERTY_STRATEGY
protected static Map<Integer,Class>
DEFAULT_PROPERTY_TYPES
The most appropriate Java type for aPropertyType
.static String
FORBIDDEN_NAME_CHARS
static String
PROP_MIXIN_TYPES
static String
PROP_PRIMARY_TYPE
some property names with special functions or filtersstatic Map<String,SetPropertyStrategy>
SET_PROPERTY_STRATEGY_MAP
-
Constructor Summary
Constructors Constructor Description PropertyUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.jcr.Value
createValue(javax.jcr.ValueFactory factory, Object value, int type)
static javax.jcr.Binary
getBinaryData(javax.jcr.Node node)
static Boolean
getProperty(javax.jcr.Node node, String name, Boolean defaultValue)
static Double
getProperty(javax.jcr.Node node, String name, Double defaultValue)
static Long
getProperty(javax.jcr.Node node, String name, Long defaultValue)
static String
getProperty(javax.jcr.Node node, String name, String defaultValue)
static BigDecimal
getProperty(javax.jcr.Node node, String name, BigDecimal defaultValue)
static Calendar
getProperty(javax.jcr.Node node, String name, Calendar defaultValue)
static SetPropertyStrategy
getSetPropertyStrategy(String name)
static com.composum.sling.core.util.PropertyUtil.StringSubtype
getStringSubtype(String value)
Determines a string value 'subtype' (the type of the editing widget) derived from the value itself.static <T> Class<T>
getType(T defaultValue)
static String
manglePropertyName(String name)
FIXME(rw,2015-04-22) not useful in the core layerstatic <T> T
readValue(javax.jcr.Value value, Class<T> type)
Reads the value of a property as the given type.static javax.jcr.Property
setProperty(javax.jcr.Node node, String name, InputStream input)
static javax.jcr.Property
setProperty(javax.jcr.Node node, String name, Iterable<?> values, int type)
static javax.jcr.Property
setProperty(javax.jcr.Node node, String name, Object value, int type)
static javax.jcr.Property
setProperty(javax.jcr.Node node, String name, javax.jcr.Value[] values, int type)
static javax.jcr.Property
setProperty(javax.jcr.Node node, String name, javax.jcr.Value value, int type)
static boolean
xssCheck(String value)
-
-
-
Field Detail
-
FORBIDDEN_NAME_CHARS
public static final String FORBIDDEN_NAME_CHARS
- See Also:
- Constant Field Values
-
PROP_PRIMARY_TYPE
public static final String PROP_PRIMARY_TYPE
some property names with special functions or filters- See Also:
- Constant Field Values
-
PROP_MIXIN_TYPES
public static final String PROP_MIXIN_TYPES
- See Also:
- Constant Field Values
-
DEFAULT_PROPERTY_STRATEGY
public static final SetPropertyStrategy DEFAULT_PROPERTY_STRATEGY
-
SET_PROPERTY_STRATEGY_MAP
public static final Map<String,SetPropertyStrategy> SET_PROPERTY_STRATEGY_MAP
-
-
Method Detail
-
getStringSubtype
public static com.composum.sling.core.util.PropertyUtil.StringSubtype getStringSubtype(String value)
Determines a string value 'subtype' (the type of the editing widget) derived from the value itself.- Parameters:
value
- the string value- Returns:
- the subtype
-
xssCheck
public static boolean xssCheck(String value)
- Returns:
- 'true' if the value seems to be free from XSS stuff
-
getType
public static <T> Class<T> getType(T defaultValue)
-
getProperty
public static String getProperty(javax.jcr.Node node, String name, String defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getProperty
public static Boolean getProperty(javax.jcr.Node node, String name, Boolean defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getProperty
public static Long getProperty(javax.jcr.Node node, String name, Long defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getProperty
public static Calendar getProperty(javax.jcr.Node node, String name, Calendar defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getProperty
public static BigDecimal getProperty(javax.jcr.Node node, String name, BigDecimal defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getProperty
public static Double getProperty(javax.jcr.Node node, String name, Double defaultValue) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
manglePropertyName
public static String manglePropertyName(String name)
FIXME(rw,2015-04-22) not useful in the core layer
-
getBinaryData
public static javax.jcr.Binary getBinaryData(javax.jcr.Node node)
-
getSetPropertyStrategy
public static SetPropertyStrategy getSetPropertyStrategy(String name)
- Parameters:
name
-- Returns:
-
setProperty
public static javax.jcr.Property setProperty(javax.jcr.Node node, String name, javax.jcr.Value value, int type) throws javax.jcr.RepositoryException
- Parameters:
node
-name
-value
-type
-- Returns:
- Throws:
javax.jcr.RepositoryException
-
setProperty
public static javax.jcr.Property setProperty(javax.jcr.Node node, String name, javax.jcr.Value[] values, int type) throws javax.jcr.RepositoryException
- Parameters:
node
-name
-values
-type
-- Returns:
- Throws:
javax.jcr.RepositoryException
-
setProperty
public static javax.jcr.Property setProperty(javax.jcr.Node node, String name, InputStream input) throws javax.jcr.RepositoryException
- Parameters:
node
-name
-input
-- Returns:
- Throws:
javax.jcr.RepositoryException
-
setProperty
public static javax.jcr.Property setProperty(javax.jcr.Node node, String name, Iterable<?> values, int type) throws javax.jcr.RepositoryException
- Parameters:
node
-name
-values
-type
-- Throws:
javax.jcr.RepositoryException
-
setProperty
public static javax.jcr.Property setProperty(javax.jcr.Node node, String name, Object value, int type) throws javax.jcr.RepositoryException
- Parameters:
node
-name
-value
-type
-- Throws:
javax.jcr.RepositoryException
-
createValue
public static javax.jcr.Value createValue(javax.jcr.ValueFactory factory, Object value, int type) throws javax.jcr.ValueFormatException
- Throws:
javax.jcr.ValueFormatException
-
readValue
public static <T> T readValue(javax.jcr.Value value, Class<T> type) throws javax.jcr.RepositoryException
Reads the value of a property as the given type.- Throws:
javax.jcr.RepositoryException
-
-