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  
         {
 51  1
             xmlWriter.addAttribute( attributeName, dom.getAttribute( attributeName ) );
 52  
         }
 53  9
         Xpp3Dom[] children = dom.getChildren();
 54  15
         for ( Xpp3Dom aChildren : children )
 55  
         {
 56  6
             write( xmlWriter, aChildren, escape );
 57  
         }
 58  
 
 59  9
         String value = dom.getValue();
 60  9
         if ( value != null )
 61  
         {
 62  6
             if ( escape )
 63  
             {
 64  6
                 xmlWriter.writeText( value );
 65  
             }
 66  
             else
 67  
             {
 68  0
                 xmlWriter.writeMarkup( value );
 69  
             }
 70  
         }
 71  9
         xmlWriter.endElement();
 72  9
     }
 73  
 
 74  
 }