1 /* 2 * Copyright (c) 2002-2017, Mairie de Paris 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: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software 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 HOLDERS 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 * License 1.0 33 */ 34 package fr.paris.lutece.plugins.directory.business; 35 36 import org.apache.commons.lang.StringUtils; 37 38 /** 39 * 40 * class RecordField 41 * 42 */ 43 public class RecordField 44 { 45 public static final String ATTRIBUTE_GEOLOCATION = "geolocation"; 46 private static final String CONSTANT_LITTLE_THUMBNAIL = "little_thumbnail"; 47 private static final String CONSTANT_BIG_THUMBNAIL = "big_thumbnail"; 48 private int _nIdRecordField; 49 private String _strValue; 50 private IEntry _entry; 51 private Field _field; 52 private File _file; 53 private Record _record; 54 55 /** 56 * This attribute is used for EntryTypeDownloadURL 57 * 58 * {@link EntryTypeDownloadUrl} 59 */ 60 private String _strFileName; 61 62 /** 63 * This attribute is used for EntryTypeDownloadURL 64 * 65 * {@link EntryTypeDownloadUrl} 66 */ 67 private String _strFileExtension; 68 69 /** 70 * 71 * @return the record associate to the field 72 */ 73 public Record getRecord( ) 74 { 75 return _record; 76 } 77 78 /** 79 * the record associate to the field 80 * 81 * @param record 82 * the record 83 */ 84 public void setRecord( Record record ) 85 { 86 _record = record; 87 } 88 89 /** 90 * 91 * @return the entry associate to the field 92 */ 93 public IEntry getEntry( ) 94 { 95 return _entry; 96 } 97 98 /** 99 * set the entry associate to the field 100 * 101 * @param entry 102 * the entry associate to the field 103 */ 104 public void setEntry( IEntry entry ) 105 { 106 _entry = entry; 107 } 108 109 /** 110 * 111 * @return the id of the response 112 */ 113 public int getIdRecordField( ) 114 { 115 return _nIdRecordField; 116 } 117 118 /** 119 * set the id of the record field 120 * 121 * @param idRecordField 122 * the id of the record field 123 */ 124 public void setIdRecordField( int idRecordField ) 125 { 126 _nIdRecordField = idRecordField; 127 } 128 129 /** 130 * 131 * @return the value of the record field 132 */ 133 public String getValue( ) 134 { 135 return _strValue; 136 } 137 138 /** 139 * set the value of the record field 140 * 141 * @param valueRecordField 142 * the value of the record field 143 */ 144 public void setValue( String valueRecordField ) 145 { 146 _strValue = valueRecordField; 147 } 148 149 /** 150 * get the field associate to the response 151 * 152 * @return the field associate to the response 153 */ 154 public Field getField( ) 155 { 156 return _field; 157 } 158 159 /** 160 * set the field associate to the response 161 * 162 * @param field 163 * field 164 */ 165 public void setField( Field field ) 166 { 167 this._field = field; 168 } 169 170 /** 171 * 172 * @return the file associate to the record field 173 */ 174 public File getFile( ) 175 { 176 return _file; 177 } 178 179 /** 180 * set the file associate to the record field 181 * 182 * @param file 183 * the file 184 */ 185 public void setFile( File file ) 186 { 187 _file = file; 188 } 189 190 /** 191 * Check if this record field represents a little thumbnail 192 * 193 * @return True if this record field represents a little thumbnail, false otherwise 194 */ 195 public boolean isLittleThumbnail( ) 196 { 197 if ( StringUtils.isNotBlank( _strValue ) && ( _strValue.startsWith( CONSTANT_LITTLE_THUMBNAIL ) ) ) 198 { 199 return true; 200 } 201 202 return false; 203 } 204 205 /** 206 * Check if this record field represents a big thumbnail 207 * 208 * @return True if this record field represents a big thumbnail, false otherwise 209 */ 210 public boolean isBigThumbnail( ) 211 { 212 if ( StringUtils.isNotBlank( _strValue ) && ( _strValue.startsWith( CONSTANT_BIG_THUMBNAIL ) ) ) 213 { 214 return true; 215 } 216 217 return false; 218 } 219 220 /** 221 * Converts this record field into a string 222 * 223 * @return the value of the recordField 224 */ 225 @Override 226 public String toString( ) 227 { 228 return _strValue; 229 } 230 231 /** 232 * Get the file extensions This attribute is used for EntryTypeDownloadURL 233 * 234 * {@link EntryTypeDownloadUrl} 235 * @return the file extension if the response value is a file 236 */ 237 public String getFileExtension( ) 238 { 239 return _strFileExtension; 240 } 241 242 /** 243 * Set the file extension if the response value is a file This attribute is used for EntryTypeDownloadURL 244 * 245 * {@link EntryTypeDownloadUrl} 246 * @param fileExtension 247 * the file extension if the response value is a file 248 */ 249 public void setFileExtension( String fileExtension ) 250 { 251 _strFileExtension = fileExtension; 252 } 253 254 /** 255 * The file name if the response value is a file This attribute is used for EntryTypeDownloadURL 256 * 257 * {@link EntryTypeDownloadUrl} 258 * @return the file name if the response value is a file 259 */ 260 public String getFileName( ) 261 { 262 return _strFileName; 263 } 264 265 /** 266 * The file name if the response value is a file This attribute is used for EntryTypeDownloadURL 267 * 268 * {@link EntryTypeDownloadUrl} 269 * @param fileName 270 * the file name if the response value is a file 271 */ 272 public void setFileName( String fileName ) 273 { 274 _strFileName = fileName; 275 } 276 }