Class PropertyUtil


  • public class PropertyUtil
    extends Object
    Created by rw on 26.02.15.
    • Constructor Detail

      • PropertyUtil

        public PropertyUtil()
    • 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