/** * Returns the constant named <tt>constantName</tt> from the enum class specified by <tt>enumName</tt>. * * @param enumName * Java class name of an enum. * @param constantName * Name of the constant to get from the specified enum. * * @return * An <tt>Object</tt>, the constant from the specified enum. */ public Object getEnumConstant(String enumName, String constantName) throws ClassNotFoundException, JAXBException { Object valueToReturn = null; Class<?> enumClass = getDynamicClassLoader().loadClass(enumName); Object[] enumConstants = enumClass.getEnumConstants(); for (Object enumConstant : enumConstants) { if (enumConstant.toString().equals(constantName)) { valueToReturn = enumConstant; } } if (valueToReturn != null) { return valueToReturn; } else { throw new JAXBException(org.eclipse.persistence.exceptions.JAXBException.enumConstantNotFound(enumName + "." + constantName)); } }
/** * Returns the constant named <tt>constantName</tt> from the enum class specified by <tt>enumName</tt>. * * @param enumName * Java class name of an enum. * @param constantName * Name of the constant to get from the specified enum. * * @return * An <tt>Object</tt>, the constant from the specified enum. */ public Object getEnumConstant(String enumName, String constantName) throws ClassNotFoundException, JAXBException { Object valueToReturn = null; Class<?> enumClass = getDynamicClassLoader().loadClass(enumName); Object[] enumConstants = enumClass.getEnumConstants(); for (Object enumConstant : enumConstants) { if (enumConstant.toString().equals(constantName)) { valueToReturn = enumConstant; } } if (valueToReturn != null) { return valueToReturn; } else { throw new JAXBException(org.eclipse.persistence.exceptions.JAXBException.enumConstantNotFound(enumName + "." + constantName)); } }