|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AbstractLogger | Line # 44 | 35 | 0% | 12 | 29 | 43,1% |
0.43137255
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (18) | |||
| Result | |||
|
0.39215687
|
net.sourceforge.pebble.logging.CombinedLogFormatLoggerTest.testAllMonthsReturnedInYearlySummary
net.sourceforge.pebble.logging.CombinedLogFormatLoggerTest.testAllMonthsReturnedInYearlySummary
|
1 PASS | |
|
0.39215687
|
net.sourceforge.pebble.logging.CombinedLogFormatLoggerTest.testAllMonthsReturnedInYearlySummary
net.sourceforge.pebble.logging.CombinedLogFormatLoggerTest.testAllMonthsReturnedInYearlySummary
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testComment
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testComment
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testMultipleSubCategory
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testMultipleSubCategory
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerpt
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerpt
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testMultipleSubCategory
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testMultipleSubCategory
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerptNoExtendedBody
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerptNoExtendedBody
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testUTF8
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testUTF8
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testImport
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testImport
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testImport
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testImport
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testComment
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testComment
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testPublished
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testPublished
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerpt
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerpt
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testUTF8
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testUTF8
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerptNoExtendedBody
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoExcerptNoExtendedBody
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoPrimaryCategory
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoPrimaryCategory
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoPrimaryCategory
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testNoPrimaryCategory
|
1 PASS | |
|
0.039215688
|
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testPublished
net.sourceforge.pebble.util.importer.MovableTypeImporterTest.testPublished
|
1 PASS | |
| 1 | /* | |
| 2 | * Copyright (c) 2003-2006, Simon Brown | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions are met: | |
| 7 | * | |
| 8 | * - Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * | |
| 11 | * - Redistributions in binary form must reproduce the above copyright | |
| 12 | * notice, this list of conditions and the following disclaimer in | |
| 13 | * the documentation and/or other materials provided with the | |
| 14 | * distribution. | |
| 15 | * | |
| 16 | * - Neither the name of Pebble nor the names of its contributors may | |
| 17 | * be used to endorse or promote products derived from this software | |
| 18 | * without specific prior written permission. | |
| 19 | * | |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | */ | |
| 32 | package net.sourceforge.pebble.logging; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.domain.Blog; | |
| 35 | ||
| 36 | import javax.servlet.http.HttpServletRequest; | |
| 37 | import java.util.*; | |
| 38 | ||
| 39 | /** | |
| 40 | * Interface that all loggers implement. | |
| 41 | * | |
| 42 | * @author Simon Brown | |
| 43 | */ | |
| 44 | public abstract class AbstractLogger { | |
| 45 | ||
| 46 | /** the blog that this instance is associated with, and logging for */ | |
| 47 | protected Blog blog; | |
| 48 | ||
| 49 | /** | |
| 50 | * Creates a new log associated with the given blog. | |
| 51 | * | |
| 52 | * @param blog a Blog instance | |
| 53 | */ | |
| 54 | 1336 |
public AbstractLogger(Blog blog) { |
| 55 | 1336 | this.blog = blog; |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Logs a HTTP request. | |
| 60 | * | |
| 61 | * @param request a HttpServletRequest | |
| 62 | */ | |
| 63 | public abstract void log(HttpServletRequest request, int status); | |
| 64 | ||
| 65 | /** | |
| 66 | * Called to start this logger. | |
| 67 | */ | |
| 68 | public abstract void start(); | |
| 69 | ||
| 70 | /** | |
| 71 | * Called to stop this logger. | |
| 72 | */ | |
| 73 | public abstract void stop(); | |
| 74 | ||
| 75 | /** | |
| 76 | * Gets a copy of the log file for a given year, month and day. | |
| 77 | * | |
| 78 | * @param year the year to get entries for | |
| 79 | * @param month the month to get entries for | |
| 80 | * @param day the day to get entries for | |
| 81 | * @return a String containing the contents of the requested log file | |
| 82 | */ | |
| 83 | public abstract String getLogFile(int year, int month, int day); | |
| 84 | ||
| 85 | /** | |
| 86 | * Gets a copy of the log file for today. | |
| 87 | * | |
| 88 | * @return a String containing the contents of the requested log file | |
| 89 | */ | |
| 90 | 0 |
public String getLogFile() { |
| 91 | 0 | Calendar cal = blog.getCalendar(); |
| 92 | 0 | return getLogFile(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH)); |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * Gets a copy of the log file for a given year and month. | |
| 97 | * | |
| 98 | * @param year the year to get entries for | |
| 99 | * @param month the month to get entries for | |
| 100 | * @return a String containing the contents of the requested log file | |
| 101 | */ | |
| 102 | 0 |
public String getLogFile(int year, int month) { |
| 103 | 0 | StringBuffer buf = new StringBuffer(); |
| 104 | 0 | Calendar cal = blog.getCalendar(); |
| 105 | 0 | cal.set(Calendar.YEAR, year); |
| 106 | 0 | cal.set(Calendar.MONTH, month-1); |
| 107 | 0 | for (int day = 1; day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); day++) { |
| 108 | 0 | buf.append(getLogFile(year, month, day)); |
| 109 | } | |
| 110 | ||
| 111 | 0 | return buf.toString(); |
| 112 | } | |
| 113 | ||
| 114 | /** | |
| 115 | * Gets the log for a given year, month and day. | |
| 116 | * | |
| 117 | * @param year the year to get entries for | |
| 118 | * @param month the month to get entries for | |
| 119 | * @param day the day to get entries for | |
| 120 | * @return a Log object | |
| 121 | */ | |
| 122 | public abstract Log getLog(int year, int month, int day); | |
| 123 | ||
| 124 | /** | |
| 125 | * Gets the log for today. | |
| 126 | * | |
| 127 | * @return a Log object | |
| 128 | */ | |
| 129 | 0 |
public Log getLog() { |
| 130 | 0 | Calendar cal = blog.getCalendar(); |
| 131 | 0 | return getLog(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH)); |
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * Gets the log for a given year and month. | |
| 136 | * | |
| 137 | * @param year the year to get entries for | |
| 138 | * @param month the month to get entries for | |
| 139 | * @return a Log object | |
| 140 | */ | |
| 141 | 0 |
public Log getLog(int year, int month) { |
| 142 | 0 | Collection logEntries = new HashSet(); |
| 143 | 0 | Calendar cal = blog.getCalendar(); |
| 144 | 0 | cal.set(Calendar.YEAR, year); |
| 145 | 0 | cal.set(Calendar.MONTH, month-1); |
| 146 | 0 | for (int day = 1; day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); day++) { |
| 147 | 0 | logEntries.addAll(getLog(year, month, day).getLogEntries()); |
| 148 | } | |
| 149 | ||
| 150 | 0 | return new Log(blog, logEntries); |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * Gets the log summary information for the given year, month and day. | |
| 155 | * | |
| 156 | * @param year the year to get entries for | |
| 157 | * @param month the month to get entries for | |
| 158 | * @param day the day to get entries for | |
| 159 | * @return a LogSummary object | |
| 160 | */ | |
| 161 | public abstract LogSummary getLogSummary(int year, int month, int day); | |
| 162 | ||
| 163 | /** | |
| 164 | * Gets the log summary for today. | |
| 165 | * | |
| 166 | * @return a LogSummary object | |
| 167 | */ | |
| 168 | 0 |
public LogSummary getLogSummary() { |
| 169 | 0 | Calendar cal = blog.getCalendar(); |
| 170 | 0 | return getLogSummary(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH)); |
| 171 | } | |
| 172 | ||
| 173 | /** | |
| 174 | * Gets the log summary information for the given year and month. | |
| 175 | * | |
| 176 | * @param year the year to get entries for | |
| 177 | * @param month the month to get entries for | |
| 178 | * @return a LogSummary object | |
| 179 | */ | |
| 180 | 24 |
public LogSummary getLogSummary(int year, int month) { |
| 181 | 24 | Calendar cal = blog.getCalendar(); |
| 182 | 24 | cal.set(Calendar.YEAR, year); |
| 183 | 24 | cal.set(Calendar.DAY_OF_MONTH, 1); |
| 184 | 24 | cal.set(Calendar.MONTH, month-1); |
| 185 | ||
| 186 | 24 | List logSummaries = new ArrayList(); |
| 187 | 754 | for (int day = 1; day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); day++) { |
| 188 | 730 | logSummaries.add(getLogSummary(year, month, day)); |
| 189 | } | |
| 190 | ||
| 191 | 24 | return new LogSummaryContainer(blog, cal.getTime(), logSummaries); |
| 192 | } | |
| 193 | ||
| 194 | /** | |
| 195 | * Gets the log summary information for the given year. | |
| 196 | * | |
| 197 | * @param year the year to get entries for | |
| 198 | * @return a LogSummary object | |
| 199 | */ | |
| 200 | 2 |
public LogSummary getLogSummary(int year) { |
| 201 | 2 | Calendar cal = blog.getCalendar(); |
| 202 | 2 | cal.set(Calendar.YEAR, year); |
| 203 | ||
| 204 | 2 | List logSummaries = new ArrayList(); |
| 205 | 26 | for (int month = 1; month <= 12; month++) { |
| 206 | 24 | logSummaries.add(getLogSummary(year, month)); |
| 207 | } | |
| 208 | ||
| 209 | 2 | return new LogSummaryContainer(blog, cal.getTime(), logSummaries); |
| 210 | } | |
| 211 | ||
| 212 | } | |
|
||||||||||||