info.magnolia.jcr.util
Class PropertyUtil

java.lang.Object
  extended by info.magnolia.jcr.util.PropertyUtil

public class PropertyUtil
extends Object

Property-related utility methods.

Version:
$Id$

Constructor Summary
PropertyUtil()
           
 
Method Summary
static javax.jcr.Value createValue(Object obj, javax.jcr.ValueFactory valueFactory)
           
static javax.jcr.Value createValue(String valueStr, int type, javax.jcr.ValueFactory valueFactory)
          Transforms a string to a jcr value object.
static boolean getBoolean(javax.jcr.Node node, String name, boolean defaultValue)
          Return the boolean representing the node property value.
static Calendar getDate(javax.jcr.Node node, String name)
          Return the Calendar representing the node property value.
static Calendar getDate(javax.jcr.Node node, String name, Calendar defaultValue)
          Return the Calendar representing the node property value.
static String getDateFormat()
           
static int getJCRPropertyType(Object obj)
           
static javax.jcr.Property getProperty(javax.jcr.Node node, String relativePath)
          Return the Property relative to the Node.
static String getString(javax.jcr.Node node, String name)
          Return the String representing the node property value.
static String getString(javax.jcr.Node node, String name, String defaultValue)
          Return the String representing the node property value.
static List<String> getValuesStringList(javax.jcr.Value[] values)
           
static void renameProperty(javax.jcr.Property property, String newName)
           
static void setProperty(javax.jcr.Node node, String propertyName, Object propertyValue)
          Allows setting a Node's property from an object.
static void updateOrCreate(javax.jcr.Node node, String string, GregorianCalendar gregorianCalendar)
          Updates existing property or creates a new one if it doesn't exist already.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtil

public PropertyUtil()
Method Detail

renameProperty

public static void renameProperty(javax.jcr.Property property,
                                  String newName)
                           throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

setProperty

public static void setProperty(javax.jcr.Node node,
                               String propertyName,
                               Object propertyValue)
                        throws javax.jcr.RepositoryException
Allows setting a Node's property from an object.

Throws:
javax.jcr.RepositoryException

createValue

public static javax.jcr.Value createValue(String valueStr,
                                          int type,
                                          javax.jcr.ValueFactory valueFactory)
Transforms a string to a jcr value object.


getJCRPropertyType

public static int getJCRPropertyType(Object obj)
Returns:
JCR-PropertyType corresponding to provided Object.

updateOrCreate

public static void updateOrCreate(javax.jcr.Node node,
                                  String string,
                                  GregorianCalendar gregorianCalendar)
                           throws javax.jcr.RepositoryException
Updates existing property or creates a new one if it doesn't exist already.

Throws:
javax.jcr.RepositoryException

getDateFormat

public static String getDateFormat()

getValuesStringList

public static List<String> getValuesStringList(javax.jcr.Value[] values)

createValue

public static javax.jcr.Value createValue(Object obj,
                                          javax.jcr.ValueFactory valueFactory)
                                   throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

getDate

public static Calendar getDate(javax.jcr.Node node,
                               String name)
Return the Calendar representing the node property value. If the Node did not contain such a Property, then return null.


getDate

public static Calendar getDate(javax.jcr.Node node,
                               String name,
                               Calendar defaultValue)
Return the Calendar representing the node property value. If the Node did not contain such a Property, then return the default value.


getString

public static String getString(javax.jcr.Node node,
                               String name)
Return the String representing the node property value. If the Node did not contain such a Property, then return null.


getString

public static String getString(javax.jcr.Node node,
                               String name,
                               String defaultValue)
Return the String representing the node property value. If the Node did not contain such a Property, then return the default value.


getBoolean

public static boolean getBoolean(javax.jcr.Node node,
                                 String name,
                                 boolean defaultValue)
Return the boolean representing the node property value. If the Node did not contain such a Property, then return the default value.


getProperty

public static javax.jcr.Property getProperty(javax.jcr.Node node,
                                             String relativePath)
Return the Property relative to the Node. Return null in case of Exception.



Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.