KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > data > containers > ContainerSorterByContainerDefinition


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
//
14
//
15
//
16
//
17
// 29.05.2002 NK added in Jahia
18

19
20 package org.jahia.data.containers;
21
22 import java.io.Serializable JavaDoc;
23 import java.sql.Connection JavaDoc;
24 import java.sql.ResultSet JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import java.sql.Statement JavaDoc;
27 import java.text.Collator JavaDoc;
28 import java.util.ArrayList JavaDoc;
29 import java.util.BitSet JavaDoc;
30 import java.util.Collections JavaDoc;
31 import java.util.Comparator JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.Locale JavaDoc;
35 import java.util.Vector JavaDoc;
36
37 import org.jahia.bin.Jahia;
38 import org.jahia.data.fields.ExpressionMarker;
39 import org.jahia.exceptions.JahiaException;
40 import org.jahia.resourcebundle.ResourceBundleMarker;
41 import org.jahia.services.fields.ContentField;
42 import org.jahia.services.version.EntryLoadRequest;
43 import org.jahia.utils.JahiaConsole;
44 import org.jahia.utils.JahiaTools;
45
46 /**
47  * Jahia Standard Containers Sort Handler for a containers on containers
48  * of same container definition or having same field name.
49  *
50  * @see ContainerSorterByContainerDefinition
51  * @see JahiaContainerSet
52  * @author Khue Nguyen <a HREF="mailto:khue@jahia.org">khue@jahia.org</a>
53  */

54
55 public class ContainerSorterByContainerDefinition implements Serializable JavaDoc, ContainerSorterInterface {
56
57     private static org.apache.log4j.Logger logger =
58         org.apache.log4j.Logger.getLogger(ContainerSorterByContainerDefinition.class);
59
60     protected int listId = -1;
61
62     protected int siteId = -1;
63
64     protected String JavaDoc fieldName;
65
66     protected String JavaDoc containerDefinitionName;
67
68     protected boolean updated = false;
69
70     protected long lastSortingTime = -1;
71
72     protected boolean numberSort = false;
73     
74     protected String JavaDoc numberFormat = NumberFormats.LONG_FORMAT;
75     
76     protected boolean isValid = false;
77
78     protected boolean ASC_Ordering = true; // by default ASCENDANT ORDER.
79

80     //** sorted ctnids **/
81
protected Vector JavaDoc result;
82
83     protected EntryLoadRequest entryLoadRequest = EntryLoadRequest.CURRENT;
84
85     public int getCtnListID(){
86         return this.listId;
87     }
88
89     public void setCtnListID(int id){
90         this.listId = id;
91     }
92
93     //--------------------------------------------------------------------------
94
/**
95      * Constructor
96      *
97      * @param siteId
98      * @param fieldName
99      * @param containerDefinitionName
100      * @throws JahiaException
101      * @deprecated, inverted numbersort and entryLoadRequest parameter
102      *
103      */

104     public ContainerSorterByContainerDefinition(int siteId, String JavaDoc fieldName,
105             String JavaDoc containerDefinitionName, EntryLoadRequest entryLoadRequest,
106             boolean numberSort)
107     throws JahiaException
108     {
109         this(siteId,fieldName,containerDefinitionName,numberSort,entryLoadRequest);
110     }
111
112     //--------------------------------------------------------------------------
113
/**
114      *
115      * @param siteId
116      * @param fieldName
117      * @param containerDefinitionName
118      * @param numberSort
119      * @param entryLoadRequest
120      * @throws JahiaException
121      */

122     public ContainerSorterByContainerDefinition(int siteId, String JavaDoc fieldName,
123             String JavaDoc containerDefinitionName, boolean numberSort,
124             EntryLoadRequest entryLoadRequest)
125     throws JahiaException
126     {
127         this(siteId,fieldName,containerDefinitionName,numberSort,null,entryLoadRequest);
128     }
129
130     /**
131      *
132      * @param siteId
133      * @param fieldName
134      * @param containerDefinitionName
135      * @param boolean , force field values to be converted to number representation before sorting ( if true ).
136      * @param numberFormat, only used if numberSort is true. If null, the format used is NumberFormat.LONG_FORMAT
137      * @param entryLoadRequest
138      * @throws JahiaException
139      */

140     public ContainerSorterByContainerDefinition(int siteId, String JavaDoc fieldName,
141             String JavaDoc containerDefinitionName,
142             boolean numberSort,
143             String JavaDoc numberFormat,
144             EntryLoadRequest entryLoadRequest )
145     throws JahiaException
146     {
147         if ( fieldName != null && !fieldName.trim().equals("") )
148         {
149             this.siteId = siteId;
150             this.fieldName = fieldName;
151             this.containerDefinitionName = containerDefinitionName;
152             this.isValid = true;
153             this.numberSort = numberSort;
154             if ( NumberFormats.isValidFormat(numberFormat) ){
155                 this.numberFormat = numberFormat;
156             }
157         }
158         if (entryLoadRequest != null){
159             this.entryLoadRequest = entryLoadRequest;
160         }
161     }
162     
163     //--------------------------------------------------------------------------
164
/**
165      * Do the sort. Optionally, you can provide a BitSet where each bit set correspond the a container id you want in the result.
166      * If you want all containers in the result, give a null BitSet.
167      *
168      * @param BitSet bits
169      */

170     public Vector JavaDoc doSort(BitSet JavaDoc bits)
171     {
172         this.result = null;
173
174         try {
175             Vector JavaDoc ctnIds = null;
176
177             if ( this.isValid ){
178                 // get all container ids
179
if ( this.numberSort )
180                 {
181                     this.result = doNumberSort(bits);
182                 } else {
183                     this.result = doStringSort(bits);
184                 }
185             }
186         } catch ( Throwable JavaDoc t ){
187             JahiaConsole.println("ContainerSorterByContainerDefinition.doSort",
188                                     "Exception occured :" + t.getMessage());
189             t.printStackTrace();
190         }
191
192         // Set search time
193
this.lastSortingTime = System.currentTimeMillis();
194
195         return this.result;
196     }
197
198
199     //--------------------------------------------------------------------------
200
/**
201      * Return the vector of sorted ctnids.
202      *
203      */

204     public Vector JavaDoc result()
205     {
206         return this.result;
207     }
208
209     //--------------------------------------------------------------------------
210
/**
211      * Return the order , true - > ASC, false -> DESC.
212      *
213      */

214     public boolean isAscOrdering()
215     {
216         return this.ASC_Ordering;
217     }
218
219     //--------------------------------------------------------------------------
220
/**
221      * Return true, if the values are converted to number before sorting.
222      *
223      */

224     public boolean isNumberOrdering()
225     {
226         return this.numberSort;
227     }
228
229     //--------------------------------------------------------------------------
230
/**
231      * Force or not value to be converted to number before doing the sort.
232      *
233      */

234     public boolean setNumberOrdering(boolean val)
235     {
236         return this.numberSort = val;
237     }
238
239     //--------------------------------------------------------------------------
240
/**
241      * Set DESC ordering.
242      *
243      */

244     public void setDescOrdering()
245     {
246         this.ASC_Ordering = false;
247     }
248
249     //--------------------------------------------------------------------------
250
/**
251      * Set ASC ordering.
252      *
253      */

254     public boolean setAscOrdering()
255     {
256         return this.ASC_Ordering = true;
257     }
258
259     //--------------------------------------------------------------------------
260
/**
261      * Set ASC ordering.
262      *
263      */

264     public boolean setAscOrdering(boolean val)
265     {
266         return this.ASC_Ordering = val;
267     }
268
269     //--------------------------------------------------------------------------
270
/**
271      * Return the site id.
272      *
273      * @return
274      */

275     public int getSiteId()
276     {
277         return this.siteId;
278     }
279
280     //--------------------------------------------------------------------------
281
/**
282      * Return the sorting field.
283      *
284      * @return int ctnListID, the container list id.
285      */

286     public String JavaDoc getSortingFieldName()
287     {
288         return this.fieldName;
289     }
290
291     //--------------------------------------------------------------------------
292
/**
293      * Return the last sorting time.
294      *
295      * @return long , the last sorting time
296      */

297     public long getLastSortingTime()
298     {
299         return this.lastSortingTime;
300     }
301
302     //--------------------------------------------------------------------------
303
/**
304      * Return true if the sorter initialited properly
305      *
306      * @return boolean, the valid state value.
307      */

308     public boolean isValid()
309     {
310         return this.isValid;
311     }
312
313     //--------------------------------------------------------------------------
314
/**
315      * Return the update status. Each time the doSort method is called, this update status is set to true.
316      *
317      * @return boolean, the internal updated status value.
318      */

319     public boolean getUpdateStatus()
320     {
321         return this.updated;
322     }
323
324     //--------------------------------------------------------------------------
325
/**
326      * Set the update status to true.
327      *
328      */

329     public void setUpdateStatus()
330     {
331         this.updated = true;
332     }
333
334     //--------------------------------------------------------------------------
335
public EntryLoadRequest getEntryLoadRequest(){
336         return this.entryLoadRequest;
337     }
338
339     //--------------------------------------------------------------------------
340
/**
341      * You can reset the internal update status by setting it to false
342      *
343      */

344     public void resetUpdateStatus()
345     {
346         this.updated = false;
347     }
348
349     //--------------------------------------------------------------------------
350
/**
351      * Load an hashtable of pair/value (ctnID,fieldValue) .
352      *
353      *
354      * @param bits
355      * @return
356      * @throws JahiaException
357      */

358     protected Vector JavaDoc getFieldValues(BitSet JavaDoc bits)
359     throws JahiaException
360     {
361
362         ArrayList JavaDoc deletedCtns = ContainerFilterByContainerDefinition
363                               .getDeletedContainersBySite(siteId,
364                               containerDefinitionName);
365         ArrayList JavaDoc stagingFields = getStagingFields();
366
367         StringBuffer JavaDoc buff = new StringBuffer JavaDoc("SELECT DISTINCT ctnid_jahia_fields_data,b.id_jahia_fields_data,b.value_jahia_fields_data,b.workflow_state,b.language_code FROM jahia_ctn_entries a, jahia_fields_data b, jahia_fields_def c, jahia_ctn_def d WHERE ");
368
369         if ( siteId != -1 ){
370             buff.append(" jahiaid_jahia_ctn_entries=");
371             buff.append(siteId);
372             buff.append(" AND ");
373         }
374
375         if ( containerDefinitionName != null &&
376              !"".equals(containerDefinitionName.trim()) ){
377             buff.append(" ctndefid_jahia_ctn_entries = id_jahia_ctn_def ");
378             buff.append(" AND name_jahia_ctn_def='");
379             buff.append(JahiaTools.quote(containerDefinitionName));
380             buff.append("' AND ");
381         }
382
383         buff.append(" ( a.id_jahia_ctn_entries = b.ctnid_jahia_fields_data AND b.fielddefid_jahia_fields_data = c.id_jahia_fields_def AND c.name_jahia_fields_def='");
384         buff.append(JahiaTools.quote(fieldName));
385         buff.append("' ) AND (");
386         buff.append(ContainerFilterBean.buildMultilangAndWorlflowQuery(this.entryLoadRequest,true));
387         buff.append(") ORDER BY ");
388         buff.append(ContainerFilterBean.FIELD_ID);
389         buff.append(",");
390         buff.append(ContainerFilterBean.FIELD_WORKFLOW_STATE);
391
392         String JavaDoc query = buff.toString();
393         Connection JavaDoc dbConn = null;
394         Statement JavaDoc stmt = null;
395         ResultSet JavaDoc rs = null;
396
397         Locale JavaDoc locale = this.getEntryLoadRequest().getFirstLocale(true);
398         if ( locale == null ){
399             locale = Locale.ENGLISH;
400         }
401         Collator JavaDoc collator = this.getCollator();
402
403         Vector JavaDoc datas = new Vector JavaDoc();
404         HashMap JavaDoc maps = new HashMap JavaDoc();
405         try
406         {
407             dbConn = org.jahia.services.database.ConnectionDispenser.getConnection();
408             stmt = dbConn.createStatement();
409             rs = stmt.executeQuery( query );
410             while (rs.next())
411             {
412                 int ctnID = rs.getInt(1);
413                 int fieldID = rs.getInt(2);
414                 String JavaDoc fieldValue = rs.getString(3);
415                 int workflowState = rs.getInt(4);
416                 String JavaDoc languageCode = rs.getString(5);
417
418                 if ( bits == null || bits.get(ctnID) ){
419                     if ( this.entryLoadRequest.isCurrent()
420                          || !deletedCtns.contains(new Integer JavaDoc(ctnID))){
421                         if ( workflowState > EntryLoadRequest.ACTIVE_WORKFLOW_STATE ){
422                             workflowState = EntryLoadRequest.STAGING_WORKFLOW_STATE;
423                         }
424
425                         if (Jahia.getThreadParamBean() != null) {
426                             // expression marker
427
ExpressionMarker exprMarker = ExpressionMarker.parseMarkerValue(fieldValue, Jahia.getThreadParamBean());
428                             if ( exprMarker != null ){
429                                 try {
430                                     String JavaDoc value = exprMarker.getValue();
431                                     if ( value != null && !"".equals(value) ){
432                                         fieldValue = value;
433                                     }
434                                 }
435                                 catch (Throwable JavaDoc t) {
436                                     logger.debug("Problem while evaluating expression " + exprMarker.getExpr(), t);
437                                 }
438                             }
439                         }
440
441                         // resbundle marker
442
ResourceBundleMarker resMarker = ResourceBundleMarker.parseMarkerValue(fieldValue);
443                         if ( resMarker != null ){
444                             try {
445                                 String JavaDoc value = resMarker.getValue(locale);
446                                 if ( value != null && !"".equals(value) ){
447                                     fieldValue = value;
448                                 }
449                             }
450                             catch (Throwable JavaDoc t) {
451                             }
452                         }
453
454
455                         TempField aField = new TempField(fieldID,ctnID,0,workflowState,languageCode,fieldValue);
456                         String JavaDoc key = fieldID + "_" + workflowState + "_" + languageCode;
457                         maps.put(key,aField);
458                     }
459                 }
460             }
461         }
462         catch (SQLException JavaDoc se)
463         {
464             String JavaDoc errorMsg = "Error in getFieldValues : " + se.getMessage();
465             JahiaConsole.println ("ContainerSorterByContainerDefinition.getFieldValues", errorMsg);
466         } finally {
467
468             closeStatement (stmt);
469         }
470
471         Vector JavaDoc addedIds = new Vector JavaDoc();
472         int size = maps.size();
473         Iterator JavaDoc iterator = maps.values().iterator();
474         while ( iterator.hasNext() ){
475             TempField aField = (TempField)iterator.next();
476             if ( !addedIds.contains(new Integer JavaDoc(aField.id)) ){
477                 String JavaDoc key = aField.id + "_" + aField.workflowState + "_" +
478                     locale.toString();
479                 if (!aField.languageCode.equals(ContentField.SHARED_LANGUAGE)
480                     && maps.containsKey(key) &&
481                     !aField.languageCode.equals(locale.toString())) {
482                     continue;
483                 }
484                 else if (!aField.languageCode.equals(ContentField.SHARED_LANGUAGE)
485                          && !maps.containsKey(key)) {
486                     // this field doesn't exist in the given language, so sort it as "" value
487
aField.value = "";
488                 }
489                 Object JavaDoc obj = null;
490                 if (this.numberSort) {
491                     try {
492                         obj = new DataBean(aField.ctnID,
493                                            aField.value);
494                     }
495                     catch (Throwable JavaDoc t) {
496                         // we want to display the ctn anyway
497
obj = new DataBean(aField.ctnID, null);
498                     }
499                 }
500                 else {
501                     obj = new StrDataBean(aField.ctnID, aField.value, collator);
502                 }
503                 if (this.entryLoadRequest.isCurrent()) {
504                     datas.add(obj);
505                     addedIds.add(new Integer JavaDoc(aField.id));
506                 }
507                 else if (this.entryLoadRequest.isStaging()
508                          &&
509                          aField.workflowState >
510                          EntryLoadRequest.ACTIVE_WORKFLOW_STATE) {
511                     datas.add(obj);
512                     addedIds.add(new Integer JavaDoc(aField.id));
513                 }
514                 else if (aField.workflowState ==
515                          EntryLoadRequest.ACTIVE_WORKFLOW_STATE
516                          && !stagingFields.contains(new Integer JavaDoc(aField.id))) {
517                     datas.add(obj);
518                     addedIds.add(new Integer JavaDoc(aField.id));
519                 }
520             }
521         }
522
523         return datas;
524     }
525
526     //--------------------------------------------------------------------------
527
/**
528      * Containers are sorted after sorting field's data are loaded and converted to
529      * a long representation.
530      *
531      * @param BitSet bits, any bit position sset to true must correspond to a ctn id to include in the result.
532      * if you want all ctn ids in the result, gieve a null BitSet.
533      * @return Vector, vector of sorted ctn ids.
534      */

535     protected Vector JavaDoc doStringSort(BitSet JavaDoc bits) throws JahiaException
536     {
537         Vector JavaDoc results = new Vector JavaDoc();
538
539         Vector JavaDoc datas = this.getFieldValues(bits);
540
541         Collator JavaDoc collator = this.getCollator();
542
543         // sort the datas
544
if ( datas.size()>1 ){
545             // a dummy dataBean
546
StrDataBean dummyDataBean = new StrDataBean(ASC_Ordering, collator);
547             Collections.sort(datas,dummyDataBean);
548         }
549         // retrieve sorted ids
550
int size = datas.size();
551         StrDataBean dataBean = null;
552         for ( int i=0; i<size ; i++ ){
553             dataBean = (StrDataBean)datas.get(i);
554             results.add(new Integer JavaDoc(dataBean.ctnID));
555         }
556         return results;
557     }
558
559     //--------------------------------------------------------------------------
560
/**
561      * Containers are sorted after sorting field's data are loaded and converted to
562      * a long representation.
563      *
564      * @param BitSet bits, any bit position sset to true must correspond to a ctn id to include in the result.
565      * if you want all ctn ids in the result, gieve a null BitSet.
566      * @return Vector, vector of sorted ctn ids.
567      */

568     protected Vector JavaDoc doNumberSort(BitSet JavaDoc bits) throws JahiaException
569     {
570         Vector JavaDoc results = new Vector JavaDoc();
571
572         Vector JavaDoc datas = this.getFieldValues(bits);
573         // sort the datas
574
if ( datas.size()>1 ){
575             // a dummy dataBean
576
DataBean dummyDataBean = new DataBean(ASC_Ordering);
577             Collections.sort(datas,dummyDataBean);
578         }
579         // retrieve sorted ids
580
int size = datas.size();
581         DataBean dataBean = null;
582         for ( int i=0; i<size ; i++ ){
583             dataBean = (DataBean)datas.get(i);
584             results.add(new Integer JavaDoc(dataBean.ctnID));
585         }
586         return results;
587     }
588
589     //-------------------------------------------------------------------------
590
protected void closeStatement (Statement JavaDoc statement)
591     {
592         // Close the opened statement
593
try {
594             if (statement!=null) {
595                 statement.close();
596             }
597         }
598         catch (SQLException JavaDoc sqlEx) {
599             // just create an exception without raising it, just to notify it
600
// in the logs.
601
JahiaException je = new JahiaException ("Cannot close a statement",
602                     "Cannot close a statement", JahiaException.DATABASE_ERROR,
603                     JahiaException.WARNING_SEVERITY, sqlEx);
604             logger.error("Error:", je);
605         }
606     }
607
608
609     protected class DataBean implements Comparator JavaDoc
610     {
611         int ctnID = 0;
612         String JavaDoc value = null;
613         boolean ASC_Ordering = true;
614
615         public DataBean (int ctnID, String JavaDoc value)
616         {
617             this.ctnID = ctnID;
618             this.value = value;
619         }
620
621         public DataBean (boolean ASC_Ordering)
622         {
623             this.ASC_Ordering = ASC_Ordering;
624         }
625
626         public int compare(Object JavaDoc obj1, Object JavaDoc obj2) throws ClassCastException JavaDoc {
627
628             DataBean dataBean1 = (DataBean)obj1;
629             DataBean dataBean2 = (DataBean)obj2;
630             if ( ASC_Ordering ){
631                 return NumberFormats.compareNumber(dataBean1.value,dataBean2.value, numberFormat);
632             } else {
633                 return NumberFormats.compareNumber(dataBean2.value,dataBean1.value, numberFormat);
634             }
635         }
636     }
637
638     protected class StrDataBean implements Comparator JavaDoc
639     {
640         int ctnID = 0;
641         String JavaDoc value = "";
642         boolean ASC_Ordering = true;
643         Collator JavaDoc collator = null;
644
645         public StrDataBean (int ctnID, String JavaDoc value, Collator JavaDoc collator)
646         {
647             this.ctnID = ctnID;
648             this.value = value;
649             this.collator = collator;
650
651             if ( this.collator == null ){
652                 this.collator = Collator.getInstance();
653             }
654         }
655
656         public StrDataBean (boolean ASC_Ordering, Collator JavaDoc collator)
657         {
658             this.ASC_Ordering = ASC_Ordering;
659             this.collator = collator;
660             if ( this.collator == null ){
661                 this.collator = Collator.getInstance();
662             }
663         }
664
665         public int compare(Object JavaDoc obj1, Object JavaDoc obj2) throws ClassCastException JavaDoc {
666
667             //SCSE: temporary fix - should be fixed by Jahia team as JAHIA-380
668
// http://www.jahia.org/jira/browse/JAHIA-380
669
StrDataBean dataBean1 = (StrDataBean)obj1;
670             StrDataBean dataBean2 = (StrDataBean)obj2;
671             if ( this.ASC_Ordering ){
672                 return collator.compare(dataBean1.value,dataBean2.value);
673             } else {
674                 return collator.compare(dataBean2.value,dataBean1.value);
675             }
676         }
677     }
678
679     protected class TempField{
680         public int id;
681         public int ctnID;
682         public int versionID;
683         public int workflowState;
684         public String JavaDoc languageCode;
685         public String JavaDoc value;
686
687         public TempField(int id, int ctnID, int versionID, int workflowState,
688                          String JavaDoc languageCode, String JavaDoc value){
689             this.id = id;
690             this.ctnID = ctnID;
691             this.versionID = versionID;
692             this.workflowState = workflowState;
693             this.languageCode = languageCode;
694             this.value = value;
695         }
696     }
697
698     //--------------------------------------------------------------------------
699
/**
700      * Returns an array of fields that are in staging.
701      *
702      * @return
703      * @throws JahiaException
704      */

705     protected ArrayList JavaDoc getStagingFields()
706     throws JahiaException
707     {
708
709         StringBuffer JavaDoc buff = new StringBuffer JavaDoc("SELECT DISTINCT id_jahia_fields_data FROM jahia_ctn_entries a, jahia_fields_data b, jahia_ctn_def c WHERE ");
710
711         if ( siteId != -1 ){
712             buff.append(" jahiaid_jahia_ctn_entries=");
713             buff.append(siteId);
714             buff.append(" AND ");
715         }
716
717         if ( containerDefinitionName != null &&
718              !"".equals(containerDefinitionName.trim()) ){
719             buff.append(" ctndefid_jahia_ctn_entries = id_jahia_ctn_def ");
720             buff.append(" AND name_jahia_ctn_def='");
721             buff.append(JahiaTools.quote(containerDefinitionName));
722             buff.append("' AND");
723         }
724
725         buff.append(" a.id_jahia_ctn_entries=b.ctnid_jahia_fields_data AND b.workflow_state>1 ");
726
727         Connection JavaDoc dbConn = null;
728         Statement JavaDoc stmt = null;
729         ResultSet JavaDoc rs = null;
730
731         ArrayList JavaDoc datas = new ArrayList JavaDoc();
732
733         try
734         {
735             dbConn = org.jahia.services.database.ConnectionDispenser.getConnection();
736             stmt = dbConn.createStatement();
737             rs = stmt.executeQuery( buff.toString() );
738
739             while (rs.next()) {
740                 datas.add(new Integer JavaDoc(rs.getInt(1)));
741             }
742         }
743         catch (SQLException JavaDoc se)
744         {
745             String JavaDoc errorMsg = "Error in getStagingFields() : " + se.getMessage();
746             JahiaConsole.println ("ContainerSorterByContainerDefinition.getStagingFields()", errorMsg);
747         } finally {
748
749             closeStatement (stmt);
750         }
751         return datas;
752     }
753
754     /**
755      * Return the collator instantiated with the first locale from the internal EntryLoadRequest.
756      * If the entryLoadRequest is null, the localtor is instantiated with the default locale of the system
757      * @return
758      */

759     private Collator JavaDoc getCollator(){
760         Collator JavaDoc collator = Collator.getInstance();
761         if ( this.getEntryLoadRequest() != null ){
762             Locale JavaDoc locale = null;
763             locale = this.getEntryLoadRequest().getFirstLocale(true);
764             if ( locale != null ){
765                 collator = Collator.getInstance(locale);
766             }
767         }
768         return collator;
769     }
770
771 }
772
Popular Tags