Java Code Examples for org.alfresco.service.cmr.dictionary.DataTypeDefinition.getJavaClassName()

The following are Jave code examples for showing how to use getJavaClassName() of the org.alfresco.service.cmr.dictionary.DataTypeDefinition class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: alfresco-data-model   File: TypeConverter.java   Source Code and License Vote up 6 votes
/**
 * General conversion method to Object types (note it cannot support
 * conversion to primary types due the restrictions of reflection. Use the
 * static conversion methods to primitive types)
 * 
 * @param propertyType - the target property type
 * @param value - the value to be converted
 * @return - the converted value as the correct type
 */
public final Object convert(DataTypeDefinition propertyType, Object value)
{
    ParameterCheck.mandatory("Property type definition", propertyType);
    
    // Convert property type to java class
    Class<?> javaClass = null;
    String javaClassName = propertyType.getJavaClassName();
    try
    {
        javaClass = Class.forName(javaClassName);
    }
    catch (ClassNotFoundException e)
    {
        throw new DictionaryException("Java class " + javaClassName + " of property type " + propertyType.getName() + " is invalid", e);
    }
    
    return convert(javaClass, value);
}
 
Example 2
Project: alfresco-data-model   File: TypeConverter.java   Source Code and License Vote up 6 votes
/**
 * General conversion method to convert collection contents to the specified
 * type.
 * 
 * @param propertyType - the target property type
 * @param values - the value to be converted
 * @return - the converted value as the correct type
 * @throws DictionaryException if the property type's registered java class is invalid
 * @throws TypeConversionException if the conversion cannot be performed
 */
public final Collection<?> convert(DataTypeDefinition propertyType, Collection<?> values)
{
    ParameterCheck.mandatory("Property type definition", propertyType);
    
    // Convert property type to java class
    Class<?> javaClass = null;
    String javaClassName = propertyType.getJavaClassName();
    try
    {
        javaClass = Class.forName(javaClassName);
    }
    catch (ClassNotFoundException e)
    {
        throw new DictionaryException("Java class " + javaClassName + " of property type " + propertyType.getName() + " is invalid", e);
    }
    
    return convert(javaClass, values);
}