1 17 package org.eclipse.emf.ecore.xmi.impl; 18 19 20 import java.util.Map ; 21 22 import org.eclipse.emf.ecore.EObject; 23 24 import org.eclipse.emf.ecore.xmi.XMIResource; 25 import org.eclipse.emf.ecore.xmi.XMLHelper; 26 import org.eclipse.emf.ecore.xmi.XMLResource; 27 28 29 32 public abstract class XMIHandler extends XMLHandler 33 { 34 protected static final String XMI_ELEMENT_TYPE = "xmi"; 35 protected static final String XMI_UUID = "uuid"; 36 protected static final String XMI_EXTENSION = "Extension"; 37 38 protected final static String XMI_TYPE_ATTRIB = XMIResource.XMI_NS + ":" + XMLResource.TYPE; 39 protected final static String ID_ATTRIB = XMIResource.XMI_NS + ":" + XMIResource.XMI_ID; 40 protected final static String VERSION_ATTRIB = XMIResource.XMI_NS + ":" + XMIResource.VERSION_NAME; 41 protected final static String UUID_ATTRIB = XMIResource.XMI_NS + ":" + XMI_UUID; 42 protected final static String XMI_ELEMENT_NAME = XMIResource.XMI_NS + ":" + XMIResource.XMI_TAG_NAME; 43 44 47 public XMIHandler(XMLResource xmiResource, XMLHelper helper, Map options) 48 { 49 super(xmiResource, helper, options); 50 51 hrefAttribute = XMLResource.HREF; 52 notFeatures.add(VERSION_ATTRIB); 53 notFeatures.add(XMI_TYPE_ATTRIB); 54 notFeatures.add(UUID_ATTRIB); 55 } 56 57 protected void processElement(String name, String prefix, String localName) 58 { 59 if (name.equals(XMI_ELEMENT_NAME)) 60 { 61 types.push(XMI_ELEMENT_TYPE); 62 } 63 else 64 { 65 super.processElement(name, prefix, localName); 66 } 67 } 68 69 protected boolean isTextFeatureValue(Object type) 70 { 71 return super.isTextFeatureValue(type) && type != XMI_ELEMENT_TYPE; 72 } 73 74 protected void handleUnknownFeature(String prefix, String name, boolean isElement, EObject peekObject, String value) 75 { 76 if (XMI_EXTENSION.equals(name) && XMIResource.XMI_URI.equals(helper.getURI(prefix))) 77 { 78 if (extendedMetaData == null) 79 { 80 setExtendedMetaDataOption(Boolean.TRUE); 81 } 82 83 recordUnknownFeature(prefix, name, isElement, peekObject, value); 84 } 85 else 86 { 87 super.handleUnknownFeature(prefix, name, isElement, peekObject, value); 88 } 89 } 90 } | Popular Tags |