1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package convwatch; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.io.File; 27cdf0e10cSrcweir import java.io.FileWriter; 28cdf0e10cSrcweir 29cdf0e10cSrcweir public class INIOutputter 30cdf0e10cSrcweir { 31cdf0e10cSrcweir FileWriter m_aOut; 32cdf0e10cSrcweir String m_sFilename; 33cdf0e10cSrcweir String m_sNamePrefix; // the HTML files used a suffix to build it's right name 34cdf0e10cSrcweir 35cdf0e10cSrcweir /** 36cdf0e10cSrcweir * ls is the current line separator (carridge return) 37cdf0e10cSrcweir */ 38cdf0e10cSrcweir String ls; 39cdf0e10cSrcweir create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle )40cdf0e10cSrcweir public static INIOutputter create( String _sOutputPath, String _sHTMLFilename, String _sNamePrefix, String _sTitle ) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir FileHelper.makeDirectories("", _sOutputPath); 43cdf0e10cSrcweir INIOutputter a = new INIOutputter(); 44cdf0e10cSrcweir String fs = System.getProperty("file.separator"); 45cdf0e10cSrcweir String sFilename = _sOutputPath + fs + _sHTMLFilename; 46cdf0e10cSrcweir 47cdf0e10cSrcweir try 48cdf0e10cSrcweir { 49cdf0e10cSrcweir File outputFile = new File(sFilename); 50cdf0e10cSrcweir a.m_aOut = new FileWriter(outputFile.toString()); 51cdf0e10cSrcweir a.ls = System.getProperty("line.separator"); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir catch (java.io.IOException e) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir e.printStackTrace(); 56cdf0e10cSrcweir GlobalLogWriter.get().println("ERROR: Can't create INI Outputter"); 57cdf0e10cSrcweir return null; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir a.m_sFilename = sFilename; 60cdf0e10cSrcweir a.m_sNamePrefix = _sNamePrefix; 61cdf0e10cSrcweir 62cdf0e10cSrcweir return a; 63cdf0e10cSrcweir } getFilename()64cdf0e10cSrcweir public String getFilename() {return m_sFilename;} 65cdf0e10cSrcweir createHeader()66cdf0e10cSrcweir public void createHeader() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir try 69cdf0e10cSrcweir { 70cdf0e10cSrcweir m_aOut.write("; This file is automatically created by a convwatch run" + ls); 71cdf0e10cSrcweir m_aOut.write("; " + ls); 72cdf0e10cSrcweir m_aOut.write("; If you see this file in a browser you may have forgotten to set the follows in the property file" + ls); 73cdf0e10cSrcweir m_aOut.write("; " + PropertyName.DOC_COMPARATOR_HTML_OUTPUT_PREFIX + "=http://lla-1.germany/gfxcmp/cw.php?inifile=" + ls); 74cdf0e10cSrcweir m_aOut.write("; Please check the documentation if you got confused." + ls); 75cdf0e10cSrcweir m_aOut.write("; " + ls); 76cdf0e10cSrcweir m_aOut.write("; " + ls); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir catch (java.io.IOException e) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir } 81cdf0e10cSrcweir } 82cdf0e10cSrcweir writeSection(String _sSectionName)83cdf0e10cSrcweir public void writeSection(String _sSectionName) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir try 86cdf0e10cSrcweir { 87cdf0e10cSrcweir m_aOut.write("[" + _sSectionName + "]" + ls); 88cdf0e10cSrcweir m_aOut.flush(); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir catch (java.io.IOException e) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir } 93cdf0e10cSrcweir } 94cdf0e10cSrcweir writeValue(String _sName, String _sValue)95cdf0e10cSrcweir public void writeValue(String _sName, String _sValue) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir try 98cdf0e10cSrcweir { 99cdf0e10cSrcweir m_aOut.write(_sName + "=" + _sValue + ls); 100cdf0e10cSrcweir m_aOut.flush(); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir catch (java.io.IOException e) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir } 106cdf0e10cSrcweir startSection(int _nNumber)107cdf0e10cSrcweir public void startSection(int _nNumber) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir writeSection( "page" + String.valueOf(_nNumber)); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir close()112cdf0e10cSrcweir public void close() 113cdf0e10cSrcweir { 114cdf0e10cSrcweir try 115cdf0e10cSrcweir { 116cdf0e10cSrcweir m_aOut.flush(); 117cdf0e10cSrcweir m_aOut.close(); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir catch (java.io.IOException e) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir checkLine(StatusHelper _aStatus, boolean _bCurrentResult)124cdf0e10cSrcweir public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir try 127cdf0e10cSrcweir { 128cdf0e10cSrcweir m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls); 129cdf0e10cSrcweir m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls); 130cdf0e10cSrcweir m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls); 131cdf0e10cSrcweir 132cdf0e10cSrcweir String sPercent = String.valueOf(_aStatus.nPercent) + "%"; 133cdf0e10cSrcweir if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir sPercent += " (less 5% is ok)"; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir m_aOut.write("percent=" + sPercent + ls); 138cdf0e10cSrcweir 139cdf0e10cSrcweir if (_aStatus.m_sDiff_BM_Gfx == null) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir m_aOut.write("BM=false" + ls); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir else 144cdf0e10cSrcweir { 145cdf0e10cSrcweir m_aOut.write("BM=true" + ls); 146cdf0e10cSrcweir m_aOut.write( "old_BM_gfx=" + _aStatus.m_sOld_BM_Gfx + ls); 147cdf0e10cSrcweir m_aOut.write( "new_BM_gfx=" + _aStatus.m_sNew_BM_Gfx + ls); 148cdf0e10cSrcweir m_aOut.write( "diff_BM_gfx=" + _aStatus.m_sDiff_BM_Gfx + ls); 149cdf0e10cSrcweir 150cdf0e10cSrcweir String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%"; 151cdf0e10cSrcweir if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir sPercent2 += " (less 5% is ok)"; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir m_aOut.write("percent2=" + sPercent2 + ls); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir writeResult(_bCurrentResult); 159cdf0e10cSrcweir m_aOut.flush(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir catch (java.io.IOException e) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir } 164cdf0e10cSrcweir } 165cdf0e10cSrcweir writeResult(boolean _bCurrentResult)166cdf0e10cSrcweir void writeResult(boolean _bCurrentResult) throws java.io.IOException 167cdf0e10cSrcweir { 168cdf0e10cSrcweir // is the check positiv, in a defined range 169cdf0e10cSrcweir if (_bCurrentResult) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir m_aOut.write("result=YES" + ls); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir else 174cdf0e10cSrcweir { 175cdf0e10cSrcweir m_aOut.write("result=NO" + ls); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)179cdf0e10cSrcweir public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir try 182cdf0e10cSrcweir { 183cdf0e10cSrcweir m_aOut.write( "oldgfx=" + _aStatus.m_sOldGfx + ls); 184cdf0e10cSrcweir m_aOut.write( "newgfx=" + _aStatus.m_sNewGfx + ls); 185cdf0e10cSrcweir m_aOut.write( "diffgfx=" + _aStatus.m_sDiffGfx + ls); 186cdf0e10cSrcweir 187cdf0e10cSrcweir String sPercent = String.valueOf(_aStatus.nPercent) + "%"; 188cdf0e10cSrcweir // if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5) 189cdf0e10cSrcweir // { 190cdf0e10cSrcweir // sPercent += " (less 5% is ok)"; 191cdf0e10cSrcweir // } 192cdf0e10cSrcweir m_aOut.write("percent=" + sPercent + ls); 193cdf0e10cSrcweir 194cdf0e10cSrcweir // is the check positiv, in a defined range 195cdf0e10cSrcweir writeResult(_bCurrentResult); 196cdf0e10cSrcweir m_aOut.flush(); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir catch (java.io.IOException e) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir } 204