Class AbstractStaxXmlParser

  • All Implemented Interfaces:
    IXmlParser, org.eclipse.emf.ecore.xmi.XMLLoad
    Direct Known Subclasses:
    AbstractStaxXmiParser, StaxXmlParser

    public abstract class AbstractStaxXmlParser
    extends XmlParserAdapter
    Абстрактная реализация парсера xml документа. Поддерживает резолвинг символических ссылок, построение parse-tree и резолвинг абстрактных типов соглассно аннотациям mapping модели
    • Field Detail

      • DEBUG_DEMANDED_PACKAGES

        protected static final boolean DEBUG_DEMANDED_PACKAGES
        See Also:
        Constant Field Values
      • NO_NAMESPACE_SCHEMA_LOCATION_ATTRIB

        protected static final String NO_NAMESPACE_SCHEMA_LOCATION_ATTRIB
        See Also:
        Constant Field Values
      • isRoot

        protected boolean isRoot
      • needsPushContext

        protected boolean needsPushContext
      • documentRoot

        protected org.eclipse.emf.ecore.EObject documentRoot
      • xmlResource

        protected org.eclipse.emf.ecore.xmi.XMLResource xmlResource
      • helper

        protected org.eclipse.emf.ecore.xmi.XMLHelper helper
      • resourceSet

        protected org.eclipse.emf.ecore.resource.ResourceSet resourceSet
      • resourceURI

        protected org.eclipse.emf.common.util.URI resourceURI
      • extent

        protected org.eclipse.emf.ecore.util.InternalEList<org.eclipse.emf.ecore.EObject> extent
      • deferredExtent

        protected List<org.eclipse.emf.ecore.EObject> deferredExtent
      • sameDocumentProxies

        protected List<org.eclipse.emf.ecore.InternalEObject> sameDocumentProxies
      • packageRegistry

        protected org.eclipse.emf.ecore.EPackage.Registry packageRegistry
      • oldStyleProxyURIs

        protected boolean oldStyleProxyURIs
      • xmlSchemaTypePackage

        protected org.eclipse.emf.ecore.EPackage xmlSchemaTypePackage
      • anyType

        protected org.eclipse.emf.ecore.EClass anyType
      • anySimpleType

        protected org.eclipse.emf.ecore.EClass anySimpleType
      • contextFeature

        protected org.eclipse.emf.ecore.EStructuralFeature contextFeature
      • hrefAttribute

        protected String hrefAttribute
      • processAnyXML

        protected boolean processAnyXML
      • processSchemaLocations

        protected boolean processSchemaLocations
      • externalURIToLocations

        protected Map<String,​org.eclipse.emf.common.util.URI> externalURIToLocations
      • urisToLocations

        protected Map<String,​org.eclipse.emf.common.util.URI> urisToLocations
      • identifiers

        protected Object[] identifiers
      • positions

        protected int[] positions
      • capacity

        protected int capacity
      • prefixesToFactories

        protected Map<String,​org.eclipse.emf.ecore.EFactory> prefixesToFactories
      • eObjectToExtensionMap

        protected Map<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.xml.type.AnyType> eObjectToExtensionMap
      • deferIDREFResolution

        protected boolean deferIDREFResolution
      • isIDREF

        protected boolean isIDREF
      • isSimpleFeature

        protected boolean isSimpleFeature
      • idAttribute

        protected String idAttribute
      • isNamespaceAware

        protected boolean isNamespaceAware
      • xmlMap

        protected org.eclipse.emf.ecore.xmi.XMLResource.XMLMap xmlMap
      • extendedMetaData

        protected org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData
      • ecoreBuilder

        protected org.eclipse.emf.ecore.xmi.EcoreBuilder ecoreBuilder
      • notFeatures

        protected Set<String> notFeatures
      • laxWildcardProcessing

        protected boolean laxWildcardProcessing
      • resourceEntityHandler

        protected org.eclipse.emf.ecore.xmi.XMLResource.ResourceEntityHandler resourceEntityHandler
      • recordUnknownFeature

        protected boolean recordUnknownFeature
      • recordAnyTypeNSDecls

        protected boolean recordAnyTypeNSDecls
      • usedNullNamespacePackage

        protected boolean usedNullNamespacePackage
      • resolve

        protected boolean resolve
      • useConfigurationCache

        protected boolean useConfigurationCache
      • uriHandler

        protected org.eclipse.emf.ecore.xmi.XMLResource.URIHandler uriHandler
      • disableNotify

        protected boolean disableNotify
      • suppressDocumentRoot

        protected boolean suppressDocumentRoot
      • useSymlink

        protected boolean useSymlink
      • keepAttributeLocation

        protected boolean keepAttributeLocation
    • Constructor Detail

      • AbstractStaxXmlParser

        public AbstractStaxXmlParser()
      • AbstractStaxXmlParser

        public AbstractStaxXmlParser​(org.eclipse.emf.ecore.xmi.XMLHelper helper,
                                     Map<?,​?> options)
    • Method Detail

      • init

        public void init​(org.eclipse.emf.ecore.xmi.XMLHelper helper,
                         Map<?,​?> options)
        Specified by:
        init in class XmlParserAdapter
      • error

        public void error​(org.eclipse.emf.ecore.xmi.XMIException e)
      • warning

        public void warning​(org.eclipse.emf.ecore.xmi.XMIException e)
      • fatalError

        public void fatalError​(org.eclipse.emf.ecore.xmi.XMIException e)
      • getRegistry

        public org.eclipse.emf.ecore.EPackage.Registry getRegistry()
      • findInstantiableCompatible

        protected org.eclipse.emf.ecore.EClass findInstantiableCompatible​(org.eclipse.emf.ecore.EClass eType)
      • findSubTypeInEPackage

        protected org.eclipse.emf.ecore.EClass findSubTypeInEPackage​(org.eclipse.emf.ecore.EPackage ePackage,
                                                                     org.eclipse.emf.ecore.EClass superType)
      • globalFindInstantiableCompatible

        protected org.eclipse.emf.ecore.EClass globalFindInstantiableCompatible​(org.eclipse.emf.ecore.EClass eType)
      • getStartLocation

        protected final Location getStartLocation()
        Метод для получения текущего положения курсора в тексте
        Returns:
        координаты текущего положения курсора в тексте
      • setNodeEndLocation

        protected final void setNodeEndLocation​(INode node)
        Обновляет для узла node конечные координаты
        Parameters:
        node - узел
      • createEcoreBuilder

        protected org.eclipse.emf.ecore.xmi.EcoreBuilder createEcoreBuilder​(Map<?,​?> options,
                                                                            org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData)
      • setExtendedMetaDataOption

        protected void setExtendedMetaDataOption​(Object extendedMetaDataOption)
      • endDocument

        protected void endDocument()
        Обработка конца документа
      • endElement

        protected void endElement()
        Обработка конца элемента
      • characters

        protected void characters()
        Обработка символов (whitespaces и прочее)
      • comment

        protected void comment()
        Обработка комментариев
      • startElement

        protected void startElement()
        Обработка начала элемента
      • startDocument

        protected void startDocument()
        обработка начала документа
      • handleMixedText

        protected void handleMixedText()
      • handleComment

        protected void handleComment​(String comment)
      • isTextFeatureValue

        protected boolean isTextFeatureValue​(Object type)
      • processElement

        protected void processElement​(String name,
                                      String prefix,
                                      String localName)
      • setFeatureValue

        protected void setFeatureValue​(org.eclipse.emf.ecore.EObject object,
                                       org.eclipse.emf.ecore.EStructuralFeature feature,
                                       Object value)
      • setFeatureValue

        protected void setFeatureValue​(org.eclipse.emf.ecore.EObject object,
                                       org.eclipse.emf.ecore.EStructuralFeature feature,
                                       Object value,
                                       int position)
        Set the given feature of the given object to the given value.
      • createObjectFromTypeName

        protected org.eclipse.emf.ecore.EObject createObjectFromTypeName​(org.eclipse.emf.ecore.EObject peekObject,
                                                                         String typeQName,
                                                                         org.eclipse.emf.ecore.EStructuralFeature feature)
        Create an object from the given qualified type name.
      • createObjectFromFeatureType

        protected org.eclipse.emf.ecore.EObject createObjectFromFeatureType​(org.eclipse.emf.ecore.EObject peekObject,
                                                                            org.eclipse.emf.ecore.EStructuralFeature feature)
        Create an object based on the type of the given feature.
      • createObject

        protected void createObject​(org.eclipse.emf.ecore.EObject peekObject,
                                    org.eclipse.emf.ecore.EStructuralFeature feature,
                                    String xsiType)
        Create an object based on the given feature and attributes.
      • createObjectFromFactory

        @Deprecated
        protected org.eclipse.emf.ecore.EObject createObjectFromFactory​(org.eclipse.emf.ecore.EFactory factory,
                                                                        String typeName)
        Deprecated.
        since 2.2 Create an object given a content helper, a factory, and a type name, and process the XML attributes.
      • handleUnknownFeature

        protected void handleUnknownFeature​(String prefix,
                                            String name,
                                            boolean isElement,
                                            org.eclipse.emf.ecore.EObject peekObject,
                                            String value)
      • resolveObjectWithoutXsiType

        protected boolean resolveObjectWithoutXsiType​(String name,
                                                      org.eclipse.emf.ecore.EObject peekObject)
      • recordUnknownFeature

        protected void recordUnknownFeature​(String prefix,
                                            String name,
                                            boolean isElement,
                                            org.eclipse.emf.ecore.EObject peekObject,
                                            String value)
      • setNamespaceValue

        protected void setNamespaceValue​(String name,
                                         String value,
                                         int index)
      • setXMIAttribValue

        protected void setXMIAttribValue​(String name,
                                         String value,
                                         int index)
      • setAttribValue

        protected void setAttribValue​(org.eclipse.emf.ecore.EObject object,
                                      String name,
                                      String value,
                                      int index)
        Create a feature with the given name for the given object with the given values.
      • storeAttributeNodeLocationInfo

        protected void storeAttributeNodeLocationInfo​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                                      int index)
      • storeWhitespacesInformation

        protected void storeWhitespacesInformation​(com.ctc.wstx.sr.BasicStreamReader2 reader2,
                                                   AbstractFormattedNode attributeNode,
                                                   int index)
      • handleProxy

        protected void handleProxy​(org.eclipse.emf.ecore.InternalEObject proxy,
                                   String uriLiteral,
                                   int index)
      • setValueFromId

        protected void setValueFromId​(org.eclipse.emf.ecore.EObject object,
                                      org.eclipse.emf.ecore.EReference eReference,
                                      String ids)
      • setValueFromId

        protected void setValueFromId​(org.eclipse.emf.ecore.EObject object,
                                      org.eclipse.emf.ecore.EReference eReference,
                                      String ids,
                                      int attrIndex)
      • findAppropriateQName

        protected String findAppropriateQName​(org.eclipse.emf.ecore.EObject object,
                                              org.eclipse.emf.ecore.EReference eReference)
      • createAttributeNodeForProxy

        protected void createAttributeNodeForProxy​(org.eclipse.emf.ecore.EReference eReference,
                                                   int attrIndex,
                                                   String id)
      • growArrays

        protected void growArrays()
      • reportUnknownFeature

        protected void reportUnknownFeature​(String prefix,
                                            String name,
                                            boolean isElement,
                                            org.eclipse.emf.ecore.EObject peekObject,
                                            String value)
      • recordNamespacesSchemaLocations

        protected org.eclipse.emf.common.util.EMap<String,​String> recordNamespacesSchemaLocations​(org.eclipse.emf.ecore.EObject root)
      • handleFeature

        protected void handleFeature​(String prefix,
                                     String name)
        The XML element represents a feature. There are two cases to handle: 1. The feature has a type that is a datatype. 2. The feature has a type that is a class.
      • processFeature

        protected void processFeature​(org.eclipse.emf.ecore.EObject peekObject,
                                      org.eclipse.emf.ecore.EStructuralFeature feature,
                                      String xsiType)
      • getFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getFeature​(org.eclipse.emf.ecore.EObject object,
                                                                      String prefix,
                                                                      String name,
                                                                      boolean isElement)
        Get the EStructuralFeature from the metaObject for the given object and feature name.
      • getFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getFeature​(org.eclipse.emf.ecore.EObject object,
                                                                      String prefix,
                                                                      String name)
      • createTopObject

        protected void createTopObject​(String prefix,
                                       String name)
      • getFactoryForPrefix

        protected org.eclipse.emf.ecore.EFactory getFactoryForPrefix​(String prefix)
      • handleObjectAttribs

        protected void handleObjectAttribs​(org.eclipse.emf.ecore.EObject obj)
        Process the XML attributes for the newly created object.
      • getXsiType

        protected abstract String getXsiType()
        Returns the xsi type attribute's value.
      • createObject

        protected org.eclipse.emf.ecore.EObject createObject​(org.eclipse.emf.ecore.EFactory eFactory,
                                                             org.eclipse.emf.ecore.EClassifier type,
                                                             boolean documentRoot)
      • getExtension

        protected org.eclipse.emf.ecore.xml.type.AnyType getExtension​(org.eclipse.emf.ecore.EObject peekObject)
      • validateCreateObjectFromFactory

        protected org.eclipse.emf.ecore.EObject validateCreateObjectFromFactory​(org.eclipse.emf.ecore.EFactory factory,
                                                                                String typeName,
                                                                                org.eclipse.emf.ecore.EObject newObject,
                                                                                org.eclipse.emf.ecore.EStructuralFeature feature)
      • validateCreateObjectFromFactory

        protected org.eclipse.emf.ecore.EObject validateCreateObjectFromFactory​(org.eclipse.emf.ecore.EFactory factory,
                                                                                String typeName,
                                                                                org.eclipse.emf.ecore.EObject newObject,
                                                                                boolean top)
      • validateCreateObjectFromFactory

        protected void validateCreateObjectFromFactory​(org.eclipse.emf.ecore.EFactory factory,
                                                       String typeName,
                                                       org.eclipse.emf.ecore.EObject newObject)
      • processTopObject

        protected void processTopObject​(org.eclipse.emf.ecore.EObject object)
        Add object to extent and call processObject.
      • getContentFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getContentFeature​(org.eclipse.emf.ecore.EObject object)
      • processObject

        protected void processObject​(org.eclipse.emf.ecore.EObject object)
        Add object to appropriate stacks.
      • createDocumentRoot

        protected org.eclipse.emf.ecore.EObject createDocumentRoot​(String prefix,
                                                                   String uri,
                                                                   String name,
                                                                   org.eclipse.emf.ecore.EFactory eFactory,
                                                                   boolean top)
      • createObjectByType

        protected org.eclipse.emf.ecore.EObject createObjectByType​(String prefix,
                                                                   String name,
                                                                   boolean top)
        Create an object based on the prefix and type name.
      • processSchemaLocations

        protected void processSchemaLocations​(String prefix,
                                              String name)
      • getPackageForURI

        protected org.eclipse.emf.ecore.EPackage getPackageForURI​(String uriString)
        Attempt to get the namespace for the given prefix, then return ERegister.getPackage() or null.
      • getLineNumber

        protected int getLineNumber()
      • getColumnNumber

        protected int getColumnNumber()
      • getLocation

        protected String getLocation()
      • getCurrentLocation

        protected Location getCurrentLocation()
      • handleMissingPackage

        protected org.eclipse.emf.ecore.EPackage handleMissingPackage​(String uriString)
      • getURIConverter

        protected org.eclipse.emf.ecore.resource.URIConverter getURIConverter()
      • handleTopLocations

        protected void handleTopLocations​(String prefix,
                                          String name)
      • isError

        protected boolean isError()
        Returns true if there was an error in the last XML element; false otherwise.
      • isNull

        protected boolean isNull()
        Returns true if the xsi:nil attribute is in the list of attributes.
      • recordHeaderInformation

        protected void recordHeaderInformation()
      • handleSchemaLocation

        protected void handleSchemaLocation()
      • handleXSISchemaLocation

        protected void handleXSISchemaLocation​(String schemaLocations)
      • handleXSINoNamespaceSchemaLocation

        protected void handleXSINoNamespaceSchemaLocation​(String noNamespaceSchemaLocation)
      • handleForwardReferences

        protected void handleForwardReferences()
      • handleForwardReferences

        protected void handleForwardReferences​(boolean isEndDocument)
        Check if the values of the forward references have been set (they may have been set due to a bidirectional reference being set). If not, set them. If this is called during end document processing, errors should be diagnosed. If it is called in the middle of a document, we need to clean up the forward reference lists to avoid processing resolved references again later.