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.util.Hashtable ; 26 import java.util.Set ; 27 import java.util.Vector ; 28 29 public class ContentIntegerField extends ContentField implements ContentSimpleField { 30 private static org.apache.log4j.Logger logger 31 = org.apache.log4j.Logger.getLogger (ContentIntegerField.class); 32 33 protected ContentIntegerField (Integer ID, 34 Integer jahiaID, 35 Integer pageID, 36 Integer ctnid, 37 Integer fieldDefID, 38 Integer fieldType, 39 Integer connectType, 40 Integer aclID, 41 Vector activeAndStagingEntryStates, 42 Hashtable activeAndStagedDBValues) { 43 super (ID.intValue (), jahiaID.intValue (), pageID.intValue (), ctnid.intValue (), fieldDefID.intValue (), 44 fieldType.intValue (), connectType.intValue (), aclID.intValue (), activeAndStagingEntryStates, 45 activeAndStagedDBValues); 46 } 47 48 public static synchronized ContentIntegerField createInteger (int siteID, 49 int pageID, int containerID, 50 int fieldDefID, 51 int parentAclID, int aclID, 52 int value, ParamBean jParams) 53 throws JahiaException { 54 ContentIntegerField result = 55 (ContentIntegerField) ContentField.createField (siteID, pageID, 56 containerID, fieldDefID, 57 ContentFieldTypes.INTEGER, 58 ConnectionTypes.LOCAL, 59 parentAclID, aclID); 60 EntrySaveRequest saveRequest = new EntrySaveRequest (jParams.getUser (), 61 ContentField.SHARED_LANGUAGE); 62 63 result.setInteger (value, saveRequest); 64 return result; 65 } 66 67 68 75 public String getValue (ParamBean jParams, ContentObjectEntryState entryState) 76 throws JahiaException { 77 return getDBValue (entryState); 79 } 80 81 85 public void setInteger (int value, EntrySaveRequest saveRequest) throws JahiaException { 86 preSet (String.valueOf (value), saveRequest); 87 } 88 89 97 public String getValueForSearch (ParamBean jParams, ContentObjectEntryState entryState) 98 throws JahiaException { 99 return getDBValue (entryState); 101 } 102 103 119 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 120 ContentObjectEntryState toEntryState, 121 ParamBean jParams, 122 StateModificationContext stateModifContext) 123 throws JahiaException { 124 return new ActivationTestResults (); 125 } 126 127 protected ActivationTestResults isContentValidForActivation ( 128 Set languageCodes, 129 ParamBean jParams, 130 StateModificationContext stateModifContext) throws JahiaException { 131 132 return new ActivationTestResults (); 133 } 134 135 138 public boolean isShared () { 139 return true; 140 } 141 142 163 protected void serializeContentToXML (XmlWriter xmlWriter, 164 XMLSerializationOptions xmlSerializationOptions, 165 ContentObjectEntryState entryState, 166 ParamBean paramBean) throws java.io.IOException { 167 try { 168 String result = getDBValue (entryState); 170 xmlWriter.writeText (result); 171 } catch (JahiaException je) { 172 logger.debug ("Error while serializing small text field to XML : ", je); 173 } 174 } 175 176 } 177 | Popular Tags |