1 13 package org.jahia.services.fields; 14 15 import org.jahia.data.ConnectionTypes; 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.params.ParamBean; 18 import org.jahia.services.version.ActivationTestResults; 19 import org.jahia.services.version.ContentObjectEntryState; 20 import org.jahia.services.version.EntrySaveRequest; 21 import org.jahia.services.version.StateModificationContext; 22 import org.jahia.utils.xml.XMLSerializationOptions; 23 import org.jahia.utils.xml.XmlWriter; 24 25 import java.io.IOException ; 26 import java.util.Hashtable ; 27 import java.util.Set ; 28 import java.util.Vector ; 29 30 public class ContentFloatField extends ContentField implements ContentSimpleField { 31 private static org.apache.log4j.Logger logger 32 = org.apache.log4j.Logger.getLogger (ContentFloatField.class); 33 34 protected ContentFloatField (Integer ID, 36 Integer jahiaID, 37 Integer pageID, 38 Integer ctnid, 39 Integer fieldDefID, 40 Integer fieldType, 41 Integer connectType, 42 Integer aclID, 43 Vector activeAndStagingEntryStates, 44 Hashtable activeAndStagedDBValues) { 45 super (ID.intValue (), jahiaID.intValue (), pageID.intValue (), 46 ctnid.intValue (), fieldDefID.intValue (), fieldType.intValue (), 47 connectType.intValue (), aclID.intValue (), 48 activeAndStagingEntryStates, activeAndStagedDBValues); 49 } 50 51 public static synchronized ContentFloatField 53 createFloat (int siteID, 54 int pageID, 55 int containerID, 56 int fieldDefID, 57 int parentAclID, int aclID, 58 float value, 59 ParamBean jParams) 60 throws JahiaException { 61 ContentFloatField result = 62 (ContentFloatField) 63 ContentField.createField (siteID, pageID, containerID, 64 fieldDefID, ContentFieldTypes.BOOLEAN, 65 ConnectionTypes.LOCAL, parentAclID, 66 aclID); 67 68 EntrySaveRequest saveRequest = 69 new EntrySaveRequest (jParams.getUser (), 70 ContentField.SHARED_LANGUAGE); 71 72 result.setFloat (value, saveRequest); 73 return result; 74 } 75 76 84 public String getValue (ParamBean jParams, 85 ContentObjectEntryState entryState) 86 throws JahiaException { 87 return getDBValue (entryState); 89 } 90 91 96 public void setFloat (float value, 97 EntrySaveRequest saveRequest) 98 throws JahiaException { 99 preSet (String.valueOf (value), saveRequest); 100 } 101 102 111 public String getValueForSearch (ParamBean jParams, 112 ContentObjectEntryState entryState) 113 throws JahiaException { 114 return getDBValue (entryState); 115 } 116 117 134 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 135 ContentObjectEntryState toEntryState, 136 ParamBean jParams, 137 StateModificationContext stateModifContext) 138 throws JahiaException { 139 return new ActivationTestResults (); 140 } 141 142 protected ActivationTestResults isContentValidForActivation ( 144 Set languageCodes, 145 ParamBean jParams, 146 StateModificationContext stateModifContext) 147 throws JahiaException { 148 149 return new ActivationTestResults (); 150 } 151 152 157 public boolean isShared () { 158 return true; 159 } 160 161 182 protected void serializeContentToXML (XmlWriter xmlWriter, 183 XMLSerializationOptions xmlSerializationOptions, 184 ContentObjectEntryState entryState, 185 ParamBean paramBean) throws IOException { 186 try { 187 String result = getDBValue (entryState); 189 xmlWriter.writeCData (result); 190 } catch (JahiaException je) { 191 logger.debug ("Error while serializing small text field to XML : ", je); 192 } 193 } 194 195 196 } 197 | Popular Tags |