1 /* 2 * Copyright (c) 2002-2014, 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.digglike.business; 35 36 import fr.paris.lutece.portal.service.image.ImageResource; 37 import fr.paris.lutece.util.xml.XmlUtil; 38 39 import java.util.Locale; 40 41 import javax.servlet.http.HttpServletRequest; 42 43 44 /** 45 * 46 * class Response 47 * 48 */ 49 public class Response 50 { 51 private static final String TAG_RESPONSE = "response"; 52 private static final String TAG_RESPONSE_VALUE = "response-value"; 53 private int _nIdResponse; 54 private String _strValueResponse; 55 private IEntry _entry; 56 private DiggSubmit _diggSubmit; 57 private ImageResource _image; 58 private Integer _nIdImageResource; 59 60 /** 61 * 62 * @return the digg submit of the response 63 */ 64 public DiggSubmit getDiggSubmit( ) 65 { 66 return _diggSubmit; 67 } 68 69 /** 70 * set the digg submit of the response 71 * @param diggSubmit the digg submit of the response 72 */ 73 public void setDiggSubmit( DiggSubmit diggSubmit ) 74 { 75 _diggSubmit = diggSubmit; 76 } 77 78 /** 79 * 80 * @return the entry associate to the response 81 */ 82 public IEntry getEntry( ) 83 { 84 return _entry; 85 } 86 87 /** 88 * set the entry associate to the response 89 * @param entry the entry associate to the response 90 */ 91 public void setEntry( IEntry entry ) 92 { 93 _entry = entry; 94 } 95 96 /** 97 * 98 * @return the id of the response 99 */ 100 public int getIdResponse( ) 101 { 102 return _nIdResponse; 103 } 104 105 /** 106 * set the id of the response 107 * @param idResponse the id of the response 108 */ 109 public void setIdResponse( int idResponse ) 110 { 111 _nIdResponse = idResponse; 112 } 113 114 /** 115 * 116 * @return the value of the response 117 */ 118 public String getValueResponse( ) 119 { 120 return _strValueResponse; 121 } 122 123 /** 124 * set the value of the response 125 * @param strValueResponse Value of the response 126 */ 127 public void setValueResponse( String strValueResponse ) 128 { 129 _strValueResponse = strValueResponse; 130 } 131 132 /** 133 * get Image 134 * @return Image Resource 135 */ 136 public ImageResource getImage( ) 137 { 138 return _image; 139 } 140 141 /** 142 * set Image Resource 143 * @param image Image Resource 144 */ 145 public void setImage( ImageResource image ) 146 { 147 this._image = image; 148 } 149 150 /** 151 * Returns the xml of this digg submit 152 * 153 * @param request The HTTP Servlet request 154 * @param locale the Locale 155 * @return the xml of this digg submit 156 */ 157 public String getXml( HttpServletRequest request, Locale locale ) 158 { 159 StringBuffer strXml = new StringBuffer( ); 160 XmlUtil.beginElement( strXml, TAG_RESPONSE ); 161 XmlUtil.addElementHtml( strXml, TAG_RESPONSE_VALUE, this.getValueResponse( ) ); 162 163 if ( this.getEntry( ) != null ) 164 { 165 this.getEntry( ).getXml( locale, strXml ); 166 } 167 168 XmlUtil.endElement( strXml, TAG_RESPONSE ); 169 170 return strXml.toString( ); 171 } 172 173 /** 174 * the image resource id associate to the response 175 * @return Resource Image 176 */ 177 public Integer getIdImageResource( ) 178 { 179 return _nIdImageResource; 180 } 181 182 /** 183 * image resource id associate to the response 184 * @param idImageResource image resource id associate to the response 185 */ 186 public void setIdImageResource( Integer idImageResource ) 187 { 188 _nIdImageResource = idImageResource; 189 } 190 }