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 INIOutputter 30 { 31 FileWriter m_aOut; 32 String m_sFilename; 33 String m_sNamePrefix; // the HTML files used a suffix to build it's right name 34 35 /** 36 * ls is the current line separator (carridge return) 37 */ 38 String ls; 39 create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )40 public static INIOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle ) 41 { 42 FileHelper.makeDirectories("", _sOutputPath); 43 INIOutputter a = new INIOutputter(); 44 String fs = System.getProperty("file.separator"); 45 String sFilename = _sOutputPath + fs + _sHTMLFilename; 46 47 try 48 { 49 File outputFile = new File(sFilename); 50 a.m_aOut = new FileWriter(outputFile.toString()); 51 a.ls = System.getProperty("line.separator"); 52 } 53 catch (java.io.IOException e) 54 { 55 e.printStackTrace(); 56 GlobalLogWriter.get().println("ERROR: Can't create INI Outputter"); 57 return null; 58 } 59 a.m_sFilename = sFilename; 60 a.m_sNamePrefix = _sNamePrefix; 61 62 return a; 63 } getFilename()64 public String getFilename() {return m_sFilename;} 65 createHeader()66 public void createHeader() 67 { 68 try 69 { 70 m_aOut.write("; This file is automatically created by a convwatch run" + ls); 71 m_aOut.write("; " + ls); 72 m_aOut.write("; If you see this file in a browser you may have forgotten to set the follows in the property file" + ls); 73 m_aOut.write("; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://lla-1.germany/gfxcmp/cw.php?inifile=" + ls); 74 m_aOut.write("; Please check the documentation if you got confused." + ls); 75 m_aOut.write("; " + ls); 76 m_aOut.write("; " + ls); 77 } 78 catch (java.io.IOException e) 79 { 80 } 81 } 82 writeSection(String _sSectionName)83 public void writeSection(String _sSectionName) 84 { 85 try 86 { 87 m_aOut.write("[" + _sSectionName + "]" + ls); 88 m_aOut.flush(); 89 } 90 catch (java.io.IOException e) 91 { 92 } 93 } 94 writeValue(String _sName, String _sValue)95 public void writeValue(String _sName, String _sValue) 96 { 97 try 98 { 99 m_aOut.write(_sName + "=" + _sValue + ls); 100 m_aOut.flush(); 101 } 102 catch (java.io.IOException e) 103 { 104 } 105 } 106 startSection(int _nNumber)107 public void startSection(int _nNumber) 108 { 109 writeSection( "page" + String.valueOf(_nNumber)); 110 } 111 close()112 public void close() 113 { 114 try 115 { 116 m_aOut.flush(); 117 m_aOut.close(); 118 } 119 catch (java.io.IOException e) 120 { 121 } 122 } 123 checkLine(StatusHelper _aStatus, boolean _bCurrentResult)124 public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult) 125 { 126 try 127 { 128 m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls); 129 m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls); 130 m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls); 131 132 String sPercent = String.valueOf(_aStatus.nPercent) + "%"; 133 if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5) 134 { 135 sPercent += " (less 5% is ok)"; 136 } 137 m_aOut.write("percent=" + sPercent + ls); 138 139 if (_aStatus.m_sDiff_BM_Gfx == null) 140 { 141 m_aOut.write("BM=false" + ls); 142 } 143 else 144 { 145 m_aOut.write("BM=true" + ls); 146 m_aOut.write( "old_BM_gfx=" + _aStatus.m_sOld_BM_Gfx + ls); 147 m_aOut.write( "new_BM_gfx=" + _aStatus.m_sNew_BM_Gfx + ls); 148 m_aOut.write( "diff_BM_gfx=" + _aStatus.m_sDiff_BM_Gfx + ls); 149 150 String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%"; 151 if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5) 152 { 153 sPercent2 += " (less 5% is ok)"; 154 } 155 m_aOut.write("percent2=" + sPercent2 + ls); 156 } 157 158 writeResult(_bCurrentResult); 159 m_aOut.flush(); 160 } 161 catch (java.io.IOException e) 162 { 163 } 164 } 165 writeResult(boolean _bCurrentResult)166 void writeResult(boolean _bCurrentResult) throws java.io.IOException 167 { 168 // is the check positiv, in a defined range 169 if (_bCurrentResult) 170 { 171 m_aOut.write("result=YES" + ls); 172 } 173 else 174 { 175 m_aOut.write("result=NO" + ls); 176 } 177 } 178 checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)179 public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult) 180 { 181 try 182 { 183 m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls); 184 m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls); 185 m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls); 186 187 String sPercent = String.valueOf(_aStatus.nPercent) + "%"; 188 // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5) 189 // { 190 // sPercent += " (less 5% is ok)"; 191 // } 192 m_aOut.write("percent=" + sPercent + ls); 193 194 // is the check positiv, in a defined range 195 writeResult(_bCurrentResult); 196 m_aOut.flush(); 197 } 198 catch (java.io.IOException e) 199 { 200 } 201 } 202 203 } 204