buildframework/helium/sf/java/diamonds/src/com/nokia/helium/diamonds/XMLMerger.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
package com.nokia.helium.diamonds;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.io.File;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    22
import java.io.InputStream;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    23
import java.io.FileNotFoundException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import java.io.FileOutputStream;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    25
import java.io.IOException;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    26
import java.io.UnsupportedEncodingException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import java.util.Iterator;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import java.util.List;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
import org.apache.log4j.Logger;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
import org.dom4j.Attribute;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
import org.dom4j.Document;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
import org.dom4j.DocumentException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
import org.dom4j.Element;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
import org.dom4j.io.OutputFormat;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
import org.dom4j.io.SAXReader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
import org.dom4j.io.XMLWriter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
 * This class implements an XML file merger. All node from an external XML with
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
 * same format (same root node name) will get added to the source root element.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
public class XMLMerger {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    private Logger log = Logger.getLogger(getClass());
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    45
    private InputStream mergeStream;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    private Document doc;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    private Element root;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    48
    private File outputFile;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
     * Create an XMLMerger, the merge file will be used as input and output.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
     * @param merge
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
     * @throws XMLMergerException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    56
    public XMLMerger(InputStream stream, File file) throws XMLMergerException {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        try {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    58
            outputFile = file;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    59
            mergeStream = stream;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
            SAXReader reader = new SAXReader();
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    61
            doc = reader.read(mergeStream);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
            root = doc.getRootElement();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        } catch (DocumentException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
            throw new XMLMergerException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        }        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    67
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    68
    public void merge(InputStream stream) throws XMLMergerException {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    69
        try {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    70
            SAXReader reader = new SAXReader();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    71
            Document dataDoc = reader.read(stream);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    72
            merge(dataDoc);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    73
        } catch (DocumentException e) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    74
            throw new XMLMergerException(e.getMessage());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    75
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    76
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    78
    private void merge(Document dataDoc) throws XMLMergerException {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    79
        Element dataRoot = dataDoc.getRootElement();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    80
        if (!root.getName().equals(dataRoot.getName())) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    81
            throw new XMLMergerException(
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    82
                    "Trying to merge incompatible xml format ('"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    83
                            + root.getName() + "'!='" + dataRoot.getName()
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    84
                            + "')");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    85
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    86
        mergeNode(root, dataRoot);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    87
        write();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    88
        
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    89
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
     * Add all sub element of data file into the merged file. If the root
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
     * element name is different for the merged file an XMLMergerException is
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
     * thrown.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
     * @param data
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
     *            the input file.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
     * @throws XMLMergerException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
    public void merge(File data) throws XMLMergerException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
        log.debug("Merging " + data.getAbsolutePath());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        try {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
            SAXReader reader = new SAXReader();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
            Document dataDoc = reader.read(data);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
            Element dataRoot = dataDoc.getRootElement();
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   105
            merge(dataDoc);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
        } catch (DocumentException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
            throw new XMLMergerException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
     * Merging two XML elements. It only keeps difference.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
     * @param dest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
     * @param src
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
    @SuppressWarnings("unchecked")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
    protected void mergeNode(Element dest, Element src) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
        for (Iterator<Element> node = src.elements().iterator(); node.hasNext();) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   120
            Element element = node.next();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
            
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   122
            List<Element> ses = dest.elements(element.getName());
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
            boolean add = true;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
            for (Element se : ses) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   125
                if (areSame(se, element)) {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   126
                    log.debug("Element " + element.getName() + " already found in dest.");
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
                    add = false;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
            if (add) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   131
                log.debug("Adding node " + element.getName() + " to " + dest.getName());
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   132
                dest.add(element.detach());
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
            } else if (ses.size() > 0) {
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   134
                log.debug("Merging " + ses.get(0).getName() + " to " + element.getName());
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   135
                mergeNode(ses.get(0), element);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
     * Compare two elements name and attributes. Returns true if name and all
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
     * attributes are matching, false otherwise.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
     * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
     * @param a
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
     * @param b
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
     * @return boolean
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
    @SuppressWarnings("unchecked")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
    protected boolean areSame(Element a, Element b) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
        log.debug("areSame:" + a + " <=> " + b);
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   151
        if (!a.getName().equals(b.getName())) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
            return false;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   153
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
        log.debug("same attribute list size?");
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   155
        if (a.attributes().size() != b.attributes().size()) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
            return false;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   157
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        log.debug("same attribute list?");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        for (Iterator<Attribute> at = a.attributes().iterator(); at.hasNext();) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
            Attribute attra = at.next();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
            Attribute attrb = b.attribute(attra.getName());
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   162
            if (attrb == null || !attra.getValue().equals(attrb.getValue())) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
                return false;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   164
            }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   166
        if (!a.getTextTrim().equals(b.getTextTrim())) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
            return false;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   168
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        return true;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
     * Write the XML content back the file.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
     * @throws XMLMergerException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
    protected void write() throws XMLMergerException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        try {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   178
            FileOutputStream fos = new FileOutputStream(outputFile);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
            OutputFormat format = OutputFormat.createPrettyPrint();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
            XMLWriter writer = new XMLWriter(fos, format);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
            writer.write(doc);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
            writer.flush();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
        } catch (FileNotFoundException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
            throw new XMLMergerException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
        } catch (UnsupportedEncodingException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
            throw new XMLMergerException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
        } catch (IOException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
            throw new XMLMergerException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
     * Exception class related to the XMLMerger. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
    public class XMLMergerException extends Exception {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
        private static final long serialVersionUID = 7624650310086957316L;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
        /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
         * Default constructor.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
         * @param msg error message
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
         */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
        public XMLMergerException(String msg) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
            super(msg);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
}