Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtaal2011-02-21 06:40:04 +0000
committermtaal2011-02-21 06:40:04 +0000
commit46dbdb0abe5dbfa186bba7245c7f8fb8f5f66db8 (patch)
treea90778fe019c8ffe6a1273e78004663664fd6e3a
parent1b51bd9734806c5b1dd92d8d3f9057429a8d0c84 (diff)
downloadorg.eclipse.emf.teneo-46dbdb0abe5dbfa186bba7245c7f8fb8f5f66db8.tar.gz
org.eclipse.emf.teneo-46dbdb0abe5dbfa186bba7245c7f8fb8f5f66db8.tar.xz
org.eclipse.emf.teneo-46dbdb0abe5dbfa186bba7245c7f8fb8f5f66db8.zip
[337580]
-rw-r--r--plugins/org.eclipse.emf.teneo/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/PersistenceOptions.java21
-rw-r--r--plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/parser/ComplexNode.java64
-rw-r--r--plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/xml/XmlPersistenceContentHandler.java164
4 files changed, 167 insertions, 84 deletions
diff --git a/plugins/org.eclipse.emf.teneo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.teneo/META-INF/MANIFEST.MF
index 638c00701..9ef54f5e7 100644
--- a/plugins/org.eclipse.emf.teneo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.teneo/META-INF/MANIFEST.MF
@@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.emf.common;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)",
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.emf.teneo.annotations
+ org.eclipse.emf.teneo.annotations;bundle-version="[1.2.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.emf.teneo;version="1.1.2",
org.eclipse.emf.teneo.annotations;version="1.1.2",
diff --git a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/PersistenceOptions.java b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/PersistenceOptions.java
index 36735de07..84a922d46 100644
--- a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/PersistenceOptions.java
+++ b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/PersistenceOptions.java
@@ -13,7 +13,7 @@
* Jason Henriksen - XSDDate and XSDDateTime constants
* </copyright>
*
- * $Id: PersistenceOptions.java,v 1.67 2011/01/20 17:12:40 mtaal Exp $
+ * $Id: PersistenceOptions.java,v 1.68 2011/02/21 06:40:04 mtaal Exp $
*/
package org.eclipse.emf.teneo;
@@ -39,7 +39,7 @@ import org.eclipse.emf.teneo.extension.ExtensionPoint;
* As a convenience, this class offers type-safe property accessor wrappers.
*
* @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
- * @version $Revision: 1.67 $
+ * @version $Revision: 1.68 $
*/
public class PersistenceOptions implements ExtensionPoint {
@@ -155,6 +155,13 @@ public class PersistenceOptions implements ExtensionPoint {
public static final String SQL_INDEX_KEY_NAME_PREFIX = NAMING_PREFIX
+ "sql_index_name_prefix";
+ /**
+ * Controls if manually set sql names (table name, column names) should also
+ * be truncated or cased. Default is true for backward compatability.
+ */
+ public static final String AUTO_ADAPT_MANUAL_SET_SQL_NAMES = NAMING_PREFIX
+ + "auto_adapt_manual_set_sql_names";
+
// END: ++++++++++++++++++++++ SQL Naming related Options
// ++++++++++++++++++++++++++++++++++++
@@ -552,6 +559,7 @@ public class PersistenceOptions implements ExtensionPoint {
Constants.COLUMN_ECONTAINER_FEATURE_NAME);
props.setProperty(FEATUREMAP_AS_COMPONENT, "false");
props.setProperty(EXTRA_ANNOTATION_SOURCES, "");
+ props.setProperty(AUTO_ADAPT_MANUAL_SET_SQL_NAMES, "true");
return props;
}
@@ -577,6 +585,15 @@ public class PersistenceOptions implements ExtensionPoint {
}
/**
+ * @return value of {@link AUTO_ADAPT_MANUAL_SET_SQL_NAMES}
+ */
+ public boolean isAutoAdaptManualSQLNames() {
+ return Boolean.valueOf(
+ properties.getProperty(AUTO_ADAPT_MANUAL_SET_SQL_NAMES))
+ .booleanValue();
+ }
+
+ /**
* @return value of {@link #ECONTAINER_COLUMN}
*/
public String getEContainerColumn() {
diff --git a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/parser/ComplexNode.java b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/parser/ComplexNode.java
index 44df5185d..0f818d71a 100644
--- a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/parser/ComplexNode.java
+++ b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/parser/ComplexNode.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: ComplexNode.java,v 1.4 2010/02/04 11:02:59 mtaal Exp $
+ * $Id: ComplexNode.java,v 1.5 2011/02/21 06:40:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.annotations.parser;
@@ -29,6 +29,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.teneo.annotations.pannotation.PAnnotation;
/**
* Models a real type (a complex type in xml schema speak), an EClass.
@@ -68,37 +69,51 @@ class ComplexNode extends NamedParserNode {
}
if (eClass == null) {
- throw new AnnotationParserException("No eclass found with name " + getName());
+ throw new AnnotationParserException("No eclass found with name "
+ + getName());
}
final EObject eobj = EcoreUtil.create(eClass);
+ ((PAnnotation) eobj).setGenerated(false);
for (NamedParserNode child : children) {
- final EStructuralFeature efeature = ecr.getEStructuralFeature(eClass, child.getName());
+ final EStructuralFeature efeature = ecr.getEStructuralFeature(
+ eClass, child.getName());
if (child instanceof PrimitiveValueNode) {
final PrimitiveValueNode pvn = (PrimitiveValueNode) child;
- log.debug("Primitive child: " + pvn.getName() + ": " + pvn.getValue());
+ log.debug("Primitive child: " + pvn.getName() + ": "
+ + pvn.getValue());
if (!(efeature instanceof EAttribute)) {
- throw new AnnotationParserException("The EFeature " + efeature.getName() + "/" + eClass.getName() +
- " is not an eattribute but a " + efeature.getClass().getName());
+ throw new AnnotationParserException("The EFeature "
+ + efeature.getName() + "/" + eClass.getName()
+ + " is not an eattribute but a "
+ + efeature.getClass().getName());
}
final EClassifier eType = efeature.getEType();
if (!efeature.isMany()) {
- eobj.eSet(efeature, ParserUtil.convertValue((EDataType) eType, pvn.getValue()));
+ eobj.eSet(
+ efeature,
+ ParserUtil.convertValue((EDataType) eType,
+ pvn.getValue()));
} else {
final String[] sources = pvn.getValue().split("\\s+");
- log.debug("Child is many, splitting content into " + sources.length + " parts");
- final List<Object> referenced = new ArrayList<Object>(sources.length);
+ log.debug("Child is many, splitting content into "
+ + sources.length + " parts");
+ final List<Object> referenced = new ArrayList<Object>(
+ sources.length);
for (String source : sources) {
- referenced.add(ParserUtil.convertValue((EDataType) eType, source));
+ referenced.add(ParserUtil.convertValue(
+ (EDataType) eType, source));
}
final List currentList = (List) eobj.eGet(efeature);
currentList.addAll(referenced);
}
- } else if (child instanceof ArrayValueNode && efeature instanceof EAttribute) {
+ } else if (child instanceof ArrayValueNode
+ && efeature instanceof EAttribute) {
final EAttribute eattr = (EAttribute) efeature;
if (!eattr.isMany()) {
- throw new AnnotationParserException("The EFeature " + efeature.getName() + "/" + eClass.getName() +
- " is not ismany");
+ throw new AnnotationParserException("The EFeature "
+ + efeature.getName() + "/" + eClass.getName()
+ + " is not ismany");
}
log.debug("Array child with primitive values");
List<Object> list = ((ArrayValueNode) child).convert(ecr);
@@ -106,31 +121,38 @@ class ComplexNode extends NamedParserNode {
for (Object object : list) {
final String val = (String) object;
log.debug("Value " + val);
- convertedList.add(ParserUtil.convertValue((EDataType) eattr.getEType(), val));
+ convertedList.add(ParserUtil.convertValue(
+ (EDataType) eattr.getEType(), val));
}
final List currentList = (List) eobj.eGet(efeature);
currentList.addAll(convertedList);
} else if (child instanceof ArrayValueNode) {
if (!(efeature instanceof EReference)) {
- throw new AnnotationParserException("The EFeature " + efeature.getName() + "/" + eClass.getName() +
- " is not an ereference but a " + efeature.getClass().getName());
+ throw new AnnotationParserException("The EFeature "
+ + efeature.getName() + "/" + eClass.getName()
+ + " is not an ereference but a "
+ + efeature.getClass().getName());
}
final EReference eref = (EReference) efeature;
if (!eref.isMany()) {
- throw new AnnotationParserException("The EFeature " + efeature.getName() + "/" + eClass.getName() +
- " is not ismany");
+ throw new AnnotationParserException("The EFeature "
+ + efeature.getName() + "/" + eClass.getName()
+ + " is not ismany");
}
log.debug("Array child");
eobj.eSet(eref, ((ArrayValueNode) child).convert(ecr));
} else if (child instanceof ReferenceValueNode) {
if (!(efeature instanceof EReference)) {
- throw new AnnotationParserException("The EFeature " + efeature.getName() + "/" + eClass.getName() +
- " is not an ereference but a " + efeature.getClass().getName());
+ throw new AnnotationParserException("The EFeature "
+ + efeature.getName() + "/" + eClass.getName()
+ + " is not an ereference but a "
+ + efeature.getClass().getName());
}
final EReference eref = (EReference) efeature;
log.debug("Reference child " + child.getName());
if (eref.isMany()) {
- ((List) eobj.eGet(eref)).add(((ReferenceValueNode) child).convert(ecr));
+ ((List) eobj.eGet(eref)).add(((ReferenceValueNode) child)
+ .convert(ecr));
} else {
eobj.eSet(eref, ((ReferenceValueNode) child).convert(ecr));
}
diff --git a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/xml/XmlPersistenceContentHandler.java b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/xml/XmlPersistenceContentHandler.java
index ebb53fa8b..6a95b4573 100644
--- a/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/xml/XmlPersistenceContentHandler.java
+++ b/plugins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/annotations/xml/XmlPersistenceContentHandler.java
@@ -11,7 +11,7 @@
* Martin Taal
* </copyright>
*
- * $Id: XmlPersistenceContentHandler.java,v 1.9 2010/02/04 11:03:02 mtaal Exp $
+ * $Id: XmlPersistenceContentHandler.java,v 1.10 2011/02/21 06:40:04 mtaal Exp $
*/
package org.eclipse.emf.teneo.annotations.xml;
@@ -46,9 +46,11 @@ import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
- * SAX ContentHandler for processing XML persistence mapping. Used internally by {@link XmlPersistenceMapper}.
+ * SAX ContentHandler for processing XML persistence mapping. Used internally by
+ * {@link XmlPersistenceMapper}.
*/
-public class XmlPersistenceContentHandler extends DefaultHandler implements ExtensionPoint, ExtensionManagerAware {
+public class XmlPersistenceContentHandler extends DefaultHandler implements
+ ExtensionPoint, ExtensionManagerAware {
// Parse states
@@ -122,7 +124,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
// Stack of PAnnotations.
private Stack<PAnnotation> pAnnotations = new Stack<PAnnotation>();
- // The current EAttribute of the current pAnnotation. Used only for EDataTypes.
+ // The current EAttribute of the current pAnnotation. Used only for
+ // EDataTypes.
private EAttribute pAnnotationEAttribute;
// Stack of parse states.
@@ -143,8 +146,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
/** Set the schema */
public void setSchema(InputStream schema) {
- xmlElementToEStructuralFeatureMapper = getExtensionManager().getExtension(
- XmlElementToEStructuralFeatureMapper.class);
+ xmlElementToEStructuralFeatureMapper = getExtensionManager()
+ .getExtension(XmlElementToEStructuralFeatureMapper.class);
xmlElementToEStructuralFeatureMapper.parseSchema(schema);
}
@@ -165,30 +168,36 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
*
*/
@SuppressWarnings("unchecked")
- protected void applyAnnotation(EObject pAnnotatedEModelElement, String elementName, Attributes attributes)
- throws SAXException {
- final EStructuralFeature annotationEStructuralFeature = getEStructuralFeature(pAnnotatedEModelElement,
- elementName);
+ protected void applyAnnotation(EObject pAnnotatedEModelElement,
+ String elementName, Attributes attributes) throws SAXException {
+ final EStructuralFeature annotationEStructuralFeature = getEStructuralFeature(
+ pAnnotatedEModelElement, elementName);
if (annotationEStructuralFeature == null) {
- throw new SAXException("Cannot handle element <" + elementName + ">");
+ throw new SAXException("Cannot handle element <" + elementName
+ + ">");
}
final PAnnotation pAnnotation = (PAnnotation) EcoreUtil
.create((EClass) annotationEStructuralFeature.getEType());
+ pAnnotation.setGenerated(false);
pAnnotations.push(pAnnotation);
if (annotationEStructuralFeature.isMany()) {
- ((List<PAnnotation>) pAnnotatedEModelElement.eGet(annotationEStructuralFeature)).add(pAnnotation);
+ ((List<PAnnotation>) pAnnotatedEModelElement
+ .eGet(annotationEStructuralFeature)).add(pAnnotation);
} else {
- pAnnotatedEModelElement.eSet(annotationEStructuralFeature, pAnnotation);
+ pAnnotatedEModelElement.eSet(annotationEStructuralFeature,
+ pAnnotation);
}
// Apply attributes to pAnnotation
for (int i = 0, n = attributes.getLength(); i < n; i++) {
- final EAttribute eAttribute = (EAttribute) getEStructuralFeature(pAnnotation, attributes.getLocalName(i));
+ final EAttribute eAttribute = (EAttribute) getEStructuralFeature(
+ pAnnotation, attributes.getLocalName(i));
final EDataType eDataType = eAttribute.getEAttributeType();
- final Object valueObject = eDataType.getEPackage().getEFactoryInstance().createFromString(eDataType,
- attributes.getValue(i));
+ final Object valueObject = eDataType.getEPackage()
+ .getEFactoryInstance()
+ .createFromString(eDataType, attributes.getValue(i));
if (eAttribute.isMany()) {
((List<Object>) pAnnotation.eGet(eAttribute)).add(valueObject);
} else {
@@ -199,28 +208,34 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
}
/**
- * Returns an estructuralfeature on the basis of the name, mainly does conversion of the xmlName to the
- * efeaturename, the prefix returned from getPrefix is also used. todo: move prefix handling to
+ * Returns an estructuralfeature on the basis of the name, mainly does
+ * conversion of the xmlName to the efeaturename, the prefix returned from
+ * getPrefix is also used. todo: move prefix handling to
* XmlElementToEStructuralFeatureMapper.
*/
- protected EStructuralFeature getEStructuralFeature(EObject pAnnotatedEModelElement, String xmlName) {
+ protected EStructuralFeature getEStructuralFeature(
+ EObject pAnnotatedEModelElement, String xmlName) {
String annotationEStructuralFeatureName = convertXmlNameToEStructuralFeatureName(xmlName);
- EStructuralFeature annotationEStructuralFeature = pAnnotatedEModelElement.eClass().getEStructuralFeature(
- annotationEStructuralFeatureName);
+ EStructuralFeature annotationEStructuralFeature = pAnnotatedEModelElement
+ .eClass().getEStructuralFeature(
+ annotationEStructuralFeatureName);
if (annotationEStructuralFeature == null) {
- annotationEStructuralFeatureName = xmlElementToEStructuralFeatureMapper.getEStructuralFeatureName(xmlName);
- annotationEStructuralFeature = pAnnotatedEModelElement.eClass().getEStructuralFeature(
- annotationEStructuralFeatureName);
+ annotationEStructuralFeatureName = xmlElementToEStructuralFeatureMapper
+ .getEStructuralFeatureName(xmlName);
+ annotationEStructuralFeature = pAnnotatedEModelElement.eClass()
+ .getEStructuralFeature(annotationEStructuralFeatureName);
}
// if still null then try with the prefix
if (annotationEStructuralFeature == null) {
- // note if a prefix is added then the first character of the first part has to be
+ // note if a prefix is added then the first character of the first
+ // part has to be
// upper-cased
String name = convertXmlNameToEStructuralFeatureName(xmlName);
- annotationEStructuralFeatureName = prefix + name.substring(0, 1).toUpperCase() + name.substring(1);
+ annotationEStructuralFeatureName = prefix
+ + name.substring(0, 1).toUpperCase() + name.substring(1);
;
- annotationEStructuralFeature = pAnnotatedEModelElement.eClass().getEStructuralFeature(
- annotationEStructuralFeatureName);
+ annotationEStructuralFeature = pAnnotatedEModelElement.eClass()
+ .getEStructuralFeature(annotationEStructuralFeatureName);
}
return annotationEStructuralFeature;
}
@@ -229,7 +244,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
// Implementation of ContentHandler interface.
// --------------------------------------------------------------------
@Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
// Change parse state.
int newParseState;
switch (getParseState()) {
@@ -250,7 +266,9 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
}
break;
case ECLASS:
- if (localName.equals("eattribute") || localName.equals("ereference") || localName.equals("property")) {
+ if (localName.equals("eattribute")
+ || localName.equals("ereference")
+ || localName.equals("property")) {
newParseState = ESTRUCTURALFEATURE;
} else {
newParseState = ECLASS_ANNOTATION;
@@ -266,7 +284,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
case ECLASS_ANNOTATION:
case ESTRUCTURALFEATURE_ANNOTATION:
case NESTED_ANNOTATION: {
- final EStructuralFeature annotationEStructuralFeature = getEStructuralFeature(getPAnnotation(), localName);
+ final EStructuralFeature annotationEStructuralFeature = getEStructuralFeature(
+ getPAnnotation(), localName);
if (annotationEStructuralFeature.getEType() instanceof EClass) {
newParseState = NESTED_ANNOTATION;
} else {
@@ -275,7 +294,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
break;
}
default:
- throw new ParseXMLAnnotationsException("Invalid parse state encountered.");
+ throw new ParseXMLAnnotationsException(
+ "Invalid parse state encountered.");
}
parseStates.push(new Integer(newParseState));
@@ -283,34 +303,42 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
switch (getParseState()) {
case EPACKAGE: {
final String namespaceUri = attributes.getValue("namespace-uri");
- final EPackage ePackage = PackageRegistryProvider.getInstance().getPackageRegistry().getEPackage(
- namespaceUri);
+ final EPackage ePackage = PackageRegistryProvider.getInstance()
+ .getPackageRegistry().getEPackage(namespaceUri);
if (ePackage == null) {
- throw new SAXException("Could not find EPackage \"" + namespaceUri + "\".");
+ throw new SAXException("Could not find EPackage \""
+ + namespaceUri + "\".");
}
pAnnotatedEPackage = pAnnotatedModel.getPAnnotated(ePackage);
if (pAnnotatedEPackage == null) {
- throw new SAXException("Could not find PAnnotatedEPackage \"" + namespaceUri + "\".");
+ throw new SAXException("Could not find PAnnotatedEPackage \""
+ + namespaceUri + "\".");
}
break;
}
case ECLASS: {
final String eClassName = attributes.getValue("name");
- final EClassifier eClassifier = pAnnotatedEPackage.getModelEPackage().getEClassifier(eClassName);
+ final EClassifier eClassifier = pAnnotatedEPackage
+ .getModelEPackage().getEClassifier(eClassName);
if (eClassifier == null) {
- throw new SAXException("Could not find EClass \"" + eClassName + "\"");
+ throw new SAXException("Could not find EClass \"" + eClassName
+ + "\"");
}
if (!(eClassifier instanceof EClass)) {
- throw new SAXException("EClassifier \"" + eClassName + "\" is not an EClass.");
+ throw new SAXException("EClassifier \"" + eClassName
+ + "\" is not an EClass.");
}
- pAnnotatedEClass = pAnnotatedModel.getPAnnotated((EClass) eClassifier);
+ pAnnotatedEClass = pAnnotatedModel
+ .getPAnnotated((EClass) eClassifier);
break;
}
case EDATATYPE: {
final String eDataTypeName = attributes.getValue("name");
- final EDataType et = (EDataType) pAnnotatedEPackage.getModelEPackage().getEClassifier(eDataTypeName);
+ final EDataType et = (EDataType) pAnnotatedEPackage
+ .getModelEPackage().getEClassifier(eDataTypeName);
if (et == null) {
- throw new SAXException("Could not find EClass \"" + eDataTypeName + "\"");
+ throw new SAXException("Could not find EClass \""
+ + eDataTypeName + "\"");
}
pAnnotatedEDataType = pAnnotatedModel.getPAnnotated(et);
break;
@@ -318,18 +346,25 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
case ESTRUCTURALFEATURE: {
final String eStructuralFeatureName = attributes.getValue("name");
final EClass eClass = pAnnotatedEClass.getModelEClass();
- final EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(eStructuralFeatureName);
+ final EStructuralFeature eStructuralFeature = eClass
+ .getEStructuralFeature(eStructuralFeatureName);
if (eStructuralFeature == null) {
- throw new SAXException("Could not find EStructuralFeature \"" + eStructuralFeatureName
- + "\" in EClass \"" + eClass.getName() + "\".");
- } else if (localName.equals("eattribute") && !(eStructuralFeature instanceof EAttribute)) {
- throw new SAXException("EStructuralFeature \"" + eStructuralFeatureName + "\" in EClass \""
+ throw new SAXException("Could not find EStructuralFeature \""
+ + eStructuralFeatureName + "\" in EClass \""
+ + eClass.getName() + "\".");
+ } else if (localName.equals("eattribute")
+ && !(eStructuralFeature instanceof EAttribute)) {
+ throw new SAXException("EStructuralFeature \""
+ + eStructuralFeatureName + "\" in EClass \""
+ eClass.getName() + "\" is not an EAttribute.");
- } else if (localName.equals("ereference") && !(eStructuralFeature instanceof EReference)) {
- throw new SAXException("EStructuralFeature \"" + eStructuralFeatureName + "\" in EClass \""
+ } else if (localName.equals("ereference")
+ && !(eStructuralFeature instanceof EReference)) {
+ throw new SAXException("EStructuralFeature \""
+ + eStructuralFeatureName + "\" in EClass \""
+ eClass.getName() + "\" is not an EReference.");
}
- pAnnotatedEStructuralFeature = pAnnotatedModel.getPAnnotated(eStructuralFeature);
+ pAnnotatedEStructuralFeature = pAnnotatedModel
+ .getPAnnotated(eStructuralFeature);
break;
}
case EPACKAGE_ANNOTATION:
@@ -364,7 +399,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
@Override
@SuppressWarnings("unchecked")
- public void characters(char[] ch, int start, int length) throws SAXException {
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
final String value = new String(ch, start, length).trim();
if (value.length() == 0) {
return;
@@ -374,23 +410,30 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
case ECLASS_ANNOTATION:
case ESTRUCTURALFEATURE_ANNOTATION:
case NESTED_ANNOTATION: {
- // If we get here, we are dealing with a PAnnotation that has only one EAttribute.
+ // If we get here, we are dealing with a PAnnotation that has only
+ // one EAttribute.
// I.e. there are no
- // child elements. Example: <discriminator-value>MyObject</discriminator-value>
+ // child elements. Example:
+ // <discriminator-value>MyObject</discriminator-value>
final PAnnotation pAnnotation = getPAnnotation();
assert (pAnnotation.eClass().getEStructuralFeatures().size() == 1);
- final EAttribute eAttribute = (EAttribute) pAnnotation.eClass().getEStructuralFeatures().get(0);
+ final EAttribute eAttribute = (EAttribute) pAnnotation.eClass()
+ .getEStructuralFeatures().get(0);
final EDataType eAttributeType = eAttribute.getEAttributeType();
- final Object valueObject = eAttributeType.getEPackage().getEFactoryInstance().createFromString(
- eAttributeType, value);
+ final Object valueObject = eAttributeType.getEPackage()
+ .getEFactoryInstance()
+ .createFromString(eAttributeType, value);
pAnnotation.eSet(eAttribute, valueObject);
break;
}
case ANNOTATION_ATTRIBUTE: {
- final EDataType eDataType = pAnnotationEAttribute.getEAttributeType();
- final Object valueObject = eDataType.getEPackage().getEFactoryInstance().createFromString(eDataType, value);
+ final EDataType eDataType = pAnnotationEAttribute
+ .getEAttributeType();
+ final Object valueObject = eDataType.getEPackage()
+ .getEFactoryInstance().createFromString(eDataType, value);
if (pAnnotationEAttribute.isMany()) {
- ((List<Object>) getPAnnotation().eGet(pAnnotationEAttribute)).add(valueObject);
+ ((List<Object>) getPAnnotation().eGet(pAnnotationEAttribute))
+ .add(valueObject);
} else {
getPAnnotation().eSet(pAnnotationEAttribute, valueObject);
}
@@ -400,7 +443,8 @@ public class XmlPersistenceContentHandler extends DefaultHandler implements Exte
}
@Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
switch (getParseState()) {
case EPACKAGE_ANNOTATION:
case ECLASS_ANNOTATION:

Back to the top