Coverage Report - org.apache.maven.doxia.wrapper.OutputFileWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
OutputFileWrapper
0%
0/8
0%
0/4
2,333
 
 1  
 package org.apache.maven.doxia.wrapper;
 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.UnsupportedEncodingException;
 23  
 
 24  
 import org.codehaus.plexus.util.StringUtils;
 25  
 import org.codehaus.plexus.util.WriterFactory;
 26  
 
 27  
 /**
 28  
  * Wrapper for an output file.
 29  
  *
 30  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
 31  
  * @version $Id: OutputFileWrapper.java 786981 2009-06-21 10:01:58Z ltheussl $
 32  
  */
 33  
 public class OutputFileWrapper
 34  
     extends AbstractFileWrapper
 35  
 {
 36  
     /** serialVersionUID */
 37  
     static final long serialVersionUID = 804499615902780116L;
 38  
 
 39  
     /**
 40  
      * Private constructor.
 41  
      *
 42  
      * @param file not null
 43  
      * @param format not null
 44  
      * @param charsetName could be null
 45  
      * @param supportedFormat not null.
 46  
      * @throws IllegalArgumentException if any.
 47  
      * @throws UnsupportedEncodingException if the encoding is unsupported.
 48  
      */
 49  
     private OutputFileWrapper( String absolutePath, String format, String charsetName, String[] supportedFormat )
 50  
         throws UnsupportedEncodingException
 51  
     {
 52  0
         super( absolutePath, format, charsetName, supportedFormat );
 53  
 
 54  0
         if ( getFormat().equalsIgnoreCase( AUTO_FORMAT ) )
 55  
         {
 56  0
             throw new IllegalArgumentException( "output format could not be " + AUTO_FORMAT );
 57  
         }
 58  0
     }
 59  
 
 60  
     /**
 61  
      * @param absolutePath not null
 62  
      * @param format not null
 63  
      * @param supportedFormat not null
 64  
      * @return a type safe output writer
 65  
      * @throws UnsupportedEncodingException if the encoding is unsupported.
 66  
      */
 67  
     public static OutputFileWrapper valueOf( String absolutePath, String format, String[] supportedFormat )
 68  
         throws UnsupportedEncodingException
 69  
     {
 70  0
         return valueOf( absolutePath, format, WriterFactory.UTF_8, supportedFormat );
 71  
     }
 72  
 
 73  
     /**
 74  
      * @param absolutePath not null
 75  
      * @param format not null
 76  
      * @param charsetName could be null
 77  
      * @param supportedFormat not null
 78  
      * @return a type safe output writer
 79  
      * @throws UnsupportedEncodingException if the encoding is unsupported.
 80  
      */
 81  
     public static OutputFileWrapper valueOf( String absolutePath, String format, String charsetName,
 82  
                                              String[] supportedFormat )
 83  
         throws UnsupportedEncodingException
 84  
     {
 85  0
         if ( StringUtils.isEmpty( format ) )
 86  
         {
 87  0
             throw new IllegalArgumentException( "output format is required" );
 88  
         }
 89  0
         return new OutputFileWrapper( absolutePath, format, charsetName, supportedFormat );
 90  
     }
 91  
 }