Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
InputFileWrapper |
|
| 1.6666666666666667;1,667 |
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.FileNotFoundException; | |
23 | import java.io.UnsupportedEncodingException; | |
24 | ||
25 | /** | |
26 | * Wrapper for an input file. | |
27 | * | |
28 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
29 | * @version $Id: InputFileWrapper.java 786981 2009-06-21 10:01:58Z ltheussl $ | |
30 | */ | |
31 | public class InputFileWrapper | |
32 | extends AbstractFileWrapper | |
33 | { | |
34 | /** serialVersionUID */ | |
35 | static final long serialVersionUID = 6510443036267371188L; | |
36 | ||
37 | /** | |
38 | * Private constructor. | |
39 | * | |
40 | * @param file not null | |
41 | * @param format could be null | |
42 | * @param charsetName could be null | |
43 | * @param supportedFormat not null | |
44 | * @throws UnsupportedEncodingException if the encoding is unsupported. | |
45 | * @throws FileNotFoundException if the file for absolutePath is not found. | |
46 | */ | |
47 | private InputFileWrapper( String absolutePath, String format, String charsetName, String[] supportedFormat ) | |
48 | throws UnsupportedEncodingException, FileNotFoundException | |
49 | { | |
50 | 0 | super( absolutePath, format, charsetName, supportedFormat ); |
51 | ||
52 | 0 | if ( !getFile().exists() ) |
53 | { | |
54 | 0 | throw new FileNotFoundException( "The file '" + getFile().getAbsolutePath() + "' doesn't exist." ); |
55 | } | |
56 | 0 | } |
57 | ||
58 | /** | |
59 | * @param absolutePath for a file or a directory not null. | |
60 | * @param format could be null | |
61 | * @param supportedFormat not null | |
62 | * @return a type safe input reader | |
63 | * @throws UnsupportedEncodingException if the encoding is unsupported. | |
64 | * @throws FileNotFoundException if the file for absolutePath is not found. | |
65 | * @see #valueOf(String, String, String, String[]) using AUTO_FORMAT | |
66 | */ | |
67 | public static InputFileWrapper valueOf( String absolutePath, String format, String[] supportedFormat ) | |
68 | throws UnsupportedEncodingException, FileNotFoundException | |
69 | { | |
70 | 0 | return valueOf( absolutePath, format, AUTO_FORMAT, supportedFormat ); |
71 | } | |
72 | ||
73 | /** | |
74 | * @param absolutePath for a wanted file or a wanted directory, not null. | |
75 | * @param format could be null | |
76 | * @param charsetName could be null | |
77 | * @param supportedFormat not null | |
78 | * @return a type safe input reader | |
79 | * @throws UnsupportedEncodingException if the encoding is unsupported. | |
80 | * @throws FileNotFoundException if the file for absolutePath is not found. | |
81 | */ | |
82 | public static InputFileWrapper valueOf( String absolutePath, String format, String charsetName, | |
83 | String[] supportedFormat ) | |
84 | throws UnsupportedEncodingException, FileNotFoundException | |
85 | { | |
86 | 0 | return new InputFileWrapper( absolutePath, format, charsetName, supportedFormat ); |
87 | } | |
88 | } |