Class XmlFormatter

  • All Implemented Interfaces:
    IFormatter

    public class XmlFormatter
    extends Object
    implements IFormatter
    Класс XmlFormatter на основе интерфеса IFormatter обеспечивает стандартное форматирование для элементов модели, которые не получили информацию о форматировании при парсинге
    • Field Detail

      • OPTION_INDENT_ROOT_ELEMENT

        protected static final String OPTION_INDENT_ROOT_ELEMENT
        Начальный отступ корневого элемента
        See Also:
        Constant Field Values
      • OPTION_CUSTOM_INDENT

        protected static final String OPTION_CUSTOM_INDENT
        Опция для определения отступа в документе
        ("  " по умолчанию)
        See Also:
        Constant Field Values
      • NULL_LOCATION

        protected static final Location NULL_LOCATION
      • indent

        protected int indent
      • indentString

        protected String indentString
      • helper

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

        protected boolean declareXML
      • saveTypeInfo

        protected boolean saveTypeInfo
      • xmlTypeInfo

        protected org.eclipse.emf.ecore.xmi.XMLSave.XMLTypeInfo xmlTypeInfo
      • keepDefaults

        protected boolean keepDefaults
      • escape

        protected Escape escape
      • escapeURI

        protected Escape escapeURI
      • featureTable

        protected Lookup featureTable
      • idAttributeName

        protected String idAttributeName
      • lineSeparator

        protected String lineSeparator
      • declareSchemaLocation

        protected boolean declareSchemaLocation
      • declareSchemaLocationImplementation

        protected boolean declareSchemaLocationImplementation
      • xmlSchemaTypePackage

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

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

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

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

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

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

        protected org.eclipse.emf.ecore.xmi.XMLResource.ElementHandler elementHandler
      • saveXsiType

        protected boolean saveXsiType
    • Constructor Detail

      • XmlFormatter

        public XmlFormatter()
    • Method Detail

      • setUriEncoder

        public void setUriEncoder​(LazyUriEncoder uriEncoder)
      • init

        public void init​(org.eclipse.emf.ecore.xmi.XMLHelper helper,
                         Map<?,​?> options)
      • format

        public INode format​(org.eclipse.emf.ecore.xmi.XMLHelper helper,
                            Map<?,​?> options)
        Specified by:
        format in interface IFormatter
      • shouldSaveFeature

        protected boolean shouldSaveFeature​(org.eclipse.emf.ecore.EObject o,
                                            org.eclipse.emf.ecore.EStructuralFeature f)
      • shouldSaveObject

        protected boolean shouldSaveObject​(org.eclipse.emf.ecore.EObject child)
      • formatRootNode

        protected void formatRootNode()
      • formatEObject

        protected void formatEObject​(org.eclipse.emf.ecore.EObject obj,
                                     INode parentNode)
      • formatingContainmentReferenceNode

        protected void formatingContainmentReferenceNode​(ContainmentReferenceNode oldNode,
                                                         INode parent,
                                                         org.eclipse.emf.ecore.EObject obj)
      • formatExistFeaturesWithoutElements

        protected void formatExistFeaturesWithoutElements​(org.eclipse.emf.ecore.EObject obj,
                                                          ContainmentReferenceNode parent,
                                                          ContainmentReferenceNode oldParent,
                                                          List<org.eclipse.emf.ecore.EStructuralFeature> listExistFeatures,
                                                          List<INode> listExistElementNodes,
                                                          List<org.eclipse.emf.ecore.EStructuralFeature> listExistElementFeatures)
      • formatNewFeaturesWithoutElements

        protected void formatNewFeaturesWithoutElements​(org.eclipse.emf.ecore.EObject obj,
                                                        ContainmentReferenceNode parent,
                                                        List<org.eclipse.emf.ecore.EStructuralFeature> listExistFeatures,
                                                        List<org.eclipse.emf.ecore.EStructuralFeature> listExistElementFeatures,
                                                        List<org.eclipse.emf.ecore.EStructuralFeature> featureElementsList)
      • formatExistFeaturesLikeElements

        protected void formatExistFeaturesLikeElements​(org.eclipse.emf.ecore.EObject obj,
                                                       ContainmentReferenceNode parent,
                                                       List<org.eclipse.emf.ecore.EStructuralFeature> listExistFeatures,
                                                       List<INode> listExistElementNodes)
      • formatNewFeaturesLikeElements

        protected void formatNewFeaturesLikeElements​(org.eclipse.emf.ecore.EObject obj,
                                                     ContainmentReferenceNode parent,
                                                     List<org.eclipse.emf.ecore.EStructuralFeature> listExistFeatures,
                                                     List<org.eclipse.emf.ecore.EStructuralFeature> listExistElementFeatures,
                                                     List<org.eclipse.emf.ecore.EStructuralFeature> featureElementsList)
      • formatXsiTypeNode

        protected void formatXsiTypeNode​(org.eclipse.emf.ecore.EStructuralFeature f,
                                         org.eclipse.emf.ecore.EObject value,
                                         AbstractNode parent,
                                         NamespaceNode oldNode)
      • formatPreviousTextNodes

        protected void formatPreviousTextNodes​(INode oldNode,
                                               INode parent)
      • createRootNode

        protected void createRootNode​(org.eclipse.emf.ecore.EObject root,
                                      INode parent)
      • createContainmentReferenceNode

        protected void createContainmentReferenceNode​(org.eclipse.emf.ecore.EObject obj,
                                                      INode parent)
      • createFeatures

        protected boolean createFeatures​(org.eclipse.emf.ecore.EObject obj,
                                         ContainmentReferenceNode node,
                                         boolean isRootNode)
        Создает ноды по фичам.
        Parameters:
        obj -
        node -
        isRootNode -
        Returns:
        true - если среди созданых фич есть элементы.
      • createNonContaimentManyReferenceNodes

        protected void createNonContaimentManyReferenceNodes​(org.eclipse.emf.ecore.EObject obj,
                                                             org.eclipse.emf.ecore.EStructuralFeature f,
                                                             ContainmentReferenceNode parent)
      • createAttributeManyElementsNodes

        protected void createAttributeManyElementsNodes​(org.eclipse.emf.ecore.EObject obj,
                                                        org.eclipse.emf.ecore.EStructuralFeature f,
                                                        ContainmentReferenceNode node)
      • createAttributeNode

        protected void createAttributeNode​(org.eclipse.emf.ecore.EObject obj,
                                           org.eclipse.emf.ecore.EStructuralFeature f,
                                           ContainmentReferenceNode parent,
                                           int mark)
      • createTextNodeWithIndent

        protected TextNode createTextNodeWithIndent​(INode parentNode,
                                                    boolean isLast)
      • createXsiTypeRootNode

        protected void createXsiTypeRootNode​(org.eclipse.emf.ecore.EObject root,
                                             ContainmentReferenceNode parent)
      • createXsiTypeNode

        protected void createXsiTypeNode​(org.eclipse.emf.ecore.EStructuralFeature f,
                                         org.eclipse.emf.ecore.EObject value,
                                         AbstractNode parent)
      • getXsiTypeRootName

        protected String getXsiTypeRootName​(org.eclipse.emf.ecore.EObject root)
      • getXsiTypeName

        protected String getXsiTypeName​(org.eclipse.emf.ecore.EStructuralFeature f,
                                        org.eclipse.emf.ecore.EObject value)
      • hasAnnotationName

        protected boolean hasAnnotationName​(org.eclipse.emf.ecore.EClass eClass,
                                            org.eclipse.emf.ecore.EStructuralFeature f)
        Метод возвращает имя объекта записанного в аннотации
        Parameters:
        eClass - объекта
        f - которой объект является в contein объекте
        Returns:
        Возвращает имя объекта либо null если нет подходящей аннотации