Commit 87695a9c authored by Dominique Marcadet's avatar Dominique Marcadet

Merge branch '33-0-or-1-are-allowed-as-boolean-value' into 'master'

Resolve "0 or 1 are allowed as boolean value"

Closes #33

See merge request RiseClipseGroup/RiseClipseMetamodel_SCL2003!28
parents 3d06129c 95310f00
...@@ -23,6 +23,7 @@ import java.util.Stack; ...@@ -23,6 +23,7 @@ import java.util.Stack;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.xmi.XMLHelper; import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLResource; import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler; import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler;
...@@ -87,6 +88,21 @@ public class SCLXMLHandler extends SAXXMLHandler { ...@@ -87,6 +88,21 @@ public class SCLXMLHandler extends SAXXMLHandler {
+ (( SclObject ) object ).getLineNumber() + ")" ); + (( SclObject ) object ).getLineNumber() + ")" );
return; return;
} }
// 0 or 1 are allowed as boolean values
if( feature.getEType() == EcorePackage.Literals.EBOOLEAN_OBJECT ) {
if(( value != null ) && ( value.getClass() == String.class )) {
switch(( String ) value ) {
case "0" :
super.setFeatureValue( object, feature, "false", position );
return;
case "1" :
super.setFeatureValue( object, feature, "true", position );
return;
}
}
}
super.setFeatureValue( object, feature, value, position ); super.setFeatureValue( object, feature, value, position );
} }
...@@ -124,8 +140,7 @@ public class SCLXMLHandler extends SAXXMLHandler { ...@@ -124,8 +140,7 @@ public class SCLXMLHandler extends SAXXMLHandler {
} }
@Override @Override
public void handleUnknownFeature( java.lang.String prefix, java.lang.String name, boolean isElement, public void handleUnknownFeature( java.lang.String prefix, java.lang.String name, boolean isElement, EObject peekObject, java.lang.String value ) {
EObject peekObject, java.lang.String value ) {
String mess = "unknown feature " + name; String mess = "unknown feature " + name;
mess += " in object " + peekObject.eClass().getName(); mess += " in object " + peekObject.eClass().getName();
if( ! lineNumbers.empty() ) { if( ! lineNumbers.empty() ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment