KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > fields > ContentFloatField


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

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 JavaDoc;
26 import java.util.Hashtable JavaDoc;
27 import java.util.Set JavaDoc;
28 import java.util.Vector JavaDoc;
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     //--------------------------------------------------------------------------
35
protected ContentFloatField (Integer JavaDoc ID,
36                                  Integer JavaDoc jahiaID,
37                                  Integer JavaDoc pageID,
38                                  Integer JavaDoc ctnid,
39                                  Integer JavaDoc fieldDefID,
40                                  Integer JavaDoc fieldType,
41                                  Integer JavaDoc connectType,
42                                  Integer JavaDoc aclID,
43                                  Vector JavaDoc activeAndStagingEntryStates,
44                                  Hashtable JavaDoc 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     //--------------------------------------------------------------------------
52
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     //--------------------------------------------------------------------------
77
/**
78      * Gets the String representation of this field. In case of an Application,
79      * it will be the output of the application, in case of a bigtext it will
80      * be the full content of the bigtext, etc. This is called by the public
81      * method getValue of ContentField, which does the entryState resolving
82      * This method should call getDBValue to get the DBValue
83      */

84     public String JavaDoc getValue (ParamBean jParams,
85                                ContentObjectEntryState entryState)
86             throws JahiaException {
87         //return FormDataManager.getInstance().formDecode(getDBValue(entryState));
88
return getDBValue (entryState);
89     }
90
91     //--------------------------------------------------------------------------
92
/**
93      * Sets the String representation of this field.
94      * This method should call preSet and postSet.
95      */

96     public void setFloat (float value,
97                           EntrySaveRequest saveRequest)
98             throws JahiaException {
99         preSet (String.valueOf (value), saveRequest);
100     }
101
102     //--------------------------------------------------------------------------
103
/**
104      * get the Value that will be added to the search engine for this field.
105      * for a bigtext it will be the content of the bigtext, for an application
106      * the string will be empty!
107      * Do not return null, return an empty string instead.
108      *
109      * @param jParams the jParam containing the loadVersion and locales
110      */

111     public String JavaDoc getValueForSearch (ParamBean jParams,
112                                      ContentObjectEntryState entryState)
113             throws JahiaException {
114         return getDBValue (entryState);
115     }
116
117     //--------------------------------------------------------------------------
118
/**
119      * This method is called when there is a workflow state change
120      * Such as staged mode -> active mode (validation), active -> inactive (for versioning)
121      * and also staged mode -> other staged mode (workflow)
122      * This method should not write/change the DBValue, the service handles that.
123      *
124      * @param fromEntryState the entry state that is currently was in the database
125      * @param toEntryState the entry state that will be written to the database
126      * @param jParams ParamBean object used to get information about the user
127      * doing the request, the current locale, etc...
128      *
129      * @return null if the entry state change wasn't an activation, otherwise it
130      * returns an object that contains the status of the activation (whether
131      * successfull, partial or failed, as well as messages describing the
132      * warnings during the activation process)
133      */

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     //--------------------------------------------------------------------------
143
protected ActivationTestResults isContentValidForActivation (
144             Set JavaDoc languageCodes,
145             ParamBean jParams,
146             StateModificationContext stateModifContext)
147             throws JahiaException {
148         /** @todo to be implemented */
149         return new ActivationTestResults ();
150     }
151
152     //--------------------------------------------------------------------------
153
/**
154      * Is this kind of field shared (i.e. not one version for each language,
155      * but one version for every language)
156      */

157     public boolean isShared () {
158         return true;
159     }
160
161     /**
162      * This is called on all content fields to have them serialized only their
163      * specific part. The actual field metadata seriliazing is handled by the
164      * ContentField class. This method is called multiple times per field
165      * according to the workflow state, languages and versioning entries we
166      * want to serialize.
167      *
168      * @param xmlWriter the XML writer object in which to write the XML output
169      * @param xmlSerializationOptions options used to activate/bypass certain
170      * output of elements.
171      * @param entryState the ContentFieldEntryState for which to generate the
172      * XML export.
173      * @param paramBean specifies context of serialization, such as current
174      * user, current request parameters, entry load request, URL generation
175      * information such as ServerName, ServerPort, ContextPath, etc... URL
176      * generation is an important part of XML serialization and this is why
177      * we pass this parameter down, as well as user rights checking.
178      *
179      * @throws IOException in case there was an error writing to the Writer
180      * output object.
181      */

182     protected void serializeContentToXML (XmlWriter xmlWriter,
183                                           XMLSerializationOptions xmlSerializationOptions,
184                                           ContentObjectEntryState entryState,
185                                           ParamBean paramBean) throws IOException JavaDoc {
186         try {
187             //String result = FormDataManager.getInstance().formDecode(getDBValue(entryState));
188
String JavaDoc 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