Coverage Report - org.apache.maven.shared.utils.xml.Xpp3DomWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
Xpp3DomWriter
80%
17/21
87%
7/8
2
 
 1  
 package org.apache.maven.shared.utils.xml;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.PrintWriter;
 23  
 import java.io.Writer;
 24  
 
 25  
 /**
 26  
  * @author Brett Porter
 27  
  */
 28  0
 public class Xpp3DomWriter
 29  
 {
 30  
     public static void write( Writer writer, Xpp3Dom dom )
 31  
     {
 32  2
         write( new PrettyPrintXMLWriter( writer ), dom );
 33  2
     }
 34  
 
 35  
     public static void write( PrintWriter writer, Xpp3Dom dom )
 36  
     {
 37  0
         write( new PrettyPrintXMLWriter( writer ), dom );
 38  0
     }
 39  
 
 40  
     public static void write( XMLWriter xmlWriter, Xpp3Dom dom )
 41  
     {
 42  3
         write( xmlWriter, dom, true );
 43  3
     }
 44  
 
 45  
     public static void write( XMLWriter xmlWriter, Xpp3Dom dom, boolean escape )
 46  
     {
 47  9
         xmlWriter.startElement( dom.getName() );
 48  9
         String[] attributeNames = dom.getAttributeNames();
 49  10
         for (String attributeName : attributeNames) {
 50  1
             xmlWriter.addAttribute(attributeName, dom.getAttribute(attributeName));
 51  
         }
 52  9
         Xpp3Dom[] children = dom.getChildren();
 53  15
         for (Xpp3Dom aChildren : children) {
 54  6
             write(xmlWriter, aChildren, escape);
 55  
         }
 56  
 
 57  9
         String value = dom.getValue();
 58  9
         if ( value != null )
 59  
         {
 60  6
             if ( escape )
 61  
             {
 62  6
                 xmlWriter.writeText( value );
 63  
             }
 64  
             else
 65  
             {
 66  0
                 xmlWriter.writeMarkup( value );
 67  
             }
 68  
         }
 69  9
         xmlWriter.endElement();
 70  9
     }
 71  
 
 72  
 
 73  
 }