org.hippoecm.hst.util
Class ObjectConverterUtils

java.lang.Object
  extended by org.hippoecm.hst.util.ObjectConverterUtils

public class ObjectConverterUtils
extends Object

ObjectConverterUtils

Version:
$Id$

Method Summary
static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses)
          Creates ObjectConverter, with ignoreDuplicates = false, which means that when there are two annotated beans with the same value for Node.jcrType(), an IllegalArgumentException is thrown.
static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses, boolean ignoreDuplicates)
          Creates ObjectConverter.
static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses, Class<? extends HippoBean>[] builtInMappingClasses, String[] fallbackNodeTypes, boolean ignoreDuplicates)
          Creates ObjectConverter.
static List<Class<? extends HippoBean>> getAnnotatedClasses(ClasspathResourceScanner resourceScanner, String... locationPatterns)
          Collects bean classes annotated by Node from the location specified by locationPattern.
static List<Class<? extends HippoBean>> getAnnotatedClasses(URL url)
          Collects bean classes annotated by Node from a XML Resource URL.
static String[] getDefaultFallbackNodeTypes()
          Returns the default built-in fallback jcr primary node types
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createObjectConverter

public static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses)
                                             throws IllegalArgumentException
Creates ObjectConverter, with ignoreDuplicates = false, which means that when there are two annotated beans with the same value for Node.jcrType(), an IllegalArgumentException is thrown.

Parameters:
annotatedClasses - Annotated class mapping against jcr primary node types.
Returns:
the ObjectConverter for theseannotatedClasses
Throws:
IllegalArgumentException - when two annotatedClasses have the same Node.jcrType()

createObjectConverter

public static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses,
                                                    boolean ignoreDuplicates)
                                             throws IllegalArgumentException
Creates ObjectConverter.

Parameters:
annotatedClasses - Annotated class mapping against jcr primary node types.
ignoreDuplicates - Flag whether duplicate mapping for a node type is ignored or not. If it is false, it throws IllegalArgumentException on duplicate mappings.
Returns:
the ObjectConverter for theseannotatedClasses
Throws:
IllegalArgumentException - when two annotatedClasses have the same Node.jcrType() and ignoreDuplicates is false

createObjectConverter

public static ObjectConverter createObjectConverter(Collection<Class<? extends HippoBean>> annotatedClasses,
                                                    Class<? extends HippoBean>[] builtInMappingClasses,
                                                    String[] fallbackNodeTypes,
                                                    boolean ignoreDuplicates)
                                             throws IllegalArgumentException
Creates ObjectConverter.

Parameters:
annotatedClasses - Annotated class mapping against jcr primary node types.
builtInMappingClasses - Built-in class mappings against the default built-in jcr primary node types.
fallbackNodeTypes - If no bean found for the node type, a fallback node type is to be selected as ordered by using node.isNodeType(fallbackNodeType)
ignoreDuplicates - Flag whether duplicate mapping for a node type is ignored or not. If it is false, it throws IllegalArgumentException on duplicate mappings.
Returns:
Throws:
IllegalArgumentException

getDefaultFallbackNodeTypes

public static String[] getDefaultFallbackNodeTypes()
Returns the default built-in fallback jcr primary node types

Returns:

getAnnotatedClasses

public static List<Class<? extends HippoBean>> getAnnotatedClasses(URL url)
                                                            throws IOException,
                                                                   SAXException,
                                                                   ParserConfigurationException
Collects bean classes annotated by Node from a XML Resource URL.

Each annotated class name must be written inside <annotated-class/> element as child of the root element, <hst-content-beans/>, like the following example:


 <hst-content-beans>
   <annotated-class>org.hippoecm.hst.demo.beans.TextBean</annotated-class>
   <annotated-class>org.hippoecm.hst.demo.beans.NewsBean</annotated-class>
   <annotated-class>org.hippoecm.hst.demo.beans.ProductBean</annotated-class>
   <annotated-class>org.hippoecm.hst.demo.beans.CommentBean</annotated-class>
   <annotated-class>org.hippoecm.hst.demo.beans.CommentLinkBean</annotated-class>
   <annotated-class>org.hippoecm.hst.demo.beans.ImageLinkBean</annotated-class>
 </hst-content-beans>
 

Parameters:
url -
Returns:
Throws:
IOException
SAXException
ParserConfigurationException

getAnnotatedClasses

public static List<Class<? extends HippoBean>> getAnnotatedClasses(ClasspathResourceScanner resourceScanner,
                                                                   String... locationPatterns)
                                                            throws IOException,
                                                                   SAXException,
                                                                   ParserConfigurationException
Collects bean classes annotated by Node from the location specified by locationPattern. Class resources will be collected by the specified resourceScanner.

Parameters:
resourceScanner -
locationPatterns -
Returns:
Throws:
IOException
SAXException
ParserConfigurationException
See Also:
ClasspathResourceScanner}


Copyright © 2008-2012 Hippo. All Rights Reserved.