use of org.eclipse.persistence.oxm.annotations.XmlAccessMethods in project eclipselink by eclipse-ee4j.
the class AnnotationsProcessor method processPropertyAnnotations.
private void processPropertyAnnotations(TypeInfo info, JavaClass cls, JavaHasAnnotations propertyElement, Property property) {
// Check for mixed context
if (helper.isAnnotationPresent(propertyElement, XmlMixed.class)) {
info.setMixed(true);
property.setMixedContent(true);
findAndProcessObjectFactory(cls);
}
if (helper.isAnnotationPresent(propertyElement, XmlInverseReference.class)) {
XmlInverseReference inverseReference = (XmlInverseReference) helper.getAnnotation(propertyElement, XmlInverseReference.class);
property.setInverseReferencePropertyName(inverseReference.mappedBy());
TypeInfo targetInfo = this.getTypeInfos().get(property.getActualType().getName());
if (targetInfo != null && targetInfo.getXmlAccessType() == XmlAccessType.PROPERTY) {
String propName = property.getPropertyName();
propName = Character.toUpperCase(propName.charAt(0)) + propName.substring(1);
property.setInverseReferencePropertyGetMethodName(GET_STR + propName);
property.setInverseReferencePropertySetMethodName(SET_STR + propName);
}
property.setInverseReference(true, helper.isAnnotationPresent(propertyElement, XmlElement.class));
}
processXmlJavaTypeAdapter(property, info, cls);
if (helper.isAnnotationPresent(propertyElement, XmlAttachmentRef.class) && areEquals(property.getActualType(), JAVAX_ACTIVATION_DATAHANDLER)) {
property.setIsSwaAttachmentRef(true);
property.setSchemaType(Constants.SWA_REF_QNAME);
}
processXmlElement(property, info);
// JavaClass ptype = property.getActualType();
if (!(property.isSwaAttachmentRef()) && isMtomAttachment(property)) {
property.setIsMtomAttachment(true);
property.setSchemaType(Constants.BASE_64_BINARY_QNAME);
}
if (helper.isAnnotationPresent(propertyElement, XmlMimeType.class)) {
property.setMimeType(((XmlMimeType) helper.getAnnotation(propertyElement, XmlMimeType.class)).value());
}
// non-binary data type won't have any affect
if (helper.isAnnotationPresent(propertyElement, XmlInlineBinaryData.class) || info.isBinaryDataToBeInlined()) {
property.setisInlineBinaryData(true);
}
// later use:
if (helper.isAnnotationPresent(propertyElement, XmlSchemaType.class)) {
XmlSchemaType schemaType = (XmlSchemaType) helper.getAnnotation(propertyElement, XmlSchemaType.class);
QName schemaTypeQname = new QName(schemaType.namespace(), schemaType.name());
property.setSchemaType(schemaTypeQname);
}
if (helper.isAnnotationPresent(propertyElement, XmlAttribute.class)) {
property.setIsAttribute(true);
property.setIsRequired(((XmlAttribute) helper.getAnnotation(propertyElement, XmlAttribute.class)).required());
}
if (helper.isAnnotationPresent(propertyElement, XmlAnyAttribute.class)) {
if (info.isSetAnyAttributePropertyName() && !info.getAnyAttributePropertyName().equals(property.getPropertyName())) {
throw org.eclipse.persistence.exceptions.JAXBException.multipleAnyAttributeMapping(cls.getName());
}
if (!helper.isMapType(property.getType())) {
throw org.eclipse.persistence.exceptions.JAXBException.anyAttributeOnNonMap(property.getPropertyName());
}
property.setIsAnyAttribute(true);
info.setAnyAttributePropertyName(property.getPropertyName());
}
// Make sure XmlElementWrapper annotation is on a collection or array
if (helper.isAnnotationPresent(propertyElement, XmlElementWrapper.class)) {
XmlElementWrapper wrapper = (XmlElementWrapper) helper.getAnnotation(propertyElement, XmlElementWrapper.class);
org.eclipse.persistence.jaxb.xmlmodel.XmlElementWrapper xmlEltWrapper = new org.eclipse.persistence.jaxb.xmlmodel.XmlElementWrapper();
String wrapperName = wrapper.name();
if (wrapperName.equals(XMLProcessor.DEFAULT)) {
wrapperName = info.getXmlNameTransformer().transformElementName(property.getPropertyName());
}
xmlEltWrapper.setName(wrapperName);
xmlEltWrapper.setNamespace(wrapper.namespace());
xmlEltWrapper.setNillable(wrapper.nillable());
xmlEltWrapper.setRequired(wrapper.required());
property.setXmlElementWrapper(xmlEltWrapper);
}
if (helper.isAnnotationPresent(propertyElement, XmlList.class)) {
// Make sure XmlList annotation is on a collection or array
if (!helper.isCollectionType(property.getType()) && !property.getType().isArray()) {
throw JAXBException.invalidList(property.getPropertyName());
}
property.setIsXmlList(true);
}
if (helper.isAnnotationPresent(propertyElement, XmlValue.class)) {
property.setIsXmlValue(true);
info.setXmlValueProperty(property);
}
if (helper.isAnnotationPresent(propertyElement, XmlReadOnly.class)) {
property.setReadOnly(true);
}
if (helper.isAnnotationPresent(propertyElement, XmlWriteOnly.class)) {
property.setWriteOnly(true);
}
if (helper.isAnnotationPresent(propertyElement, XmlCDATA.class)) {
property.setCdata(true);
}
if (helper.isAnnotationPresent(propertyElement, XmlAccessMethods.class)) {
XmlAccessMethods accessMethods = (XmlAccessMethods) helper.getAnnotation(propertyElement, XmlAccessMethods.class);
if (!(accessMethods.getMethodName().equals(EMPTY_STRING))) {
property.setGetMethodName(accessMethods.getMethodName());
}
if (!(accessMethods.setMethodName().equals(EMPTY_STRING))) {
property.setSetMethodName(accessMethods.setMethodName());
}
if (!(property.isMethodProperty())) {
property.setMethodProperty(true);
}
}
// handle user properties
if (helper.isAnnotationPresent(propertyElement, XmlProperties.class)) {
XmlProperties xmlProperties = (XmlProperties) helper.getAnnotation(propertyElement, XmlProperties.class);
Map<Object, Object> propertiesMap = createUserPropertiesMap(xmlProperties.value());
property.setUserProperties(propertiesMap);
} else if (helper.isAnnotationPresent(propertyElement, XmlProperty.class)) {
XmlProperty xmlProperty = (XmlProperty) helper.getAnnotation(propertyElement, XmlProperty.class);
Map<Object, Object> propertiesMap = createUserPropertiesMap(new XmlProperty[] { xmlProperty });
property.setUserProperties(propertiesMap);
}
// handle XmlKey
if (helper.isAnnotationPresent(propertyElement, XmlKey.class)) {
info.addXmlKeyProperty(property);
}
// handle XmlJoinNode(s)
processXmlJoinNodes(property);
processXmlNullPolicy(property, cls, info);
// Handle XmlLocation
JavaHasAnnotations elem = propertyElement;
if (helper.isAnnotationPresent(elem, XmlLocation.class) || helper.isAnnotationPresent(elem, CompilerHelper.XML_LOCATION_ANNOTATION_CLASS) || helper.isAnnotationPresent(elem, CompilerHelper.OLD_XML_LOCATION_ANNOTATION_CLASS) || helper.isAnnotationPresent(elem, CompilerHelper.INTERNAL_XML_LOCATION_ANNOTATION_CLASS)) {
if (!helper.getJavaClass(Constants.LOCATOR_CLASS).isAssignableFrom(property.getType())) {
throw JAXBException.invalidXmlLocation(property.getPropertyName(), property.getType().getName());
}
property.setXmlLocation(true);
}
}
Aggregations