diff options
author | pfullbright | 2012-01-12 16:53:07 +0000 |
---|---|---|
committer | pfullbright | 2012-01-12 16:53:07 +0000 |
commit | 80426572211ad924876322ea3bbca31ea2233d25 (patch) | |
tree | b3a9d9c81039fbd3b73ed9d5d8851be95a2f7421 /jaxb | |
parent | 83e29648c14f001f53a88da67c6f2232873b0f97 (diff) | |
download | webtools.dali-80426572211ad924876322ea3bbca31ea2233d25.tar.gz webtools.dali-80426572211ad924876322ea3bbca31ea2233d25.tar.xz webtools.dali-80426572211ad924876322ea3bbca31ea2233d25.zip |
XmlPath context model support for xml any attribute/xml any element/xml elements mappings
Diffstat (limited to 'jaxb')
19 files changed, 655 insertions, 70 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF index 97a0691986..ff289b3926 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF @@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)", org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)", org.eclipse.wst.validation;bundle-version="[1.2.300,2.0.0)" Export-Package: org.eclipse.jpt.jaxb.eclipselink.core, + org.eclipse.jpt.jaxb.eclipselink.core.context.java, org.eclipse.jpt.jaxb.eclipselink.core.internal;x-internal:=true, org.eclipse.jpt.jaxb.eclipselink.core.internal.context;x-internal:=true, org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java;x-internal:=true, diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyAttributeMapping.java new file mode 100644 index 0000000000..b36fa72810 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyAttributeMapping.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.context.java; + +import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; + + +public interface ELXmlAnyAttributeMapping + extends XmlAnyAttributeMapping, ELXmlPathMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyElementMapping.java new file mode 100644 index 0000000000..e48f53639c --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlAnyElementMapping.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.context.java; + +import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping; + + +public interface ELXmlAnyElementMapping + extends XmlAnyElementMapping, ELXmlPathMapping { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementsMapping.java new file mode 100644 index 0000000000..3de17ac599 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlElementsMapping.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.context.java; + +import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; +import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping; + + +public interface ELXmlElementsMapping + extends XmlElementsMapping { + + // ***** xmlPaths ***** + + /** + * String associated with changes to the xmlPaths list + */ + String XML_PATHS_LIST = "xmlPaths"; ///$NON-NLS-1$ + + ListIterable<ELXmlPath> getXmlPaths(); + + int getXmlPathsSize(); + + ELXmlPath addXmlPath(int index); + + void removeXmlPath(int index); + + void moveXmlPath(int targetIndex, int sourceIndex); +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlNamedNodeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlNamedNodeMapping.java index 3d9f275443..053988f460 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlNamedNodeMapping.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlNamedNodeMapping.java @@ -25,30 +25,6 @@ import org.eclipse.jpt.jaxb.core.context.XmlNamedNodeMapping; * @since 3.2 */ public interface ELXmlNamedNodeMapping - extends XmlNamedNodeMapping { + extends XmlNamedNodeMapping, ELXmlPathMapping { - // ***** xmlPath ***** - - /** - * String associated with changes to the xmlPath property - */ - String XML_PATH_PROPERTY = "xmlPath"; ///$NON-NLS-1$ - - /** - * Return the xmlPath property value. - * A null indicates it is not specified. - */ - ELXmlPath getXmlPath(); - - /** - * Add (and return) an xmlPath property value. - * (Specifies the property) - */ - ELXmlPath addXmlPath(); - - /** - * Remove the xmlPath property value. - * (Unspecifies the property) - */ - void removeXmlPath(); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPath.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPath.java index c61cf761da..e7fc0d03f0 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPath.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPath.java @@ -9,8 +9,11 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.eclipselink.core.context.java; +import org.eclipse.jpt.jaxb.core.context.JaxbContextNode; -public interface ELXmlPath { + +public interface ELXmlPath + extends JaxbContextNode { // ***** value ***** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPathMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPathMapping.java new file mode 100644 index 0000000000..d48572ec63 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/java/ELXmlPathMapping.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.context.java; + + +public interface ELXmlPathMapping { + + // ***** xmlPath ***** + + /** + * String associated with changes to the xmlPath property + */ + String XML_PATH_PROPERTY = "xmlPath"; ///$NON-NLS-1$ + + /** + * Return the xmlPath property value. + * A null indicates it is not specified. + */ + ELXmlPath getXmlPath(); + + /** + * Add (and return) an xmlPath property value. + * (Specifies the property) + */ + ELXmlPath addXmlPath(); + + /** + * Remove the xmlPath property value. + * (Unspecifies the property) + */ + void removeXmlPath(); +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMapping.java new file mode 100644 index 0000000000..8ae4e0768b --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMapping.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyAttributeMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlAnyAttributeMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlPath; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation; + + +public class ELJavaXmlAnyAttributeMapping + extends GenericJavaXmlAnyAttributeMapping + implements ELXmlAnyAttributeMapping { + + private ELJavaXmlPath xmlPath; + + + public ELJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) { + super(parent); + initXmlPath(); + } + + + // ***** sync/update ***** + + @Override + public void synchronizeWithResourceModel() { + super.synchronizeWithResourceModel(); + syncXmlPath(); + } + + + // ***** XmlPath ***** + + public ELXmlPath getXmlPath() { + return this.xmlPath; + } + + protected void setXmlPath_(ELJavaXmlPath xmlPath) { + ELJavaXmlPath old = this.xmlPath; + this.xmlPath = xmlPath; + firePropertyChanged(XML_PATH_PROPERTY, old, this.xmlPath); + } + + public ELXmlPath addXmlPath() { + if (this.xmlPath != null) { + throw new IllegalStateException(); + } + getJavaResourceAttribute().addAnnotation(0, ELJaxb.XML_PATH); + ELJavaXmlPath xmlPath = buildXmlPath(); + setXmlPath_(xmlPath); + return xmlPath; + } + + public void removeXmlPath() { + if (this.xmlPath == null) { + throw new IllegalStateException(); + } + while (getXmlPathAnnotation() != null) { + getJavaResourceAttribute().removeAnnotation(0, ELJaxb.XML_PATH); + } + setXmlPath_(null); + } + + protected void initXmlPath() { + XmlPathAnnotation annotation = getXmlPathAnnotation(); + this.xmlPath = (annotation == null) ? null : buildXmlPath(); + } + + protected void syncXmlPath() { + XmlPathAnnotation annotation = getXmlPathAnnotation(); + if (annotation != null) { + if (this.xmlPath == null) { + setXmlPath_(buildXmlPath()); + } + else { + this.xmlPath.synchronizeWithResourceModel(); + } + } + else { + setXmlPath_(null); + } + } + + protected ELJavaXmlPath buildXmlPath() { + return new ELJavaXmlPath(this, new XmlPathContext()); + } + + protected XmlPathAnnotation getXmlPathAnnotation() { + return (XmlPathAnnotation) getJavaResourceAttribute().getAnnotation(0, ELJaxb.XML_PATH); + } + + + protected class XmlPathContext + implements ELJavaXmlPath.Context { + + public XmlPathAnnotation getAnnotation() { + return ELJavaXmlAnyAttributeMapping.this.getXmlPathAnnotation(); + } + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMappingDefinition.java new file mode 100644 index 0000000000..0735a5e3bd --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyAttributeMappingDefinition.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; +import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; +import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyAttributeMappingDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; + + +public class ELJavaXmlAnyAttributeMappingDefinition + extends JavaXmlAnyAttributeMappingDefinition { + + // singleton + private static final ELJavaXmlAnyAttributeMappingDefinition INSTANCE = + new ELJavaXmlAnyAttributeMappingDefinition(); + + private static final String[] SUPPORTING_ANNOTATION_NAMES = + { + ELJaxb.XML_PATH }; + + /** + * Return the singleton. + */ + public static ELJavaXmlAnyAttributeMappingDefinition instance() { + return INSTANCE; + } + + + /** + * Enforce singleton usage + */ + protected ELJavaXmlAnyAttributeMappingDefinition() { + super(); + } + + + @Override + public Iterable<String> getSupportingAnnotationNames() { + return new CompositeIterable<String>( + super.getSupportingAnnotationNames(), + new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMapping.java new file mode 100644 index 0000000000..5cbe938ca4 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMapping.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlAnyElementMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlPath; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation; + + +public class ELJavaXmlAnyElementMapping + extends GenericJavaXmlAnyElementMapping + implements ELXmlAnyElementMapping { + + private ELJavaXmlPath xmlPath; + + + public ELJavaXmlAnyElementMapping(JaxbPersistentAttribute parent) { + super(parent); + initXmlPath(); + } + + + // ***** sync/update ***** + + @Override + public void synchronizeWithResourceModel() { + super.synchronizeWithResourceModel(); + syncXmlPath(); + } + + + // ***** XmlPath ***** + + public ELXmlPath getXmlPath() { + return this.xmlPath; + } + + protected void setXmlPath_(ELJavaXmlPath xmlPath) { + ELJavaXmlPath old = this.xmlPath; + this.xmlPath = xmlPath; + firePropertyChanged(XML_PATH_PROPERTY, old, this.xmlPath); + } + + public ELXmlPath addXmlPath() { + if (this.xmlPath != null) { + throw new IllegalStateException(); + } + getJavaResourceAttribute().addAnnotation(0, ELJaxb.XML_PATH); + ELJavaXmlPath xmlPath = buildXmlPath(); + setXmlPath_(xmlPath); + return xmlPath; + } + + public void removeXmlPath() { + if (this.xmlPath == null) { + throw new IllegalStateException(); + } + while (getXmlPathAnnotation() != null) { + getJavaResourceAttribute().removeAnnotation(0, ELJaxb.XML_PATH); + } + setXmlPath_(null); + } + + protected void initXmlPath() { + XmlPathAnnotation annotation = getXmlPathAnnotation(); + this.xmlPath = (annotation == null) ? null : buildXmlPath(); + } + + protected void syncXmlPath() { + XmlPathAnnotation annotation = getXmlPathAnnotation(); + if (annotation != null) { + if (this.xmlPath == null) { + setXmlPath_(buildXmlPath()); + } + else { + this.xmlPath.synchronizeWithResourceModel(); + } + } + else { + setXmlPath_(null); + } + } + + protected ELJavaXmlPath buildXmlPath() { + return new ELJavaXmlPath(this, new XmlPathContext()); + } + + protected XmlPathAnnotation getXmlPathAnnotation() { + return (XmlPathAnnotation) getJavaResourceAttribute().getAnnotation(0, ELJaxb.XML_PATH); + } + + + protected class XmlPathContext + implements ELJavaXmlPath.Context { + + public XmlPathAnnotation getAnnotation() { + return ELJavaXmlAnyElementMapping.this.getXmlPathAnnotation(); + } + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMappingDefinition.java new file mode 100644 index 0000000000..56a5cd9112 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAnyElementMappingDefinition.java @@ -0,0 +1,43 @@ +package org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; +import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; +import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAnyElementMappingDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; + + +public class ELJavaXmlAnyElementMappingDefinition + extends JavaXmlAnyElementMappingDefinition { + + // singleton + private static final ELJavaXmlAnyElementMappingDefinition INSTANCE = + new ELJavaXmlAnyElementMappingDefinition(); + + + private static final String[] SUPPORTING_ANNOTATION_NAMES = + { + ELJaxb.XML_PATH }; + + /** + * Return the singleton. + */ + public static ELJavaXmlAnyElementMappingDefinition instance() { + return INSTANCE; + } + + + /** + * Enforce singleton usage + */ + protected ELJavaXmlAnyElementMappingDefinition() { + super(); + } + + + @Override + public Iterable<String> getSupportingAnnotationNames() { + return new CompositeIterable<String>( + super.getSupportingAnnotationNames(), + new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAttributeMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAttributeMappingDefinition.java index f20086587c..1f51fb4d4c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAttributeMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlAttributeMappingDefinition.java @@ -12,18 +12,15 @@ package org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java; import java.util.StringTokenizer; import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.jaxb.core.JaxbFactory; -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.internal.context.java.AbstractJavaAttributeMappingDefinition; import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlAttributeMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation; public class ELJavaXmlAttributeMappingDefinition - extends AbstractJavaAttributeMappingDefinition + extends JavaXmlAttributeMappingDefinition implements DefaultJavaAttributeMappingDefinition { // singleton @@ -45,29 +42,18 @@ public class ELJavaXmlAttributeMappingDefinition /** * Enforce singleton usage */ - private ELJavaXmlAttributeMappingDefinition() { + protected ELJavaXmlAttributeMappingDefinition() { super(); } - public String getKey() { - return JavaXmlAttributeMappingDefinition.instance().getKey(); - } - - public String getAnnotationName() { - return JavaXmlAttributeMappingDefinition.instance().getKey(); - } - + @Override public Iterable<String> getSupportingAnnotationNames() { return new CompositeIterable<String>( - JavaXmlAttributeMappingDefinition.instance().getSupportingAnnotationNames(), + super.getSupportingAnnotationNames(), new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES)); } - public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute persistentAttribute, JaxbFactory factory) { - return JavaXmlAttributeMappingDefinition.instance().buildMapping(persistentAttribute, factory); - } - public boolean isDefault(JaxbPersistentAttribute persistentAttribute) { // test whether annotated with @XmlPath, and if so, if last segment starts with "@" // (presence of "@" elsewhere may be a node select clause) diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementMappingDefinition.java index 948825eeeb..88d4d9858c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementMappingDefinition.java @@ -11,18 +11,13 @@ package org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java; import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.jaxb.core.JaxbFactory; -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.internal.context.java.AbstractJavaAttributeMappingDefinition; import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; public class ELJavaXmlElementMappingDefinition - extends AbstractJavaAttributeMappingDefinition - implements DefaultJavaAttributeMappingDefinition { + extends JavaXmlElementMappingDefinition { // singleton private static final ELJavaXmlElementMappingDefinition INSTANCE = @@ -43,30 +38,15 @@ public class ELJavaXmlElementMappingDefinition /** * Enforce singleton usage */ - private ELJavaXmlElementMappingDefinition() { + protected ELJavaXmlElementMappingDefinition() { super(); } - public String getKey() { - return JavaXmlElementMappingDefinition.instance().getKey(); - } - - public String getAnnotationName() { - return JavaXmlElementMappingDefinition.instance().getKey(); - } - + @Override public Iterable<String> getSupportingAnnotationNames() { return new CompositeIterable<String>( - JavaXmlElementMappingDefinition.instance().getSupportingAnnotationNames(), + super.getSupportingAnnotationNames(), new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES)); } - - public JaxbAttributeMapping buildMapping(JaxbPersistentAttribute persistentAttribute, JaxbFactory factory) { - return JavaXmlElementMappingDefinition.instance().buildMapping(persistentAttribute, factory); - } - - public boolean isDefault(JaxbPersistentAttribute persistentAttribute) { - return JavaXmlElementMappingDefinition.instance().isDefault(persistentAttribute); - } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMapping.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMapping.java new file mode 100644 index 0000000000..c60036c938 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMapping.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.common.core.resource.java.NestableAnnotation; +import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; +import org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper; +import org.eclipse.jpt.common.utility.internal.iterables.SuperListIterableWrapper; +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlElementsMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlElementsMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.context.java.ELXmlPath; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.XmlPathAnnotation; + + +public class ELJavaXmlElementsMapping + extends GenericJavaXmlElementsMapping + implements ELXmlElementsMapping { + + protected final ContextListContainer<ELJavaXmlPath, XmlPathAnnotation> xmlPathContainer; + + + public ELJavaXmlElementsMapping(JaxbPersistentAttribute parent) { + super(parent); + this.xmlPathContainer = buildXmlPathContainer(); + } + + + // ***** sync/update ***** + + @Override + public void synchronizeWithResourceModel() { + super.synchronizeWithResourceModel(); + this.xmlPathContainer.synchronizeWithResourceModel(); + } + + @Override + public void update() { + super.update(); + this.xmlPathContainer.update(); + } + + + // ***** xmlPaths ***** + + public ListIterable<ELXmlPath> getXmlPaths() { + return new SuperListIterableWrapper<ELXmlPath>(xmlPathContainer.getContextElements()); + } + + public int getXmlPathsSize() { + return this.xmlPathContainer.getContextElementsSize(); + } + + public ELXmlPath addXmlPath(int index) { + XmlPathAnnotation annotation = (XmlPathAnnotation) getJavaResourceAttribute().addAnnotation(index, ELJaxb.XML_PATH); + return this.xmlPathContainer.addContextElement(index, annotation); + } + + public void removeXmlPath(int index) { + getJavaResourceAttribute().removeAnnotation(index, ELJaxb.XML_PATH); + this.xmlPathContainer.removeContextElement(index); + } + + public void moveXmlPath(int targetIndex, int sourceIndex) { + getJavaResourceAttribute().moveAnnotation(targetIndex, sourceIndex, ELJaxb.XML_PATH); + this.xmlPathContainer.moveContextElement(targetIndex, sourceIndex); + } + + protected ELJavaXmlPath buildXmlPath(XmlPathAnnotation xmlPathAnnotation) { + return new ELJavaXmlPath(this, new XmlPathContext(xmlPathAnnotation)); + } + + protected ContextListContainer<ELJavaXmlPath, XmlPathAnnotation> buildXmlPathContainer() { + XmlPathContainer container = new XmlPathContainer(); + container.initialize(); + return container; + } + + protected ListIterable<XmlPathAnnotation> getXmlPathAnnotations() { + return new SubListIterableWrapper<NestableAnnotation, XmlPathAnnotation>( + getJavaResourceAttribute().getAnnotations(ELJaxb.XML_PATH)); + } + + + protected class XmlPathContainer + extends ContextListContainer<ELJavaXmlPath, XmlPathAnnotation> { + + @Override + protected String getContextElementsPropertyName() { + return ELXmlElementsMapping.XML_PATHS_LIST; + } + + @Override + protected ELJavaXmlPath buildContextElement(XmlPathAnnotation resourceElement) { + return ELJavaXmlElementsMapping.this.buildXmlPath(resourceElement); + } + + @Override + protected ListIterable<XmlPathAnnotation> getResourceElements() { + return ELJavaXmlElementsMapping.this.getXmlPathAnnotations(); + } + + @Override + protected XmlPathAnnotation getResourceElement(ELJavaXmlPath contextElement) { + // in the context of this mapping, there will never be an ELXmlPath without an annotation + return contextElement.getAnnotation(); + } + } + + + protected class XmlPathContext + implements ELJavaXmlPath.Context { + + protected XmlPathAnnotation annotation; + + + protected XmlPathContext(XmlPathAnnotation annotation) { + this.annotation = annotation; + } + + public XmlPathAnnotation getAnnotation() { + return this.annotation; + } + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMappingDefinition.java new file mode 100644 index 0000000000..20cbd364f2 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlElementsMappingDefinition.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012 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.eclipselink.core.internal.context.java; + +import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; +import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; +import org.eclipse.jpt.jaxb.core.internal.context.java.JavaXmlElementsMappingDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.resource.java.ELJaxb; + + +public class ELJavaXmlElementsMappingDefinition + extends JavaXmlElementsMappingDefinition { + + + // singleton + private static final ELJavaXmlElementsMappingDefinition INSTANCE = + new ELJavaXmlElementsMappingDefinition(); + + + private static final String[] SUPPORTING_ANNOTATION_NAMES = + { + ELJaxb.XML_PATH }; + + /** + * Return the singleton. + */ + public static ELJavaXmlElementsMappingDefinition instance() { + return INSTANCE; + } + + + /** + * Enforce singleton usage + */ + protected ELJavaXmlElementsMappingDefinition() { + super(); + } + + + @Override + public Iterable<String> getSupportingAnnotationNames() { + return new CompositeIterable<String>( + super.getSupportingAnnotationNames(), + new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java index a62e305ea0..17b1cf27c6 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlInverseReferenceMappingDefinition.java @@ -28,7 +28,7 @@ public class ELJavaXmlInverseReferenceMappingDefinition /** * Enforce singleton usage */ - private ELJavaXmlInverseReferenceMappingDefinition() { + protected ELJavaXmlInverseReferenceMappingDefinition() { super(); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java index 852c0810d0..afd05f47a2 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/java/ELJavaXmlTransformationMappingDefinition.java @@ -37,7 +37,7 @@ public class ELJavaXmlTransformationMappingDefinition /** * Enforce singleton usage */ - private ELJavaXmlTransformationMappingDefinition() { + protected ELJavaXmlTransformationMappingDefinition() { super(); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java index 76c7ee9ded..6acf97064a 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java @@ -13,12 +13,18 @@ import org.eclipse.jpt.jaxb.core.JaxbFactory; import org.eclipse.jpt.jaxb.core.JaxbProject; import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute; +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.XmlElementsMapping; import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbFactory; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.ELJaxbContextRoot; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAnyAttributeMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAnyElementMapping; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAttributeMapping; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementMapping; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementsMapping; public class ELJaxb_2_1_Factory @@ -50,6 +56,16 @@ public class ELJaxb_2_1_Factory } @Override + public XmlAnyAttributeMapping buildJavaXmlAnyAttributeMapping(JaxbPersistentAttribute parent) { + return new ELJavaXmlAnyAttributeMapping(parent); + } + + @Override + public XmlAnyElementMapping buildJavaXmlAnyElementMapping(JaxbPersistentAttribute parent) { + return new ELJavaXmlAnyElementMapping(parent); + } + + @Override public XmlAttributeMapping buildJavaXmlAttributeMapping(JaxbPersistentAttribute parent) { return new ELJavaXmlAttributeMapping(parent); } @@ -58,4 +74,9 @@ public class ELJaxb_2_1_Factory public XmlElementMapping buildJavaXmlElementMapping(JaxbPersistentAttribute parent) { return new ELJavaXmlElementMapping(parent); } + + @Override + public XmlElementsMapping buildJavaXmlElementsMapping(JaxbPersistentAttribute parent) { + return new ELJavaXmlElementsMapping(parent); + } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java index 53b24cd9d0..6a7aa2e8a0 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java @@ -25,8 +25,11 @@ import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition; import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription; import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbPlatform; import org.eclipse.jpt.jaxb.eclipselink.core.internal.AbstractELJaxbPlatformDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAnyAttributeMappingDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAnyElementMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAttributeMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementMappingDefinition; +import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlElementsMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlInverseReferenceMappingDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlInverseReferenceAnnotationDefinition; import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlPathAnnotationDefinition; @@ -106,6 +109,11 @@ public class ELJaxb_2_1_PlatformDefinition protected void addSpecifiedJavaAttributeMappingDefinitionsTo( ArrayList<JavaAttributeMappingDefinition> definitions) { CollectionTools.addAll(definitions, getGenericJaxbPlatformDefinition().getSpecifiedJavaAttributeMappingDefinitions()); + CollectionTools.addAll(definitions, ELJavaXmlAnyAttributeMappingDefinition.instance()); + CollectionTools.addAll(definitions, ELJavaXmlAnyElementMappingDefinition.instance()); + CollectionTools.addAll(definitions, ELJavaXmlAttributeMappingDefinition.instance()); + CollectionTools.addAll(definitions, ELJavaXmlElementMappingDefinition.instance()); + CollectionTools.addAll(definitions, ELJavaXmlElementsMappingDefinition.instance()); CollectionTools.addAll(definitions, ELJavaXmlInverseReferenceMappingDefinition.instance()); } } |