info.magnolia.cms.util
Class NodeDataUtil

java.lang.Object
  extended by info.magnolia.cms.util.NodeDataUtil

public class NodeDataUtil
extends Object

Util to work with NodeData.

Version:
$Revision$ ($Author$)
Author:
Sameer Charles

Constructor Summary
NodeDataUtil()
           
 
Method Summary
static javax.jcr.Value createValue(Object obj, javax.jcr.ValueFactory valueFactory)
          Deprecated. since 4.5 - use PropertyUtil.createValue(Object, ValueFactory) instead
static javax.jcr.Value createValue(String valueStr, int type)
          Uses the default value factory.
static javax.jcr.Value createValue(String valueStr, int type, javax.jcr.ValueFactory valueFactory)
          Deprecated. since 4.5 - directly use PropertyUtil.createValue(String, int, ValueFactory) instead.
static boolean getBoolean(Content node, String name, boolean defaultValue)
           
static Calendar getDate(Content node, String name, Calendar defaultValue)
           
static String getDateFormat()
          Deprecated. since 4.5 - use PropertyUtil.getDateFormat() instead
static String getI18NString(Content node, String str)
          Uses the i18n mechanism to translate the message if the resulting string is a key.
static String getI18NString(Content node, String str, String basename)
          Uses the i18n mechanism to translate the message if the resulting string is a key.
static int getJCRPropertyType(Object obj)
          Deprecated. since 4.5 - use PropertyUtil.getJCRPropertyType(Object) instead
static long getLong(Content node, String name, long defaultValue)
           
static NodeData getOrCreate(Content node, String name)
          If the NodeData does not exist yet, just create it.
static NodeData getOrCreate(Content node, String name, int type)
          If the NodeData does not exist yet, just create it.
static NodeData getOrCreate(Content node, String name, Object obj)
           
static NodeData getOrCreateAndSet(Content node, String name, boolean value)
           
static NodeData getOrCreateAndSet(Content node, String name, int value)
           
static NodeData getOrCreateAndSet(Content node, String name, long value)
           
static NodeData getOrCreateAndSet(Content node, String name, Object obj)
           
static NodeData getOrCreateAndSet(Content node, String name, javax.jcr.Value[] value)
           
static String getString(Content node, String name)
          Get the string or the empty string if not existing.
static String getString(Content node, String name, String defaultValue)
          You can define a default value if not found.
static String getString(String repository, String path)
          Simple method to get strings like configuration informations.
static String getString(String repository, String path, String defaultValue)
          You can define a default value if not found.
static String getTypeName(NodeData nd)
          String representation of the jcr property type.
static Object getValueObject(NodeData nd)
          Returns the value as an Object.
static List<String> getValuesStringList(javax.jcr.Value[] values)
          Deprecated. since 4.5 - use PropertyUtil.getValuesStringList(Value[]) instead
static String getValueString(NodeData nodeData)
          Same as getValueString(nd, dateFormat) but using the users short date format.
static String getValueString(NodeData nodeData, String dateFormat)
          Returns a String representation of the value.
static String getValueString(javax.jcr.Value value, String dateFormat)
          Same as value.getString(), but using custom date format.
static Object inherit(Content node, String name)
          Inherit a value.
static Object inherit(Content node, String name, Object dflt)
          Inherit a value.
static String inheritString(Content node, String name)
          Inherit a value.
static String inheritString(Content node, String name, String dflt)
          Inherit a value.
static NodeData setValue(NodeData nodeData, Object valueObj)
          Calls the correct setValue method based on object type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeDataUtil

public NodeDataUtil()
Method Detail

getValueString

public static String getValueString(NodeData nodeData)
Same as getValueString(nd, dateFormat) but using the users short date format.


getValueString

public static String getValueString(NodeData nodeData,
                                    String dateFormat)
Returns a String representation of the value. In case of a binary the path including filename and extension is returned

Parameters:
nodeData -
dateFormat - date format to use in the case it is a date
Returns:

getValueString

public static String getValueString(javax.jcr.Value value,
                                    String dateFormat)
Same as value.getString(), but using custom date format.


inheritString

public static String inheritString(Content node,
                                   String name)
                            throws javax.jcr.RepositoryException
Inherit a value. Uses the string value. The "inherit" means that the method will look for the value in the content itself and if not found it will go up in the tree and try to locate value in one of the parents of the content until reaching the root. The first value found while traversing the tree way up is the one that will be returned.

Parameters:
node - Node expected to define or inherit the searched node value.
name - Name of the nodeData.
Throws:
javax.jcr.RepositoryException

inheritString

public static String inheritString(Content node,
                                   String name,
                                   String dflt)
                            throws javax.jcr.RepositoryException
Inherit a value. You can provide a default value if not found

Throws:
javax.jcr.RepositoryException

inherit

