Revision 42563
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java | ||
---|---|---|
28 | 28 |
import java.util.List; |
29 | 29 |
import java.util.Map; |
30 | 30 |
import java.util.Map.Entry; |
31 |
|
|
31 |
import org.apache.commons.lang3.ArrayUtils; |
|
32 | 32 |
import org.cresques.cts.IProjection; |
33 |
|
|
34 | 33 |
import org.gvsig.fmap.crs.CRSFactory; |
35 | 34 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
|
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
37 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
|
38 | 37 |
import org.gvsig.fmap.geom.Geometry; |
39 | 38 |
import org.gvsig.fmap.geom.GeometryException; |
40 | 39 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
45 | 44 |
import org.gvsig.tools.dataTypes.DataTypes; |
46 | 45 |
import org.gvsig.tools.dynobject.DynField; |
47 | 46 |
import org.gvsig.tools.dynobject.DynField_LabelAttribute; |
47 |
import org.gvsig.tools.dynobject.DynField_v2; |
|
48 | 48 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
49 | 49 |
import org.gvsig.tools.dynobject.DynStruct; |
50 |
import org.gvsig.tools.dynobject.Tags; |
|
50 | 51 |
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException; |
51 | 52 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
53 |
import org.gvsig.tools.dynobject.impl.DefaultTags; |
|
52 | 54 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
53 | 55 |
import org.gvsig.tools.evaluator.Evaluator; |
54 | 56 |
import org.gvsig.tools.evaluator.EvaluatorData; |
... | ... | |
58 | 60 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
59 | 61 |
|
60 | 62 |
public class DefaultFeatureAttributeDescriptor implements |
61 |
FeatureAttributeDescriptor, Persistent, DynField, DynField_LabelAttribute { |
|
63 |
FeatureAttributeDescriptor, Persistent, DynField_v2, DynField_LabelAttribute {
|
|
62 | 64 |
|
63 | 65 |
protected boolean allowNull; |
64 | 66 |
protected DataType dataType; |
... | ... | |
87 | 89 |
protected boolean isIndexAscending = true; |
88 | 90 |
protected boolean allowIndexDuplicateds = true; |
89 | 91 |
|
92 |
protected DynObjectValueItem[] availableValues; |
|
93 |
protected String description; |
|
94 |
protected Object minValue; |
|
95 |
protected Object maxValue; |
|
96 |
protected String label; |
|
97 |
protected int order; |
|
98 |
protected boolean hidden; |
|
99 |
protected String groupName; |
|
100 |
protected Tags tags = new DefaultTags(); |
|
101 |
|
|
90 | 102 |
protected DefaultFeatureAttributeDescriptor() { |
91 | 103 |
this.allowNull = true; |
92 | 104 |
this.dataType = null; |
... | ... | |
464 | 476 |
isAutomatic = state.getBoolean("isAutomatic"); |
465 | 477 |
} |
466 | 478 |
|
467 |
/**
|
|
479 |
/* |
|
468 | 480 |
* Start of DynField interface Implementation |
469 | 481 |
* |
470 |
* @return |
|
471 | 482 |
*/ |
483 |
|
|
484 |
public Tags getTags() { |
|
485 |
return tags; |
|
486 |
} |
|
487 |
|
|
472 | 488 |
@Override |
473 | 489 |
public DynObjectValueItem[] getAvailableValues() { |
474 |
return null;
|
|
490 |
return this.availableValues;
|
|
475 | 491 |
} |
476 | 492 |
|
477 | 493 |
@Override |
478 | 494 |
public String getDescription() { |
479 |
return getName(); |
|
495 |
if( this.description == null ) { |
|
496 |
return getName(); |
|
497 |
} |
|
498 |
return this.description; |
|
480 | 499 |
} |
481 | 500 |
|
482 | 501 |
@Override |
483 | 502 |
public Object getMaxValue() { |
484 |
return null;
|
|
503 |
return this.maxValue;
|
|
485 | 504 |
} |
486 | 505 |
|
487 | 506 |
@Override |
488 | 507 |
public Object getMinValue() { |
489 |
return null;
|
|
508 |
return this.minValue;
|
|
490 | 509 |
} |
491 | 510 |
|
492 | 511 |
@Override |
493 | 512 |
public int getTheTypeOfAvailableValues() { |
494 |
return 0;
|
|
513 |
return 1;
|
|
495 | 514 |
} |
496 | 515 |
|
497 | 516 |
@Override |
... | ... | |
514 | 533 |
|
515 | 534 |
@Override |
516 | 535 |
public DynField setAvailableValues(DynObjectValueItem[] values) { |
517 |
throw new UnsupportedOperationException(); |
|
536 |
if ( ArrayUtils.isEmpty(values) ) { |
|
537 |
this.availableValues = null; |
|
538 |
} else { |
|
539 |
this.availableValues = values; |
|
540 |
} |
|
541 |
return this; |
|
518 | 542 |
} |
519 | 543 |
|
520 | 544 |
@Override |
521 | 545 |
public DynField setDescription(String description) { |
522 |
throw new UnsupportedOperationException(); |
|
546 |
this.description = description; |
|
547 |
return this; |
|
523 | 548 |
} |
524 | 549 |
|
525 | 550 |
@Override |
... | ... | |
529 | 554 |
|
530 | 555 |
@Override |
531 | 556 |
public DynField setMaxValue(Object maxValue) { |
532 |
throw new UnsupportedOperationException(); |
|
557 |
try { |
|
558 |
this.maxValue = this.coerce(maxValue); |
|
559 |
} catch (CoercionException e) { |
|
560 |
throw new IllegalArgumentException(e); |
|
561 |
} |
|
562 |
return this; |
|
533 | 563 |
} |
534 | 564 |
|
535 | 565 |
@Override |
536 | 566 |
public DynField setMinValue(Object minValue) { |
537 |
throw new UnsupportedOperationException(); |
|
567 |
try { |
|
568 |
this.maxValue = this.coerce(minValue); |
|
569 |
} catch (CoercionException e) { |
|
570 |
throw new IllegalArgumentException(e); |
|
571 |
} |
|
572 |
return this; |
|
538 | 573 |
} |
539 | 574 |
|
540 | 575 |
@Override |
... | ... | |
617 | 652 |
} |
618 | 653 |
|
619 | 654 |
@Override |
620 |
public Object coerce(Object value) { |
|
621 |
throw new UnsupportedOperationException(); |
|
655 |
public Object coerce(Object value) throws CoercionException { |
|
656 |
if ( value == null ) { |
|
657 |
return value; // O debe devolver this.defaultValue |
|
658 |
} |
|
659 |
try { |
|
660 |
return this.getDataType().coerce(value); |
|
661 |
} catch(Exception ex){ |
|
662 |
throw new RuntimeException(ex); |
|
663 |
} |
|
622 | 664 |
} |
623 | 665 |
|
624 | 666 |
@Override |
625 | 667 |
public DynField setAvailableValues(List values) { |
626 |
throw new UnsupportedOperationException(); |
|
668 |
if ( values == null || values.isEmpty() ) { |
|
669 |
this.availableValues = null; |
|
670 |
} else { |
|
671 |
this.availableValues = (DynObjectValueItem[]) values.toArray( |
|
672 |
new DynObjectValueItem[values.size()] |
|
673 |
); |
|
674 |
} |
|
675 |
return this; |
|
627 | 676 |
} |
628 | 677 |
|
629 | 678 |
@Override |
630 | 679 |
public String getGroup() { |
631 |
return null;
|
|
680 |
return this.groupName;
|
|
632 | 681 |
} |
633 | 682 |
|
634 | 683 |
@Override |
635 | 684 |
public int getOder() { |
636 |
return 0;
|
|
685 |
return this.order;
|
|
637 | 686 |
} |
638 | 687 |
|
639 | 688 |
@Override |
640 | 689 |
public String getLabel() { |
641 |
return this.getName(); |
|
690 |
if( this.label == null ) { |
|
691 |
return this.getName(); |
|
692 |
} |
|
693 |
return this.label; |
|
642 | 694 |
} |
643 | 695 |
|
644 | 696 |
@Override |
645 | 697 |
public DynField setLabel(String label) { |
646 |
throw new UnsupportedOperationException("Not supported yet."); |
|
698 |
this.label = label; |
|
699 |
return this; |
|
647 | 700 |
} |
648 | 701 |
|
649 | 702 |
@Override |
650 | 703 |
public DynField setGroup(String groupName) { |
651 |
throw new UnsupportedOperationException(); |
|
704 |
this.groupName = groupName; |
|
705 |
return this; |
|
652 | 706 |
} |
653 | 707 |
|
654 | 708 |
@Override |
655 | 709 |
public DynField setOrder(int order) { |
656 |
throw new UnsupportedOperationException(); |
|
710 |
this.order = order; |
|
711 |
return this; |
|
657 | 712 |
} |
658 | 713 |
|
659 | 714 |
@Override |
660 | 715 |
public DynField setHidden(boolean hidden) { |
661 |
throw new UnsupportedOperationException(); |
|
716 |
this.hidden = hidden; |
|
717 |
return this; |
|
662 | 718 |
} |
663 | 719 |
|
664 | 720 |
@Override |
665 | 721 |
public boolean isHidden() { |
666 |
return false;
|
|
722 |
return this.hidden;
|
|
667 | 723 |
} |
668 | 724 |
|
669 | 725 |
@Override |
... | ... | |
732 | 788 |
return this.isIndexAscending; |
733 | 789 |
} |
734 | 790 |
|
791 |
@Override |
|
792 |
public DynField setClassOfValue(DynStruct dynStrct) { |
|
793 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
794 |
} |
|
795 |
|
|
796 |
@Override |
|
797 |
public DynField setClassOfValue(String theClassNameOfValue) { |
|
798 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
799 |
} |
|
800 |
|
|
801 |
@Override |
|
802 |
public String getClassNameOfValue() { |
|
803 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
804 |
} |
|
805 |
|
|
806 |
@Override |
|
807 |
public DynStruct getDynClassOfValue() { |
|
808 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
809 |
} |
|
810 |
|
|
811 |
@Override |
|
812 |
public DynField setTypeOfItems(int type) { |
|
813 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
814 |
} |
|
815 |
|
|
816 |
@Override |
|
817 |
public int getTypeOfItems() { |
|
818 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
819 |
} |
|
820 |
|
|
821 |
@Override |
|
822 |
public DynField setClassOfItems(DynStruct dynStrct) { |
|
823 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
824 |
} |
|
825 |
|
|
826 |
@Override |
|
827 |
public DynField setClassOfItems(String theClassNameOfValue) { |
|
828 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
829 |
} |
|
830 |
|
|
831 |
@Override |
|
832 |
public String getClassNameOfItems() { |
|
833 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
834 |
} |
|
835 |
|
|
836 |
@Override |
|
837 |
public DynStruct getDynClassOfItems() { |
|
838 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
839 |
} |
|
840 |
|
|
841 |
@Override |
|
842 |
public DynField setRelationType(int relationType) { |
|
843 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
844 |
} |
|
845 |
|
|
846 |
@Override |
|
847 |
public int getRelationType() { |
|
848 |
return RELATION_TYPE_NONE; |
|
849 |
} |
|
850 |
|
|
735 | 851 |
private class ConstantValueEvaluator extends AbstractEvaluator { |
736 | 852 |
|
737 | 853 |
@Override |
Also available in: Unified diff