|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LogEntry | Line # 41 | 16 | 0% | 16 | 4 | 87,5% |
0.875
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (42) | |||
| Result | |||
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
|
1 PASS | |
|
0.625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
|
1 PASS | |
|
0.5625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
|
1 PASS | |
|
0.5625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
|
1 PASS | |
|
0.5625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
|
1 PASS | |
|
0.5625
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
|
1 PASS | |
|
0.4375
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
|
1 PASS | |
|
0.25
|
net.sourceforge.pebble.logging.LogEntryTest.testRequest
net.sourceforge.pebble.logging.LogEntryTest.testRequest
|
1 PASS | |
|
0.25
|
net.sourceforge.pebble.logging.LogEntryTest.testRequest
net.sourceforge.pebble.logging.LogEntryTest.testRequest
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testAgent
net.sourceforge.pebble.logging.LogEntryTest.testAgent
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testHost
net.sourceforge.pebble.logging.LogEntryTest.testHost
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testAgent
net.sourceforge.pebble.logging.LogEntryTest.testAgent
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testDate
net.sourceforge.pebble.logging.LogEntryTest.testDate
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testStatusCode
net.sourceforge.pebble.logging.LogEntryTest.testStatusCode
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testStatusCode
net.sourceforge.pebble.logging.LogEntryTest.testStatusCode
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testHost
net.sourceforge.pebble.logging.LogEntryTest.testHost
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testReferer
net.sourceforge.pebble.logging.LogEntryTest.testReferer
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testReferer
net.sourceforge.pebble.logging.LogEntryTest.testReferer
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.logging.LogEntryTest.testDate
net.sourceforge.pebble.logging.LogEntryTest.testDate
|
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 java.util.Date; | |
| 35 | ||
| 36 | /** | |
| 37 | * Represents an entry (line) in a log file. | |
| 38 | * | |
| 39 | * @author Simon Brown | |
| 40 | */ | |
| 41 | public class LogEntry { | |
| 42 | ||
| 43 | /** the host that made the request */ | |
| 44 | private String host; | |
| 45 | ||
| 46 | /** the date the request was made */ | |
| 47 | private Date date = new Date(); | |
| 48 | ||
| 49 | /** the HTTP request */ | |
| 50 | private String request = ""; | |
| 51 | ||
| 52 | /** the HTTP status code returned */ | |
| 53 | private int statusCode = 200; | |
| 54 | ||
| 55 | /** the number of bytes returned */ | |
| 56 | private long bytes = -1; | |
| 57 | ||
| 58 | /** the referer (if applicable) */ | |
| 59 | private String referer; | |
| 60 | ||
| 61 | /** the user-agent (if applicable) */ | |
| 62 | private String agent; | |
| 63 | ||
| 64 | /** | |
| 65 | * Gets the host (an IP address or DNS name). | |
| 66 | * | |
| 67 | * @return the host as a String | |
| 68 | */ | |
| 69 | 40 |
public String getHost() { |
| 70 | 40 | return host; |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * Sets the host (an IP address or DNS name). | |
| 75 | * | |
| 76 | * @param host the host as a String | |
| 77 | */ | |
| 78 | 12 |
public void setHost(String host) { |
| 79 | 12 | this.host = host; |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * Gets the date. | |
| 84 | * | |
| 85 | * @return a Date | |
| 86 | */ | |
| 87 | 50 |
public Date getDate() { |
| 88 | 50 | return date; |
| 89 | } | |
| 90 | ||
| 91 | /** | |
| 92 | * Sets the date. | |
| 93 | * | |
| 94 | * @param date a Date instance | |
| 95 | */ | |
| 96 | 18 |
public void setDate(Date date) { |
| 97 | 18 | this.date = date; |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Gets the request. | |
| 102 | * | |
| 103 | * @return the request as a String | |
| 104 | */ | |
| 105 | 34 |
public String getRequest() { |
| 106 | 34 | return request; |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * Gets just the method portion of the request. | |
| 111 | * | |
| 112 | * @return the request method as a String | |
| 113 | */ | |
| 114 | 2 |
public String getRequestMethod() { |
| 115 | 2 | return request.substring(0, request.indexOf("/")-1); |
| 116 | } | |
| 117 | ||
| 118 | /** | |
| 119 | * Gets just the URI portion of the request. | |
| 120 | * | |
| 121 | * @return the request URI as a String | |
| 122 | */ | |
| 123 | 2 |
public String getRequestUri() { |
| 124 | 2 | return request.substring(request.indexOf("/")); |
| 125 | } | |
| 126 | ||
| 127 | /** | |
| 128 | * Sets the request. | |
| 129 | * | |
| 130 | * @param request the HTTP request as a String | |
| 131 | */ | |
| 132 | 22 |
public void setRequest(String request) { |
| 133 | 22 | this.request = request; |
| 134 | } | |
| 135 | ||
| 136 | /** | |
| 137 | * Gets the HTTP status code. | |
| 138 | * | |
| 139 | * @return the status code as an int (-1 if not set) | |
| 140 | */ | |
| 141 | 32 |
public int getStatusCode() { |
| 142 | 32 | return statusCode; |
| 143 | } | |
| 144 | ||
| 145 | /** | |
| 146 | * Sets the HTTP status code. | |
| 147 | * | |
| 148 | * @param statusCode the status code | |
| 149 | */ | |
| 150 | 18 |
public void setStatusCode(int statusCode) { |
| 151 | 18 | this.statusCode = statusCode; |
| 152 | } | |
| 153 | ||
| 154 | /** | |
| 155 | * Gets the number of bytes sent. | |
| 156 | * | |
| 157 | * @return the number of bytes as a long (-1 if not set) | |
| 158 | */ | |
| 159 | 0 |
public long getBytes() { |
| 160 | 0 | return bytes; |
| 161 | } | |
| 162 | ||
| 163 | /** | |
| 164 | * Sets the number of bytes sent. | |
| 165 | * | |
| 166 | * @param bytes the number of bytes sent | |
| 167 | */ | |
| 168 | 0 |
public void setBytes(long bytes) { |
| 169 | 0 | this.bytes = bytes; |
| 170 | } | |
| 171 | ||
| 172 | /** | |
| 173 | * Gets the referer. | |
| 174 | * | |
| 175 | * @return the refering URL as a String | |
| 176 | */ | |
| 177 | 40 |
public String getReferer() { |
| 178 | 40 | return referer; |
| 179 | } | |
| 180 | ||
| 181 | /** | |
| 182 | * Sets the referer. | |
| 183 | * | |
| 184 | * @param referer the refering URL as a String | |
| 185 | */ | |
| 186 | 12 |
public void setReferer(String referer) { |
| 187 | 12 | this.referer = referer; |
| 188 | } | |
| 189 | ||
| 190 | /** | |
| 191 | * Gets the user agent (e.g. Mozilla, Internet Explorer, Safari, etc). | |
| 192 | * | |
| 193 | * @return the user agent as a String | |
| 194 | */ | |
| 195 | 40 |
public String getAgent() { |
| 196 | 40 | return agent; |
| 197 | } | |
| 198 | ||
| 199 | /** | |
| 200 | * Sets the user agent. | |
| 201 | * | |
| 202 | * @param agent the user agent as a String | |
| 203 | */ | |
| 204 | 12 |
public void setAgent(String agent) { |
| 205 | 12 | this.agent = agent; |
| 206 | } | |
| 207 | ||
| 208 | } | |
|
||||||||||||