diff options
author | pfullbright | 2011-07-21 20:22:50 +0000 |
---|---|---|
committer | pfullbright | 2011-07-21 20:22:50 +0000 |
commit | 2e88268d68e282e6df889fc0bc52a803779554da (patch) | |
tree | 7891476cff46bc3885687059a1f301afd9425d4f | |
parent | 49b2f6852f2b9cbb54fb7c4b348b8996cb7c609a (diff) | |
download | webtools.dali-2e88268d68e282e6df889fc0bc52a803779554da.tar.gz webtools.dali-2e88268d68e282e6df889fc0bc52a803779554da.tar.xz webtools.dali-2e88268d68e282e6df889fc0bc52a803779554da.zip |
added api, fixed attribute mapping defaults
19 files changed, 333 insertions, 88 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java index 89039b4cb4..3173f762cb 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java @@ -35,6 +35,10 @@ import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlElementMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping; +import org.eclipse.jpt.jaxb.core.context.XmlMixedMapping; import org.eclipse.jpt.jaxb.core.context.XmlNs; import org.eclipse.jpt.jaxb.core.context.XmlRootElement; import org.eclipse.jpt.jaxb.core.context.XmlSchema; @@ -44,20 +48,14 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation; /** * Use a JAXB factory to build any core (e.g. {@link JaxbProject}) - * model object or any Java (e.g. {@link JavaEntity}), ORM (e.g. - * {@link EntityMappings}), or persistence (e.g. {@link PersistenceUnit}) - * context model objects. + * model object or any Java (e.g. {@link XmlType}) context model objects * <p> * Assumes a base JAXB project context structure * corresponding to the JAXB spec: * <pre> * RootContext - * |- persistence.xml - * |- persistence unit(s) - * |- mapping file(s) (e.g. orm.xml) - * | |- persistent type mapping(s) (e.g. Entity) - * | |- persistent attribute mapping(s) (e.g. Basic) - * |- persistent type mapping(s) + * |- jaxb packages/types + * |- jaxb attributes/methods * </pre> * ... and associated objects. *<p> @@ -69,7 +67,7 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation; * * @see org.eclipse.jpt.jaxb.core.internal.jaxb21.GenericJaxb_2_1_Factory * - * @version 3.0 + * @version 3.1 * @since 3.0 */ public interface JaxbFactory { @@ -140,9 +138,16 @@ public interface JaxbFactory { XmlAttributeMapping buildJavaXmlAttributeMapping(JaxbPersistentAttribute parent); XmlElementMapping buildJavaXmlElementMapping(JaxbPersistentAttribute parent); - + + XmlElementRefMapping buildJavaXmlElementRefMapping(JaxbPersistentAttribute parent); + + XmlElementRefsMapping buildJavaXmlElementRefsMapping(JaxbPersistentAttribute parent); + + XmlElementsMapping buildJavaXmlElementsMapping(JaxbPersistentAttribute parent); + + XmlMixedMapping buildJavaXmlMixedMapping(JaxbPersistentAttribute parent); + JaxbAttributeMapping buildJavaXmlTransientMapping(JaxbPersistentAttribute parent); - + XmlValueMapping buildJavaXmlValueMapping(JaxbPersistentAttribute parent); - } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java index 4a547d1c1a..00bc71254d 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/MappingKeys.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.jaxb.core; /** - * + * Identifiers for JAXB class/attribute mapping types * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +18,7 @@ package org.eclipse.jpt.jaxb.core; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. * - * @version 3.0 + * @version 3.1 * @since 3.0 */ @SuppressWarnings("nls") @@ -31,6 +31,7 @@ public interface MappingKeys { String XML_ELEMENTS_ATTRIBUTE_MAPPING_KEY = "xml-elements"; String XML_ELEMENT_REF_ATTRIBUTE_MAPPING_KEY = "xml-element-ref"; String XML_ELEMENT_REFS_ATTRIBUTE_MAPPING_KEY = "xml-element-refs"; + String XML_MIXED_ATTRIBUTE_MAPPING_KEY = "xml-mixed"; String XML_TRANSIENT_ATTRIBUTE_MAPPING_KEY = "xml-transient"; String XML_VALUE_ATTRIBUTE_MAPPING_KEY = "xml-value"; diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java new file mode 100644 index 0000000000..40cb20736e --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefMapping.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.context; + +/** + * Represents a JAXB xml element ref mapping (@XmlElementRef) + * <p> + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.1 + * @since 3.1 + */ +public interface XmlElementRefMapping + extends JaxbAttributeMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java new file mode 100644 index 0000000000..a99e837802 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementRefsMapping.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.context; + +/** + * Represents a JAXB xml element refs mapping (@XmlElementRefs) + * <p> + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.1 + * @since 3.1 + */ +public interface XmlElementRefsMapping + extends JaxbAttributeMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java new file mode 100644 index 0000000000..03954956e8 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlElementsMapping.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.context; + +/** + * Represents a JAXB xml elements mapping (@XmlElements) + * <p> + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.1 + * @since 3.1 + */ +public interface XmlElementsMapping + extends JaxbAttributeMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlMixedMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlMixedMapping.java new file mode 100644 index 0000000000..04d40a11d0 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlMixedMapping.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.context; + +/** + * Represents a JAXB mixed mapping (@XmlMixed) + * <p> + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.1 + * @since 3.1 + */ +public interface XmlMixedMapping + extends JaxbAttributeMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java index 97a5553962..a06765dd88 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java @@ -39,6 +39,10 @@ import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlElementMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping; +import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping; +import org.eclipse.jpt.jaxb.core.context.XmlMixedMapping; import org.eclipse.jpt.jaxb.core.context.XmlNs; import org.eclipse.jpt.jaxb.core.context.XmlRootElement; import org.eclipse.jpt.jaxb.core.context.XmlSchema; @@ -58,6 +62,10 @@ import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyAttribut import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAttributeMapping; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementMapping; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementRefMapping; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementRefsMapping; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementsMapping; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlMixedMapping; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlNs; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlRootElement; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlSchema; @@ -133,51 +141,67 @@ public abstract class AbstractJaxbFactory public XmlNs buildJavaXmlNs(XmlSchema parent, XmlNsAnnotation xmlNsAnnotation) { return new GenericJavaXmlNs(parent, xmlNsAnnotation); } - + public XmlRootElement buildJavaXmlRootElement(JaxbPersistentType parent, XmlRootElementAnnotation xmlRootElementAnnotation) { return new GenericJavaXmlRootElement(parent, xmlRootElementAnnotation); } - + public JaxbElementFactoryMethod buildJavaElementFactoryMethod(JaxbRegistry parent, JavaResourceMethod resourceMethod) { return new GenericJavaElementFactoryMethod(parent, resourceMethod); } - + public JaxbPersistentAttribute buildJavaPersistentAttribute(JaxbPersistentClass parent, Accessor accessor) { return new GenericJavaPersistentAttribute(parent, accessor); } - + public JaxbPersistentAttribute buildJavaPersistentField(JaxbPersistentClass parent, JavaResourceField resourceField) { return GenericJavaPersistentAttribute.buildPersistentField(parent, resourceField); } - + public JaxbPersistentAttribute buildJavaPersistentProperty(JaxbPersistentClass parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) { return GenericJavaPersistentAttribute.buildPersistentProperty(parent, resourceGetter, resourceSetter); } - + public JaxbAttributeMapping buildJavaNullAttributeMapping(JaxbPersistentAttribute parent) { return new GenericJavaNullAttributeMapping(parent); } - + public JaxbAttributeMapping buildJavaXmlTransientMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlTransientMapping(parent); } - + public XmlAnyAttributeMapping buildJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlAnyAttributeMapping(parent); } - + public XmlAnyElementMapping buildJavaXmlAnyElementMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlAnyElementMapping(parent); } - + public XmlAttributeMapping buildJavaXmlAttributeMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlAttributeMapping(parent); } - + public XmlElementMapping buildJavaXmlElementMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlElementMapping(parent); } - + + public XmlElementRefMapping buildJavaXmlElementRefMapping(JaxbPersistentAttribute parent) { + return new GenericJavaXmlElementRefMapping(parent); + } + + public XmlElementRefsMapping buildJavaXmlElementRefsMapping(JaxbPersistentAttribute parent) { + return new GenericJavaXmlElementRefsMapping(parent); + } + + public XmlElementsMapping buildJavaXmlElementsMapping(JaxbPersistentAttribute parent) { + return new GenericJavaXmlElementsMapping(parent); + } + + public XmlMixedMapping buildJavaXmlMixedMapping(JaxbPersistentAttribute parent) { + return new GenericJavaXmlMixedMapping(parent); + } + public XmlValueMapping buildJavaXmlValueMapping(JaxbPersistentAttribute parent) { return new GenericJavaXmlValueMapping(parent); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java index 6990ad0363..ba939e4245 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementMapping.java @@ -261,6 +261,11 @@ public class GenericJavaXmlElementMapping public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); + // If the property or field type is a parametric collection type, then @XmlElement.type() + // must be DEFAULT.class or collectionitem.class (since the type of the collection is + // already known). [ JAXB 2.2 spec, 8.9.1.2 ] +// if (getPersistentAttribute().getResourceType()) + if (this.getXmlElementWrapper() != null) { this.getXmlElementWrapper().validate(messages, reporter, astRoot); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java index dc7e6df0d1..d728cf1e95 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefMapping.java @@ -11,12 +11,14 @@ package org.eclipse.jpt.jaxb.core.internal.context.java; import org.eclipse.jpt.jaxb.core.MappingKeys; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefMapping; import org.eclipse.jpt.jaxb.core.resource.java.JAXB; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation; public class GenericJavaXmlElementRefMapping - extends AbstractJavaAttributeMapping<XmlElementRefAnnotation> { + extends AbstractJavaAttributeMapping<XmlElementRefAnnotation> + implements XmlElementRefMapping { public GenericJavaXmlElementRefMapping(JaxbPersistentAttribute parent) { super(parent); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java index 0cdbc4d3bd..ce8f2b47ad 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementRefsMapping.java @@ -11,12 +11,14 @@ package org.eclipse.jpt.jaxb.core.internal.context.java; import org.eclipse.jpt.jaxb.core.MappingKeys; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.context.XmlElementRefsMapping; import org.eclipse.jpt.jaxb.core.resource.java.JAXB; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefsAnnotation; public class GenericJavaXmlElementRefsMapping - extends AbstractJavaAttributeMapping<XmlElementRefsAnnotation> { + extends AbstractJavaAttributeMapping<XmlElementRefsAnnotation> + implements XmlElementRefsMapping { public GenericJavaXmlElementRefsMapping(JaxbPersistentAttribute parent) { super(parent); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java index 9aae42ed46..ab03647160 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlElementsMapping.java @@ -11,12 +11,14 @@ package org.eclipse.jpt.jaxb.core.internal.context.java; import org.eclipse.jpt.jaxb.core.MappingKeys; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping; import org.eclipse.jpt.jaxb.core.resource.java.JAXB; import org.eclipse.jpt.jaxb.core.resource.java.XmlElementsAnnotation; public class GenericJavaXmlElementsMapping - extends AbstractJavaAttributeMapping<XmlElementsAnnotation> { + extends AbstractJavaAttributeMapping<XmlElementsAnnotation> + implements XmlElementsMapping { public GenericJavaXmlElementsMapping(JaxbPersistentAttribute parent) { super(parent); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixedMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixedMapping.java new file mode 100644 index 0000000000..10eca0f4d1 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaXmlMixedMapping.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.internal.context.java; + +import org.eclipse.jpt.jaxb.core.MappingKeys; +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.context.XmlMixedMapping; +import org.eclipse.jpt.jaxb.core.resource.java.JAXB; +import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation; + + +public class GenericJavaXmlMixedMapping + extends AbstractJavaAttributeMapping<XmlMixedAnnotation> + implements XmlMixedMapping { + + public GenericJavaXmlMixedMapping(JaxbPersistentAttribute parent) { + super(parent); + } + + + public String getKey() { + return MappingKeys.XML_MIXED_ATTRIBUTE_MAPPING_KEY; + } + + @Override + protected String getAnnotationName() { + return JAXB.XML_MIXED; + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java index 77c8b1b1c1..a447555cbd 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlAnyElementMappingDefinition.java @@ -21,44 +21,46 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation; public class JavaXmlAnyElementMappingDefinition - extends AbstractJavaAttributeMappingDefinition -{ + extends AbstractJavaAttributeMappingDefinition { + // singleton private static final JavaXmlAnyElementMappingDefinition INSTANCE = new JavaXmlAnyElementMappingDefinition(); - - + + private static final String[] SUPPORTING_ANNOTATION_NAMES = + { + XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME, + XmlMixedAnnotation.ANNOTATION_NAME }; + + /** * Return the singleton. */ public static JavaAttributeMappingDefinition instance() { return INSTANCE; } - - private static final String[] SUPPORTING_ANNOTATION_NAMES = - {XmlJavaTypeAdapterAnnotation.ANNOTATION_NAME, - XmlMixedAnnotation.ANNOTATION_NAME}; - + + /** * Enforce singleton usage */ private JavaXmlAnyElementMappingDefinition() { super(); } - - + + public String getKey() { return MappingKeys.XML_ANY_ELEMENT_ATTRIBUTE_MAPPING_KEY; } - + public String getAnnotationName() { return XmlAnyElementAnnotation.ANNOTATION_NAME; } - + public Iterable<String> getSupportingAnnotationNames() { return new ArrayListIterable<String>(SUPPORTING_ANNOTATION_NAMES); } - + public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) { return factory.buildJavaXmlAnyElementMapping(parent); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java index 9ed795cbc7..061d49863d 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementMappingDefinition.java @@ -9,8 +9,6 @@ ******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.context.java; -import java.util.Collection; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; import org.eclipse.jpt.jaxb.core.JaxbFactory; import org.eclipse.jpt.jaxb.core.MappingKeys; @@ -85,14 +83,13 @@ public class JavaXmlElementMappingDefinition * <li> @XmlElement * </ul> * <li> otherwise the default mapping annotation is:<ul> - * <li> @XmlElements({ @XmlElement(nillable=true)}) + * <li> @XmlElements({ @XmlElement(nillable=true)}) + * (NB: this actually means the same as + * @XmlElement(nillable=true) + * ) * </ul> */ public boolean isDefault(JaxbPersistentAttribute persistentAttribute) { - JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute(); - if (resourceAttribute.typeIsSubTypeOf(Collection.class.getName())) { - return resourceAttribute.getAnnotation(JAXB.XML_LIST) != null; - } return true; } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java index 8d116fe3e5..3c07d7bb30 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefMappingDefinition.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.context.java; import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; @@ -47,7 +56,6 @@ public class JavaXmlElementRefMappingDefinition } public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) { - // TODO: move to factory once API opens up again - return new GenericJavaXmlElementRefMapping(parent); + return factory.buildJavaXmlElementRefsMapping(parent); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java index 5c33c1e390..8a5e44a960 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementRefsMappingDefinition.java @@ -1,3 +1,12 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.context.java; import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; @@ -47,7 +56,6 @@ public class JavaXmlElementRefsMappingDefinition } public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) { - // TODO: move to factory once API opens up again - return new GenericJavaXmlElementRefsMapping(parent); + return factory.buildJavaXmlElementRefsMapping(parent); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java index 36f82cd2f5..e9556e627d 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlElementsMappingDefinition.java @@ -1,28 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ package org.eclipse.jpt.jaxb.core.internal.context.java; -import java.util.Collection; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; import org.eclipse.jpt.jaxb.core.JaxbFactory; import org.eclipse.jpt.jaxb.core.MappingKeys; import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; -import org.eclipse.jpt.jaxb.core.context.java.DefaultJavaAttributeMappingDefinition; +import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition; import org.eclipse.jpt.jaxb.core.resource.java.JAXB; public class JavaXmlElementsMappingDefinition - extends AbstractJavaAttributeMappingDefinition - implements DefaultJavaAttributeMappingDefinition { + extends AbstractJavaAttributeMappingDefinition { // singleton - private static final DefaultJavaAttributeMappingDefinition INSTANCE = new JavaXmlElementsMappingDefinition(); + private static final JavaAttributeMappingDefinition INSTANCE + = new JavaXmlElementsMappingDefinition(); /** * Return the singleton. */ - public static DefaultJavaAttributeMappingDefinition instance() { + public static JavaAttributeMappingDefinition instance() { return INSTANCE; } @@ -51,30 +58,6 @@ public class JavaXmlElementsMappingDefinition } public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) { - // TODO: move to factory once API opens up again - return new GenericJavaXmlElementsMapping(parent); - } - - /** - * From the JAXB spec section 8.12.5.1 Default Mapping: - * <p> - * A single valued property or field must be mapped by with the following default mapping annotation:<ul> - * <li> @XmlElement - * </ul> - * <p> - * A property or field with a collection type must be mapped by with the following default mapping annotation:<ul> - * <li> if the property or field is annotated with @XmlList, then the default mapping annotation is:<ul> - * <li> @XmlElement - * </ul> - * <li> otherwise the default mapping annotation is:<ul> - * <li> @XmlElements({ @XmlElement(nillable=true)}) - * </ul> - */ - public boolean isDefault(JaxbPersistentAttribute persistentAttribute) { - JavaResourceAttribute resourceAttribute = persistentAttribute.getJavaResourceAttribute(); - if (resourceAttribute.typeIsSubTypeOf(Collection.class.getName())) { - return resourceAttribute.getAnnotation(JAXB.XML_LIST) == null; - } - return true; + return factory.buildJavaXmlElementsMapping(parent); } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlMixedMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlMixedMappingDefinition.java new file mode 100644 index 0000000000..e08f852eaf --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/JavaXmlMixedMappingDefinition.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.internal.context.java; + +import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; +import org.eclipse.jpt.jaxb.core.JaxbFactory; +import org.eclipse.jpt.jaxb.core.MappingKeys; +import org.eclipse.jpt.jaxb.core.context.JaxbAttributeMapping; +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.context.java.JavaAttributeMappingDefinition; +import org.eclipse.jpt.jaxb.core.resource.java.JAXB; + + +public class JavaXmlMixedMappingDefinition + extends AbstractJavaAttributeMappingDefinition{ + + // singleton + private static final JavaXmlMixedMappingDefinition INSTANCE = + new JavaXmlMixedMappingDefinition(); + + private static final String[] SUPPORTING_ANNOTATION_NAMES = + { JAXB.XML_JAVA_TYPE_ADAPTER }; + + + /** + * Return the singleton. + */ + public static JavaAttributeMappingDefinition instance() { + return INSTANCE; + } + + + /** + * Enforce singleton usage + */ + private JavaXmlMixedMappingDefinition() { + super(); + } + + + public String getKey() { + return MappingKeys.XML_MIXED_ATTRIBUTE_MAPPING_KEY; + } + + public String getAnnotationName() { + return JAXB.XML_MIXED; + } + + public Iterable<String> getSupportingAnnotationNames() { + return new ArrayListIterable<String>(SUPPORTING_ANNOTATION_NAMES); + } + + public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute parent, JaxbFactory factory) { + return factory.buildJavaXmlMixedMapping(parent); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java index fda7d2ec4b..81a5a525fc 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/jaxb21/GenericJaxb_2_1_PlatformDefinition.java @@ -155,7 +155,6 @@ public class GenericJaxb_2_1_PlatformDefinition @Override protected void addDefaultJavaAttributeMappingDefinitionsTo(ArrayList<DefaultJavaAttributeMappingDefinition> definitions) { definitions.add(JavaXmlElementMappingDefinition.instance()); - definitions.add(JavaXmlElementsMappingDefinition.instance()); } @Override |