KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > repository > DjProperty


1 /*
2  * Copyright (c) 2001-2005 by Genimen BV (www.genimen.com) All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, is permitted provided that the following conditions are met: -
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer. - Redistributions in binary
8  * form must reproduce the above copyright notice, this list of conditions and
9  * the following disclaimer in the documentation and/or other materials
10  * provided with the distribution. - All advertising materials mentioning
11  * features or use of this software must display the following acknowledgment:
12  * "This product includes Djeneric." - Products derived from this software may
13  * not be called "Djeneric" nor may "Djeneric" appear in their names without
14  * prior written permission of Genimen BV. - Redistributions of any form
15  * whatsoever must retain the following acknowledgment: "This product includes
16  * Djeneric."
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL GENIMEN BV, DJENERIC.ORG, OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */

30 package com.genimen.djeneric.repository;
31
32 import java.util.ArrayList JavaDoc;
33 import java.util.Comparator JavaDoc;
34
35 import com.genimen.djeneric.language.Messages;
36 import com.genimen.djeneric.repository.exceptions.CatalogException;
37 import com.genimen.djeneric.repository.exceptions.DjenericException;
38 import com.genimen.djeneric.repository.exceptions.DomainViolationException;
39 import com.genimen.djeneric.repository.exceptions.ObjectNotDefinedException;
40 import com.genimen.djeneric.util.DjLogger;
41
42 /**
43  * Description of the Class
44  *
45  * @author Wido Riezebos @created 26 juni 2002
46  */

