use of com.webcohesion.enunciate.modules.jaxb.api.impl.DataTypeReferenceImpl in project enunciate by stoicflame.
the class QNameForMediaTypeMethod method exec.
public Object exec(List list) throws TemplateModelException {
if (list.size() < 1) {
throw new TemplateModelException("The QNameForType method must have a type mirror as a parameter.");
}
TemplateModel from = (TemplateModel) list.get(0);
Object unwrapped = FreemarkerUtil.unwrap(from);
if (unwrapped instanceof MediaTypeDescriptor) {
MediaTypeDescriptor mt = (MediaTypeDescriptor) unwrapped;
DataTypeReference typeReference = mt.getDataType();
if (typeReference != null) {
if (typeReference instanceof DataTypeReferenceImpl) {
return ((DataTypeReferenceImpl) typeReference).getElementQName();
} else if (associateJsonWithXml && mt.getMediaType().endsWith("json")) {
DataType dataType = typeReference.getValue();
if (dataType != null) {
XmlType knownType = this.context.getKnownType(dataType.getJavaElement());
if (knownType != null) {
return knownType.getQname();
}
TypeDefinition typeDefinition = this.context.findTypeDefinition(dataType.getJavaElement());
if (typeDefinition != null) {
return typeDefinition.getQname();
}
}
}
}
}
return null;
}
Aggregations