| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Defect |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * Copyright (c) 2011-2015, jcabi.com | |
| 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 | |
| 7 | * are met: 1) Redistributions of source code must retain the above | |
| 8 | * copyright notice, this list of conditions and the following | |
| 9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
| 10 | * copyright notice, this list of conditions and the following | |
| 11 | * disclaimer in the documentation and/or other materials provided | |
| 12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
| 13 | * the names of its contributors may be used to endorse or promote | |
| 14 | * products derived from this software without specific prior written | |
| 15 | * permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | */ | |
| 30 | package com.jcabi.w3c; | |
| 31 | ||
| 32 | import com.jcabi.log.Logger; | |
| 33 | import lombok.EqualsAndHashCode; | |
| 34 | ||
| 35 | /** | |
| 36 | * Validation defect (error or warning) produced by {@link ValidationResponse}. | |
| 37 | * | |
| 38 | * <p>Objects of this class are immutable and thread-safe. | |
| 39 | * | |
| 40 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
| 41 | * @version $Id$ | |
| 42 | * @see <a href="http://validator.w3.org/docs/api.html">W3C API</a> | |
| 43 | * @checkstyle LineLength (2 lines) | |
| 44 | */ | |
| 45 | 0 | @EqualsAndHashCode(of = { "iline", "icolumn", "isource", "iexplanation", "msg", "imessage" }) |
| 46 | public final class Defect { | |
| 47 | ||
| 48 | /** | |
| 49 | * Line. | |
| 50 | */ | |
| 51 | private final transient int iline; | |
| 52 | ||
| 53 | /** | |
| 54 | * Column. | |
| 55 | */ | |
| 56 | private final transient int icolumn; | |
| 57 | ||
| 58 | /** | |
| 59 | * Source line. | |
| 60 | */ | |
| 61 | private final transient String isource; | |
| 62 | ||
| 63 | /** | |
| 64 | * Explanation. | |
| 65 | */ | |
| 66 | private final transient String iexplanation; | |
| 67 | ||
| 68 | /** | |
| 69 | * Message id. | |
| 70 | */ | |
| 71 | private final transient String msg; | |
| 72 | ||
| 73 | /** | |
| 74 | * The message. | |
| 75 | */ | |
| 76 | private final transient String imessage; | |
| 77 | ||
| 78 | /** | |
| 79 | * Protected ctor, to be called only from this package. | |
| 80 | * @param line Line number | |
| 81 | * @param column Column number | |
| 82 | * @param source Source line | |
| 83 | * @param explanation The explanation | |
| 84 | * @param mid ID of the message | |
| 85 | * @param message Message text | |
| 86 | * @checkstyle ParameterNumber (5 lines) | |
| 87 | */ | |
| 88 | Defect(final int line, final int column, final String source, | |
| 89 | final String explanation, final String mid, | |
| 90 | 1 | final String message) { |
| 91 | 1 | this.iline = line; |
| 92 | 1 | this.icolumn = column; |
| 93 | 1 | this.isource = source.trim(); |
| 94 | 1 | this.iexplanation = explanation.trim(); |
| 95 | 1 | this.msg = mid.trim(); |
| 96 | 1 | this.imessage = message.trim(); |
| 97 | 1 | } |
| 98 | ||
| 99 | @Override | |
| 100 | public String toString() { | |
| 101 | 1 | return Logger.format( |
| 102 | "[%d:%d] \"%s\", \"%s\", \"%s\", \"%s\"", | |
| 103 | this.iline, | |
| 104 | this.icolumn, | |
| 105 | this.isource, | |
| 106 | this.iexplanation, | |
| 107 | this.msg, | |
| 108 | this.imessage | |
| 109 | ); | |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * Line number, where the defect was found. | |
| 114 | * @return Line number | |
| 115 | */ | |
| 116 | public int line() { | |
| 117 | 0 | return this.iline; |
| 118 | } | |
| 119 | ||
| 120 | /** | |
| 121 | * Column number inside the line. | |
| 122 | * @return Column number | |
| 123 | */ | |
| 124 | public int column() { | |
| 125 | 0 | return this.icolumn; |
| 126 | } | |
| 127 | ||
| 128 | /** | |
| 129 | * Source line, as quoted by W3C validator. | |
| 130 | * @return Full text of the source line | |
| 131 | */ | |
| 132 | public String source() { | |
| 133 | 0 | return this.isource; |
| 134 | } | |
| 135 | ||
| 136 | /** | |
| 137 | * Explanation of the problem. | |
| 138 | * @return Text | |
| 139 | */ | |
| 140 | public String explanation() { | |
| 141 | 0 | return this.iexplanation; |
| 142 | } | |
| 143 | ||
| 144 | /** | |
| 145 | * Message ID, according to W3C API. | |
| 146 | * @return The ID | |
| 147 | */ | |
| 148 | public String messageId() { | |
| 149 | 0 | return this.msg; |
| 150 | } | |
| 151 | ||
| 152 | /** | |
| 153 | * Text of the message. | |
| 154 | * @return The message returned by W3C server | |
| 155 | */ | |
| 156 | public String message() { | |
| 157 | 0 | return this.imessage; |
| 158 | } | |
| 159 | ||
| 160 | } |