47 public class DjProperty implements Cloneable JavaDoc
48 {
49   String JavaDoc _name;
50   String JavaDoc _prompt;
51   String JavaDoc _mapping;
52   String JavaDoc _alias;
53   String JavaDoc _defaultValue;
54   String JavaDoc _description;
55   DjPropertyType _type;
56   boolean _required;
57   boolean _partOfUID;
58   boolean _query = true;
59   DjExtent _extent;
60   int _seq;
61   int _sortOrder = 0;
62   ArrayList JavaDoc _propertyRestrictions = null;
63
64   boolean _mapped2longCache = false;
65   boolean _mapped2longCacheIsDetermined = false;
66   boolean _mapped2relationCache = false;
67   boolean _mapped2relationCacheIsDetermined = false;
68
69   boolean _partOfRestrictedPath = false;
70
71   long _internalId;
72
73   /**
74    * Constructor for the DjProperty object
75    *
76    * @param name
77    * Description of the Parameter
78    * @param mapping
79    * Description of the Parameter
80    * @param alias
81    * Description of the Parameter
82    * @param prompt
83    * Description of the Parameter
84    * @param type
85    * Description of the Parameter
86    * @param required
87    * Description of the Parameter
88    * @param seq
89    * Description of the Parameter
90    * @param defaultValue
91    * Description of the Parameter
92    * @param description
93    * Description of the Parameter
94    * @exception DjenericException
95    * Description of the Exception
96    */

97   public DjProperty(String JavaDoc name, String JavaDoc mapping, String JavaDoc alias, String JavaDoc prompt, DjPropertyType type, boolean required,
98                     int seq, String JavaDoc defaultValue, String JavaDoc description) throws DjenericException
99   {
100     _internalId = DjPersistenceManager.getNextInternalId();
101     _extent = null;
102     setName(name);
103     setAlias(alias);
104     setPrompt(prompt);
105     setMapping(mapping);
106     setType(type);
107     setRequired(required);
108     setSeq(seq);
109     setDescription(description);
110     setDefaultValue(defaultValue);
111   }
112
113   /**
114    * Returns the propertyRestrictionCount of the DjProperty object
115    *
116    * @return The propertyRestrictionCount value
117    */

118   public int getPropertyRestrictionCount()
119   {
120     if (_propertyRestrictions == null) return 0;
121     else return _propertyRestrictions.size();
122   }
123
124   public boolean isRestricted()
125   {
126     return (_propertyRestrictions != null && _propertyRestrictions.size() > 0);
127   }
128
129   /**
130    * Returns the propertyRestriction of the DjProperty object
131    *
132    * @param idx
133    * Description of the Parameter
134    * @return The propertyRestriction value
135    */

136   public DjPropertyRestriction getPropertyRestriction(int idx)
137   {
138     return (DjPropertyRestriction) _propertyRestrictions.get(idx);
139   }
140
141   /**
142    * Adds a feature to the PropertyRestriction attribute of the DjProperty
143    * object
144    *
145    * @param pr
146    * The feature to be added to the PropertyRestriction attribute
147    */

148   public void addPropertyRestriction(DjPropertyRestriction pr)
149   {
150     if (_propertyRestrictions == null) _propertyRestrictions = new ArrayList JavaDoc();
151     _propertyRestrictions.add(pr);
152   }
153
154   /**
155    * Description of the Method
156    *
157    * @param pr
158    * Description of the Parameter
159    */

160   public void removePropertyRestriction(DjPropertyRestriction pr)
161   {
162     if (_propertyRestrictions == null) return;
163     _propertyRestrictions.remove(pr);
164   }
165
166   /**
167    * Description of the Method
168    *
169    * @param pr
170    * Description of the Parameter
171    */

172   public void removePropertyRestriction(DjRestriction pr)
173   {
174     if (_propertyRestrictions == null) return;
175     for (int i = 0; i < getPropertyRestrictionCount(); i++)
176     {
177       if (getPropertyRestriction(i).getRestriction().equals(pr)) removePropertyRestriction(getPropertyRestriction(i));
178     }
179   }
180
181   /**
182    * Returns the extent of the DjProperty object
183    *
184    * @return The extent value
185    */

186   public DjExtent getExtent()
187   {
188     return _extent;
189   }
190
191   /**
192    * Description of the Method
193    *
194    * @return Description of the Return Value
195    */

196   public Object JavaDoc clone()
197   {
198     try
199     {
200       DjProperty nc = new DjProperty(_name, _mapping, _alias, _prompt, _type, _required, _seq, _defaultValue,
201           _description);
202       nc.setSortOrder(getSortOrder());
203       nc.setPartOfUID(isPartOfUID());
204       nc.setQueryable(isQueryable());
205
206       nc._internalId = _internalId;
207       return nc;
208     }
209     catch (Exception JavaDoc x)
210     {
211       DjLogger.log(x);
212     }
213     return null;
214   }
215
216   /**
217    * Returns the internalId of the DjProperty object
218    *
219    * @return The internalId value
220    */

221   public long getInternalId()
222   {
223     return _internalId;
224   }
225
226   /**
227    * Returns the seq of the DjProperty object
228    *
229    * @return The seq value
230    */

231   public int getSeq()
232   {
233     return _seq;
234   }
235
236   /**
237    * Sets the seq of the DjProperty object
238    *
239    * @param seq
240    * The new seq value
241    */

242   public void setSeq(int seq)
243   {
244     _seq = seq;
245   }
246
247   /**
248    * Returns the sortOrder of the DjProperty object
249    *
250    * @return The sortOrder value
251    */

252   public int getSortOrder()
253   {
254     return _sortOrder;
255   }
256
257   /**
258    * Sets the sortOrder of the DjProperty object
259    *
260    * @param s
261    * The new sortOrder value
262    */

263   public void setSortOrder(int s)
264   {
265     _sortOrder = s;
266   }
267
268   /**
269    * Returns the name of the DjProperty object
270    *
271    * @return The name value
272    */

273   public String JavaDoc getName()
274   {
275     return _name;
276   }
277
278   /**
279    * Returns the prompt of the DjProperty object
280    *
281    * @return The prompt value
282    */

283   public String JavaDoc getPrompt()
284   {
285     if (_prompt == null) return getName();
286     return _prompt;
287   }
288
289   /**
290    * Sets the prompt of the DjProperty object
291    *
292    * @param prompt
293    * The new prompt value
294    */

295   public void setPrompt(String JavaDoc prompt)
296   {
297     if (prompt != null)
298     {
299       if (prompt.trim().length() == 0) prompt = null;
300       else if (prompt.equals(_name)) prompt = null;
301     }
302     _prompt = prompt;
303   }
304
305   /**
306    * Returns the alias of the DjProperty object
307    *
308    * @return The alias value
309    */

310   public String JavaDoc getAlias()
311   {
312     if (_alias == null) return getName();
313     return _alias;
314   }
315
316   /**
317    * Returns the defaultValue of the DjProperty object
318    *
319    * @return The defaultValue value
320    */

321   public String JavaDoc getDefaultValue()
322   {
323     return _defaultValue;
324   }
325
326   /**
327    * Sets the defaultValue of the DjProperty object
328    *
329    * @param value
330    * The new defaultValue value
331    */

332   public void setDefaultValue(String JavaDoc value)
333   {
334     if (value != null && value.trim().length() == 0) value = null;
335
336     _defaultValue = value;
337   }
338
339   /**
340    * Sets the alias of the DjProperty object
341    *
342    * @param alias
343    * The new alias value
344    */

345   public void setAlias(String JavaDoc alias)
346   {
347     if (alias != null)
348     {
349       if (alias.trim().length() == 0) alias = null;
350       else if (alias.equals(_name)) alias = null;
351     }
352     _alias = alias;
353   }
354
355   /**
356    * Returns the length of the DjProperty object
357    *
358    * @return The length value
359    */

360   public int getLength()
361   {
362     if (_type.getLength() == 0)
363     {
364       if (_type.getTypeCode() == DjDomain.STRING_TYPE)
365       {
366         if (getMapping().startsWith(DjPersistenceManager.MAPPING_STR)) return DjPersistenceManager.MAPPING_STR_MAX;
367         if (getMapping().startsWith(DjPersistenceManager.MAPPING_TXT)) return DjPersistenceManager.MAPPING_TXT_MAX;
368         if (getMapping().startsWith(DjPersistenceManager.MAPPING_LNG)) return DjPersistenceManager.MAPPING_LNG_MAX;
369       }
370       if (_type.getTypeCode() == DjDomain.BIGDECIMAL_TYPE) return 15;
371       if (_type.getTypeCode() == DjDomain.INT_TYPE) return 10;
372       if (_type.getTypeCode() == DjDomain.DATE_TYPE) return 15;
373       if (_type.getTypeCode() == DjDomain.LONG_TYPE) return 15;
374     }
375     return _type.getLength();
376   }
377
378   /**
379    * Returns the decimals of the DjProperty object
380    *
381    * @return The decimals value
382    */

383   public int getDecimals()
384   {
385     return _type.getDecimals();
386   }
387
388   /**
389    * Returns the description of the DjProperty object
390    *
391    * @return The description value
392    */

393   public String JavaDoc getDescription()
394   {
395     return _description;
396   }
397
398   /**
399    * Sets the description of the DjProperty object
400    *
401    * @param descr
402    * The new description value
403    */

404   public void setDescription(String JavaDoc descr)
405   {
406     _description = descr;
407   }
408
409   /**
410    * Returns the mapping of the DjProperty object
411    *
412    * @return The mapping value
413    */

414   public String JavaDoc getMapping()
415   {
416     return _mapping;
417   }
418
419   /**
420    * Returns the type of the DjProperty object; defined by DjExtent or DjDomain
421    *
422    * @return The type value
423    */

424   public DjPropertyType getType()
425   {
426     return _type;
427   }
428
429   /**
430    * Returns the nativeType of the DjProperty object
431    *
432    * @return The nativeType value
433    */

434   public String JavaDoc getNativeType()
435   {
436     return _type.getNativeType();
437   }
438
439   public Class JavaDoc getNativeTypeClass()
440   {
441     return _type.getNativeTypeClass();
442   }
443
444   /**
445    * Returns the typeName of the DjProperty object
446    *
447    * @return The typeName value
448    */

449   public String JavaDoc getTypeName()
450   {
451     return _type.getTypeName();
452   }
453
454   /**
455    * Returns the typeCode of the DjProperty object
456    *
457    * @return The typeCode value
458    */

459   public int getTypeCode()
460   {
461     return _type.getTypeCode();
462   }
463
464   /**
465    * Sets the type of the DjProperty object
466    *
467    * @param type
468    * The new type value
469    */

470   public void setType(DjPropertyType type)
471   {
472     _type = type;
473   }
474
475   /**
476    * Sets the queryable of the DjProperty object
477    *
478    * @param b
479    * The new queryable value
480    */

481   public void setQueryable(boolean b)
482   {
483     _query = b;
484   }
485
486   /**
487    * Returns the queryable of the DjProperty object
488    *
489    * @return The queryable value
490    */

491   public boolean isQueryable()
492   {
493     return _query;
494   }
495
496   /**
497    * Returns the required of the DjProperty object
498    *
499    * @return The required value
500    */

501   public boolean isRequired()
502   {
503     return _required;
504   }
505
506   /**
507    * Returns true if the underlying type is an object. int and long values are
508    * not represented by objects.
509    *
510    * @return The internalTypeObjectBased value
511    */

512
513   public boolean isInternalTypeObjectBased()
514   {
515     return getTypeCode() == DjDomain.BIGDECIMAL_TYPE || getTypeCode() == DjDomain.BYTE_TYPE
516            || getTypeCode() == DjDomain.DATE_TYPE || getTypeCode() == DjDomain.STRING_TYPE
517            || getTypeCode() == DjDomain.DATE_TYPE;
518   }
519
520   /**
521    * Sets the mapping of the DjProperty object
522    *
523    * @param mapping
524    * The new mapping value
525    */

526   public void setMapping(String JavaDoc mapping)
527   {
528     _mapped2longCacheIsDetermined = false;
529     _mapping = mapping.toLowerCase();
530   }
531
532   /**
533    * Sets the name of the DjProperty object
534    *
535    * @param name
536    * The new name value
537    * @exception CatalogException
538    * Description of the Exception
539    */

540   public void setName(String JavaDoc name) throws CatalogException
541   {
542     if ((_name != null) && !_name.equalsIgnoreCase(name))
543     {
544       if (_extent != null && _extent.hasProperty(name)) throw new CatalogException(Messages
545           .getString("DjProperty.DuplicateProperty", name, _extent.getName()));
546     }
547     _name = name;
548     if (_extent != null) _extent.updateHashes();
549   }
550
551   /**
552    * Sets the required of the DjProperty object
553    *
554    * @param required
555    * The new required value
556    */

557   public void setRequired(boolean required)
558   {
559     _required = required;
560   }
561
562   /**
563    * Sets the extent of the DjProperty object
564    *
565    * @param tab
566    * The new extent value
567    */

568   protected void setExtent(DjExtent tab)
569   {
570     _extent = tab;
571   }
572
573   /**
574    * Description of the Method
575    *
576    * @return Description of the Return Value
577    */

578   public String JavaDoc toString()
579   {
580     return getName();
581   }
582
583   /**
584    * Returns the validValues of the DjProperty object
585    *
586    * @param session
587    * Description of the Parameter
588    * @return The validValues value
589    * @exception DjenericException
590    * Description of the Exception
591    */

592   public DjDomainValue[] getValidValues(DjSession session) throws DjenericException
593   {
594     if (getType() instanceof DjDomain)
595     {
596       DjDomain dom = (DjDomain) getType();
597       return dom.getValidValues();
598     }
599     else if (getType() instanceof DjExtent)
600     {
601       DjList masters = session.getObjects((DjExtent) getType());
602       return DjDomain.convertToValueList(masters);
603     }
604     return null;
605   }
606
607   public boolean isMappedToLong()
608   {
609     if (_mapped2longCacheIsDetermined) return _mapped2longCache;
610
611     _mapped2longCache = getMapping().startsWith(DjPersistenceManager.MAPPING_LNG);
612     _mapped2longCacheIsDetermined = true;
613     return _mapped2longCache;
614   }
615
616   public boolean isMappedToRelation()
617   {
618     if (_mapped2relationCacheIsDetermined) return _mapped2relationCache;
619
620     _mapped2relationCache = getMapping().startsWith(DjPersistenceManager.MAPPING_REL);
621     _mapped2relationCacheIsDetermined = true;
622     return _mapped2relationCache;
623   }
624
625   /**
626    * Description of the Method
627    *
628    * @param mgr
629    * Description of the Parameter
630    * @param strictChecking
631    * Description of the Parameter
632    * @exception CatalogException
633    * Description of the Exception
634    */

635   protected void validate(DjPersistenceManager mgr, boolean strictChecking) throws CatalogException
636   {
637     if (getName().trim().length() == 0) throw new CatalogException(Messages.getString("DjProperty.EmptyName", _extent
638         .getName()));
639     if (getType() == null) throw new CatalogException(Messages.getString("DjProperty.NoTypeSet", _extent.getName()
640                                                                                                  + "." + getName()));
641
642     if (!DjPersistenceManager.isValidName(getName()))
643     {
644       throw new CatalogException(Messages.getString("DjProperty.InvalidName", _extent.getName(), getName()));
645     }
646     if (!DjPersistenceManager.isValidName(getAlias()))
647     {
648       throw new CatalogException(Messages.getString("DjProperty.InvalidAlias", _extent.getName() + "." + getName(),
649                                                     getAlias()));
650     }
651
652     // Not referring to this? Then check the type with the manager's known list
653
if (!getType().getTypeName().equals(getExtent().getTypeName())) try
654     {
655       mgr.getType(getType().getTypeName());
656     }
657     catch (Exception JavaDoc x)
658     {
659       throw new CatalogException(Messages.getString("DjProperty.InvalidType", _extent.getName() + "." + getName(),
660                                                     getType().getTypeName()));
661     }
662
663     try
664     {
665       String JavaDoc map = getMapping().toLowerCase();
666       if (map.equalsIgnoreCase(DjPersistenceManager.MAPPING_OBJECT_ID))
667       {
668         setType(mgr.getDomain(DjPersistenceManager.INTERNAL_ID_COLUMN_TYPE));
669         setRequired(true);
670       }
671     }
672     catch (ObjectNotDefinedException ox)
673     {
674       throw new CatalogException(Messages.getString("global.IdNotMapped", getExtent().getName(),
675                                                     DjPersistenceManager.MAPPING_OBJECT_ID));
676     }
677
678     checkMapping(strictChecking);
679     if (strictChecking && getDefaultValue() != null)
680     {
681       if (getType() instanceof DjDomain)
682       {
683         DjDomain dom = (DjDomain) getType();
684         try
685         {
686           dom.validateValue(getDefaultValue());
687         }
688         catch (DomainViolationException dve)
689         {
690           throw new CatalogException(Messages.getString("DjProperty.InvalidDefault", _extent.getName() + "."
691                                                                                      + getName(), dve.getMessage()));
692         }
693       }
694       else
695       {
696         throw new CatalogException(Messages.getString("DjProperty.RelNoDefault", _extent.getName() + "." + getName()));
697       }
698
699     }
700   }
701
702   private void checkMapping(boolean strictChecking) throws CatalogException
703   {
704     String JavaDoc map = getMapping().toLowerCase();
705
706     if (!map.startsWith(DjPersistenceManager.MAPPING_OBJECT_ID) && !map.startsWith(DjPersistenceManager.MAPPING_STR)
707         && !map.startsWith(DjPersistenceManager.MAPPING_NUM) && !map.startsWith(DjPersistenceManager.MAPPING_TXT)
708         && !map.startsWith(DjPersistenceManager.MAPPING_DAT) && !map.startsWith(DjPersistenceManager.MAPPING_LNG)
709         && !map.startsWith(DjPersistenceManager.MAPPING_REL))
710     {
711       throw new CatalogException(Messages.getString("DjProperty.InvalidMapping", _extent.getName() + "." + getName(),
712                                                     map));
713     }
714
715     if (strictChecking)
716     {
717       // Check String specific stuff:
718

719       // LNG column must be mapped to byte[] or String
720
if (map.startsWith(DjPersistenceManager.MAPPING_LNG)
721           && ((getTypeCode() != DjDomain.BYTE_TYPE) && (getTypeCode() != DjDomain.STRING_TYPE)))
722       {
723         throw new CatalogException(Messages.getString("DjProperty.WrongLongMapping", _extent.getName() + "."
724                                                                                      + getName(), map));
725       }
726
727       // STR column must be mapped to String
728
if (map.startsWith(DjPersistenceManager.MAPPING_STR) && getTypeCode() != DjDomain.STRING_TYPE)
729       {
730         throw new CatalogException(Messages.getString("DjProperty.WrongStringMapping", _extent.getName() + "."
731                                                                                        + getName(), map));
732       }
733
734       // TXT column must be mapped to String
735
if (map.startsWith(DjPersistenceManager.MAPPING_TXT) && getTypeCode() != DjDomain.STRING_TYPE)
736       {
737         throw new CatalogException(Messages.getString("DjProperty.WrongStringMapping", _extent.getName() + "."
738                                                                                        + getName(), map));
739       }
740
741       // String types must be mapped to a TXT, STR or LNG column
742
if (getTypeCode() == DjDomain.STRING_TYPE
743           && !(map.startsWith(DjPersistenceManager.MAPPING_TXT) || map.startsWith(DjPersistenceManager.MAPPING_STR) || map
744               .startsWith(DjPersistenceManager.MAPPING_LNG)))
745       {
746         throw new CatalogException(Messages.getString("DjProperty.WrongStringMapping", _extent.getName() + "."
747                                                                                        + getName(), map));
748       }
749
750       // Check Date specific stuff:
751

752       // DAT column must be mapped to Date and vice versa
753
if (map.startsWith(DjPersistenceManager.MAPPING_DAT) && getTypeCode() != DjDomain.DATE_TYPE)
754       {
755         throw new CatalogException(Messages.getString("DjProperty.WrongDateMapping", _extent.getName() + "."
756                                                                                      + getName(), map));
757       }
758
759       if (!map.startsWith(DjPersistenceManager.MAPPING_DAT) && getTypeCode() == DjDomain.DATE_TYPE)
760       {
761         throw new CatalogException(Messages.getString("DjProperty.WrongDateMapping2", _extent.getName() + "."
762                                                                                       + getName(), map,
763                                                       DjPersistenceManager.MAPPING_DAT));
764       }
765
766     }
767
768     if (map.startsWith(DjPersistenceManager.MAPPING_STR) && getLength() > DjPersistenceManager.MAPPING_STR_MAX)
769     {
770       throw new CatalogException(Messages.getString("DjProperty.MaxLenExceeded", _extent.getName() + "." + getName(),
771                                                     map, String.valueOf(DjPersistenceManager.MAPPING_STR_MAX)));
772     }
773
774     if (map.startsWith(DjPersistenceManager.MAPPING_NUM) && getLength() > DjPersistenceManager.MAPPING_NUM_MAX)
775     {
776       throw new CatalogException(Messages.getString("DjProperty.MaxLenExceeded", _extent.getName() + "." + getName(),
777                                                     map, String.valueOf(DjPersistenceManager.MAPPING_NUM_MAX)));
778     }
779
780     if (map.startsWith(DjPersistenceManager.MAPPING_REL))
781     {
782       if (getExtent().getMasterRelationByPropertyName(getName()) == null) throw new CatalogException(Messages
783           .getString("DjProperty.MappedToRelButNorel", _extent.getName() + "." + getName(), map));
784     }
785
786     if (map.startsWith(DjPersistenceManager.MAPPING_TXT) && getLength() > DjPersistenceManager.MAPPING_TXT_MAX)
787     {
788       throw new CatalogException(Messages.getString("DjProperty.MaxLenExceeded", _extent.getName() + "." + getName(),
789                                                     map, String.valueOf(DjPersistenceManager.MAPPING_TXT_MAX)));
790     }
791   }
792
793   /**
794    * Returns the defaultComparator of the DjProperty class
795    *
796    * @return The defaultComparator value
797    */

798   public static Comparator JavaDoc getDefaultComparator()
799   {
800     return new PropertyComparator();
801   }
802
803   public boolean mappingIsValid()
804   {
805     try
806     {
807       checkMapping(true);
808       return true;
809     }
810     catch (CatalogException ce)
811     { // Ignore; return false
812
}
813     return false;
814   }
815
816   public void setIsPartOfRestrictedPath(boolean b)
817   {
818     _partOfRestrictedPath = b;
819   }
820
821   /**
822    * @return
823    */

824   public boolean isPartOfRestrictedPath()
825   {
826     return _partOfRestrictedPath;
827   }
828
829   public boolean isPartOfUID()
830   {
831     return _partOfUID;
832   }
833
834   public void setPartOfUID(boolean partOfUID)
835   {
836     _partOfUID = partOfUID;
837   }
838
839 }
840
841 class PropertyComparator implements Comparator JavaDoc
842 {
843   public int compare(Object JavaDoc o1, Object JavaDoc o2)
844   {
845     DjProperty f1 = (DjProperty) o1;
846     DjProperty f2 = (DjProperty) o2;
847
848     return f1.getSeq() - f2.getSeq();
849   }
850 }
851
852 class PropertySortOrderComparator implements Comparator JavaDoc
853 {
854   public int compare(Object JavaDoc o1, Object JavaDoc o2)
855   {
856     DjProperty f1 = (DjProperty) o1;
857     DjProperty f2 = (DjProperty) o2;
858
859     return f1.getSortOrder() - f2.getSortOrder();
860   }
861 }
Popular Tags