1 /* 2 * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.exceptions.report.message; 17 18 import java.io.Serializable; 19 20 import de.smartics.exceptions.i18n.message.MessageType; 21 22 /** 23 * Information about a place holder. 24 */ 25 public final class PlaceHolderDesc implements Serializable, 26 Comparable<PlaceHolderDesc> 27 { 28 // ********************************* Fields ********************************* 29 30 // --- constants ------------------------------------------------------------ 31 32 /** 33 * The class version identifier. 34 */ 35 private static final long serialVersionUID = 1L; 36 37 // --- members -------------------------------------------------------------- 38 39 /** 40 * The ID of the place holder. 41 * 42 * @serial 43 */ 44 private final PlaceHolderDescId placeHolderId; 45 46 /** 47 * The descriptive name of the place holder. This is the name of the field 48 * that holds the value. The value may be a complex type where the OGNL path 49 * points to the value of the variable that will substitute the place holder. 50 * 51 * @serial 52 */ 53 private final String paramName; 54 55 /** 56 * The path to the value that substitutes the place holder. 57 * 58 * @serial 59 */ 60 private final String ognlPath; 61 62 /** 63 * The description of the place holder. 64 * 65 * @serial 66 */ 67 private final String description; 68 69 // ****************************** Initializer ******************************* 70 71 // ****************************** Constructors ****************************** 72 73 /** 74 * Copy constructor with a new message type. 75 * 76 * @param desc the description to copy except its message type. 77 * @param messageType the new message type. 78 */ 79 public PlaceHolderDesc(final PlaceHolderDesc desc, 80 final MessageType messageType) 81 { 82 this(new PlaceHolderDescId(desc.getPlaceHolderIndex(), messageType), desc 83 .getParamName(), desc.getOgnlPath(), desc.getDescription()); 84 } 85 86 /** 87 * Default constructor. 88 * 89 * @param placeHolderId the ID of the place holder. 90 * @param paramName the descriptive name of the place holder. 91 * @param ognlPath the path to the value that substitutes the place holder. 92 * @param description the description of the place holder. 93 */ 94 public PlaceHolderDesc(final PlaceHolderDescId placeHolderId, 95 final String paramName, final String ognlPath, final String description) 96 { 97 this.placeHolderId = placeHolderId; 98 this.paramName = paramName; 99 this.ognlPath = ognlPath; 100 this.description = description; 101 } 102 103 // ****************************** Inner Classes ***************************** 104 105 // ********************************* Methods ******************************** 106 107 // --- init ----------------------------------------------------------------- 108 109 // --- get&set -------------------------------------------------------------- 110 111 /** 112 * Returns the ID of the place holder. 113 * 114 * @return the ID of the place holder. 115 */ 116 public PlaceHolderDescId getPlaceHolderId() 117 { 118 return placeHolderId; 119 } 120 121 /** 122 * Returns the index of the place holder within a message of the given message 123 * type. 124 * 125 * @return the index of the place holder within a message of the given message 126 * type. 127 */ 128 public String getPlaceHolderIndex() 129 { 130 return placeHolderId.getPlaceHolderIndex(); 131 } 132 133 /** 134 * Returns the type of the indexed message. 135 * 136 * @return the type of the indexed message. 137 */ 138 public MessageType getPlaceHolderMessageType() 139 { 140 return placeHolderId.getMessageType(); 141 } 142 143 /** 144 * Returns the descriptive name of the place holder. This is the name of the 145 * field that holds the value. The value may be a complex type where the OGNL 146 * path points to the value of the variable that will substitute the place 147 * holder. 148 * 149 * @return the descriptive name of the place holder. 150 */ 151 public String getParamName() 152 { 153 return paramName; 154 } 155 156 /** 157 * Returns the path to the value that substitutes the place holder. 158 * 159 * @return the path to the value that substitutes the place holder. 160 */ 161 public String getOgnlPath() 162 { 163 return ognlPath; 164 } 165 166 /** 167 * Returns the description of the place holder. 168 * 169 * @return the description of the place holder. 170 */ 171 public String getDescription() 172 { 173 return description; 174 } 175 176 // --- business ------------------------------------------------------------- 177 178 // --- object basics -------------------------------------------------------- 179 180 @Override 181 public int compareTo(final PlaceHolderDesc o) 182 { 183 final int compare = placeHolderId.compareTo(o.placeHolderId); 184 return compare; 185 } 186 187 /** 188 * Returns the string representation of the object. 189 * 190 * @return the string representation of the object. 191 */ 192 @Override 193 public String toString() 194 { 195 return placeHolderId + ": " + paramName + ':' + ognlPath + ": " 196 + description; 197 } 198 }