org.apache.chemistry.opencmis.jcr
Class JcrConverter

java.lang.Object
  extended by org.apache.chemistry.opencmis.jcr.JcrConverter

public final class JcrConverter
extends java.lang.Object

Utility class providing methods for converting various entities from/to their respective representation in JCR/CMIS.


Method Summary
static PropertyData<?> convert(javax.jcr.Property jcrProperty)
          Convert a JCR Property to a CMIS PropertyData.
static boolean isValidJcrName(java.lang.String name)
          Checks if the given name is valid a valid JCR name
static void removeProperty(javax.jcr.Node node, PropertyData<?> propertyData)
          Remove a property from a JCR node
static void setProperty(javax.jcr.Node node, PropertyData<?> propertyData)
          Set a property on a JCR node.
static java.lang.String toJcrName(java.lang.String cmisName)
          Escapes all illegal JCR name characters of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toJcrName

public static java.lang.String toJcrName(java.lang.String cmisName)
Escapes all illegal JCR name characters of a string. The encoding is loosely modeled after URI encoding, but only encodes the characters it absolutely needs to in order to make the resulting string a valid JCR name.

QName EBNF:

 simplename ::= onecharsimplename | twocharsimplename | threeormorecharname
 onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', '|' or any whitespace character *)
 twocharsimplename ::= '.' onecharsimplename | onecharsimplename '.' | onecharsimplename onecharsimplename
 threeormorecharname ::= nonspace string nonspace
 string ::= char | string char
 char ::= nonspace | ' '
 nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', '|' or any whitespace character *)
 

Parameters:
cmisName - the name to escape
Returns:
the escaped name

isValidJcrName

public static boolean isValidJcrName(java.lang.String name)
Checks if the given name is valid a valid JCR name

Parameters:
name - the name to check
Returns:
true if the name is valid, false otherwise.

convert

public static PropertyData<?> convert(javax.jcr.Property jcrProperty)
                               throws javax.jcr.RepositoryException
Convert a JCR Property to a CMIS PropertyData.

Parameters:
jcrProperty -
Returns:
Throws:
javax.jcr.RepositoryException

setProperty

public static void setProperty(javax.jcr.Node node,
                               PropertyData<?> propertyData)
                        throws javax.jcr.RepositoryException
Set a property on a JCR node.

Parameters:
node - the node to set the property
propertyData - the property to set
Throws:
javax.jcr.RepositoryException

removeProperty

public static void removeProperty(javax.jcr.Node node,
                                  PropertyData<?> propertyData)
                           throws javax.jcr.RepositoryException
Remove a property from a JCR node

Parameters:
node - the node from which to remove the property
propertyData - the property to remove
Throws:
javax.jcr.RepositoryException


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.