1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package convwatch;
25 
26 import java.io.File;
27 import java.io.FileWriter;
28 
29 public class LISTOutputter
30 {
31     FileWriter m_aOut;
32     String m_sFilename;
33 
34     /**
35      * ls is the current line separator (carridge return)
36      */
37     String ls;
38 
create( String _sOutputPath, String _sFilename)39     public static LISTOutputter create( String _sOutputPath, String _sFilename)
40         {
41             FileHelper.makeDirectories("", _sOutputPath);
42             LISTOutputter a = new LISTOutputter();
43             String fs = System.getProperty("file.separator");
44             String sFilename = _sOutputPath + fs + _sFilename;
45 
46             try
47             {
48                 File outputFile = new File(sFilename);
49                 a.m_aOut = new FileWriter(outputFile.toString());
50                 a.ls = System.getProperty("line.separator");
51             }
52             catch (java.io.IOException e)
53             {
54                 e.printStackTrace();
55                 GlobalLogWriter.get().println("ERROR: Can't create LIST Outputter");
56                 return null;
57             }
58             a.m_sFilename = sFilename;
59 
60             return a;
61         }
getFilename()62     public String getFilename() {return m_sFilename;}
63 
createHeader()64     public void createHeader()
65         {
66             try
67             {
68                 m_aOut.write("# This file is automatically created by a convwatch run" + ls);
69                 m_aOut.write("# " + ls);
70             }
71             catch (java.io.IOException e)
72             {
73             }
74         }
75 
writeValue(String _sValue)76     public void writeValue(String _sValue)
77         {
78             try
79             {
80                 m_aOut.write(_sValue + ls);
81                 m_aOut.flush();
82             }
83             catch (java.io.IOException e)
84             {
85             }
86         }
87 
close()88     public void close()
89         {
90             try
91             {
92                 m_aOut.flush();
93                 m_aOut.close();
94             }
95             catch (java.io.IOException e)
96             {
97             }
98         }
99 
100 }
101