protected void init()

in impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java [684:733]


        protected void init(XMLResource resource, Map options) {
            super.init(resource, options);
            int unformat = 0;
            String lineBreak = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK);
            if (lineBreak == null)
                changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK);
            else if (lineBreak.length() == 0)
                ++unformat;
            else {
                changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK);
                if (lineBreak.equals(LINE_SEPARATOR))
                    lineBreak = null;
            }
            String indent = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_INDENT);
            if (indent == null)
                changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT);
            else if (indent.length() == 0)
                ++unformat;
            else {
                changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, this.indent = indent);
                if (indent.equals(INDENT))
                    indent = null;
            }
            String margin = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_MARGIN);
            if (margin == null || margin.length() == 0) {
                if (unformat == 2)
                    doc.setUnformatted(true);
                else if (lineBreak != null) {
                    XmlString d = doc(resource, options);
                    d.setLineBreak(lineBreak);
                    if (indent != null)
                        d.indent = indent;
                } else if (indent != null)
                    doc(resource, options).indent = indent;
                this.margin = this.indent;
            } else {
                XmlString d = doc(resource, options);
                d.margin(margin);
                if (lineBreak != null)
                    d.setLineBreak(lineBreak);
                if (indent != null)
                    d.indent = indent;
                this.margin = margin + this.indent;
                if (!toDOM && declareXML)
                    d.add(margin);
            }
            // changeSummaryOptions.put(ChangeSummaryStreamSerializer.OPTION_RootObject_PATH, "#");
            // changeSummaryOptions.put(ChangeSummaryStreamSerializer.OPTION_OPTIMIZE_LIST, Boolean.TRUE);
            changeSummaryOptions.put(OPTION_EXTENDED_META_DATA, extendedMetaData);
        }