Class JcrDataConverter
- java.lang.Object
-
- org.silverpeas.core.persistence.jcr.JcrDataConverter
-
public class JcrDataConverter extends Object
A converter of some data handled in the JCR, such as node paths and dates. It converts the data from and for the JCR world and the Silverpeas world.- Author:
- Emmanuel Hugonnet
-
-
Field Summary
Fields Modifier and Type Field Description static String
PATH_SEPARATOR
Token used in path.static String
SPACE_TOKEN
Token used to replace space in names.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
convertFromJcrPath(String name)
Replace all SPACE_TOKEN to whitespace.static String
convertToJcrPath(String name)
Replace all whitespace to SPACE_TOKEN.static String
escapeIllegalJcrChars(String name)
static String
formatDate(Calendar calendar)
Format a Calendar to a String of format yyyy/MM/dd.static String
formatDate(Date date)
Format a Date to a String of format yyyy/MM/dd.static String
formatDateForXpath(Date date)
static String
formatTime(Calendar calendar)
Format a Calendar to a String of format HH:mm.static String
formatTime(Date date)
Format a Date to a String of format HH:mm.protected static String
getTimeZone(Date date)
protected static String
getXpathFormattedDate(Date date)
protected static String
getXpathFormattedTime(Date date)
static Date
parseDate(String date)
Parses the specified text encoding a date in the format yyyy/MM/dd and returns the represented date.static void
setTime(Calendar calendar, String time)
Parse a String of format HH:mm and set the corresponding hours and minutes to the specified Calendar.
-
-
-
Field Detail
-
SPACE_TOKEN
public static final String SPACE_TOKEN
Token used to replace space in names.- See Also:
- Constant Field Values
-
PATH_SEPARATOR
public static final String PATH_SEPARATOR
Token used in path.- See Also:
- Constant Field Values
-
-
Method Detail
-
convertToJcrPath
public static String convertToJcrPath(String name)
Replace all whitespace to SPACE_TOKEN.- Parameters:
name
- the String o be converted.- Returns:
- the resulting String.
-
convertFromJcrPath
public static String convertFromJcrPath(String name)
Replace all SPACE_TOKEN to whitespace.- Parameters:
name
- the String o be converted.- Returns:
- the resulting String.
-
parseDate
public static Date parseDate(String date) throws ParseException
Parses the specified text encoding a date in the format yyyy/MM/dd and returns the represented date.- Parameters:
date
- the String to be parsed.- Returns:
- the corresponding date.
- Throws:
ParseException
- an error if the specified text doesn't encode a date.
-
formatDate
public static String formatDate(Date date)
Format a Date to a String of format yyyy/MM/dd.- Parameters:
date
- the date to be formatted.- Returns:
- the formatted String.
-
formatDate
public static String formatDate(Calendar calendar)
Format a Calendar to a String of format yyyy/MM/dd.- Parameters:
calendar
- the date to be formatted.- Returns:
- the formatted String.
-
setTime
public static void setTime(Calendar calendar, String time)
Parse a String of format HH:mm and set the corresponding hours and minutes to the specified Calendar.- Parameters:
time
- the String to be parsed.calendar
- the calendar to be updated.
-
formatTime
public static String formatTime(Date date)
Format a Date to a String of format HH:mm.- Parameters:
date
- the date to be formatted.- Returns:
- the formatted String.
-
formatTime
public static String formatTime(Calendar calendar)
Format a Calendar to a String of format HH:mm.- Parameters:
calendar
- the date to be formatted.- Returns:
- the formatted String.
-
-