private JAXBContextHelper() {
}
public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
if (tContext == null)
throw new TransformationException("JAXB context is not set for the transformation.");
DataType<?> dataType = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
// FIXME: We should check the context path or classes
// FIXME: What should we do if JAXB is an intermediate node?
// String contextPath = null;
JAXBContext context = null;
Class<?> cls = getJavaType(dataType);
context = JAXBContext.newInstance(cls);
if (context == null) {
throw new TransformationException("JAXB context is not set for the transformation.");
}
return context;
}