public static Object inherit(Content node,
                             String name)
                      throws javax.jcr.RepositoryException
Inherit a value. Uses the string value

Throws:
javax.jcr.RepositoryException

inherit

public static Object inherit(Content node,
                             String name,
                             Object dflt)
                      throws javax.jcr.RepositoryException
Inherit a value. You can provide a default value if not found

Throws:
javax.jcr.RepositoryException

getValueObject

public static Object getValueObject(NodeData nd)
Returns the value as an Object.

Returns:
Object

setValue

public static NodeData setValue(NodeData nodeData,
                                Object valueObj)
                         throws AccessDeniedException,
                                javax.jcr.RepositoryException
Calls the correct setValue method based on object type. If the value is null an empty string is set.

Throws:
AccessDeniedException
javax.jcr.RepositoryException

getTypeName

public static String getTypeName(NodeData nd)
String representation of the jcr property type.


getString

public static String getString(String repository,
                               String path)
Simple method to get strings like configuration informations.


getString

public static String getString(Content node,
                               String name)
Get the string or the empty string if not existing.


getString

public static String getString(String repository,
                               String path,
                               String defaultValue)
You can define a default value if not found.


getString

public static String getString(Content node,
                               String name,
                               String defaultValue)
You can define a default value if not found.


getLong

public static long getLong(Content node,
                           String name,
                           long defaultValue)

getDate

public static Calendar getDate(Content node,
                               String name,
                               Calendar defaultValue)

getBoolean

public static boolean getBoolean(Content node,
                                 String name,
                                 boolean defaultValue)

getOrCreate

public static NodeData getOrCreate(Content node,
                                   String name)
                            throws AccessDeniedException,
                                   javax.jcr.RepositoryException
If the NodeData does not exist yet, just create it.

Parameters:
node -
name -
Returns:
the found or created NodeData
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreate

public static NodeData getOrCreate(Content node,
                                   String name,
                                   int type)
                            throws AccessDeniedException,
                                   javax.jcr.RepositoryException
If the NodeData does not exist yet, just create it.

Parameters:
node -
name -
Returns:
the found or created NodeData
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreate

public static NodeData getOrCreate(Content node,
                                   String name,
                                   Object obj)
                            throws AccessDeniedException,
                                   javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreateAndSet

public static NodeData getOrCreateAndSet(Content node,
                                         String name,
                                         Object obj)
                                  throws AccessDeniedException,
                                         javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreateAndSet

public static NodeData getOrCreateAndSet(Content node,
                                         String name,
                                         long value)
                                  throws AccessDeniedException,
                                         javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreateAndSet

public static NodeData getOrCreateAndSet(Content node,
                                         String name,
                                         javax.jcr.Value[] value)
                                  throws AccessDeniedException,
                                         javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreateAndSet

public static NodeData getOrCreateAndSet(Content node,
                                         String name,
                                         int value)
                                  throws AccessDeniedException,
                                         javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getOrCreateAndSet

public static NodeData getOrCreateAndSet(Content node,
                                         String name,
                                         boolean value)
                                  throws AccessDeniedException,
                                         javax.jcr.RepositoryException
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getI18NString

public static String getI18NString(Content node,
                                   String str)
Uses the i18n mechanism to translate the message if the resulting string is a key.


getI18NString

public static String getI18NString(Content node,
                                   String str,
                                   String basename)
Uses the i18n mechanism to translate the message if the resulting string is a key.


createValue

public static javax.jcr.Value createValue(String valueStr,
                                          int type)
                                   throws javax.jcr.RepositoryException
Uses the default value factory.

Throws:
javax.jcr.RepositoryException

createValue

@Deprecated
public static javax.jcr.Value createValue(Object obj,
                                                     javax.jcr.ValueFactory valueFactory)
                                   throws javax.jcr.RepositoryException
Deprecated. since 4.5 - use PropertyUtil.createValue(Object, ValueFactory) instead

Throws:
javax.jcr.RepositoryException

createValue

@Deprecated
public static javax.jcr.Value createValue(String valueStr,
                                                     int type,
                                                     javax.jcr.ValueFactory valueFactory)
Deprecated. since 4.5 - directly use PropertyUtil.createValue(String, int, ValueFactory) instead.

Transforms a string to a jcr value object.


getJCRPropertyType

@Deprecated
public static int getJCRPropertyType(Object obj)
Deprecated. since 4.5 - use PropertyUtil.getJCRPropertyType(Object) instead


getValuesStringList

@Deprecated
public static List<String> getValuesStringList(javax.jcr.Value[] values)
Deprecated. since 4.5 - use PropertyUtil.getValuesStringList(Value[]) instead


getDateFormat

@Deprecated
public static String getDateFormat()
Deprecated. since 4.5 - use PropertyUtil.getDateFormat() instead



Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.