Revision 1860
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/DynObjectManager.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
public int NULLCODE = -1; |
60 | 60 |
|
61 |
public DynClass createCopy(DynClass source); |
|
61 | 62 |
/** |
62 | 63 |
* Create a instance of DynClass with the name and description |
63 | 64 |
* Indicated as parameters. |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DefaultDynObjectManager.java | ||
---|---|---|
43 | 43 |
import org.gvsig.tools.dynobject.AbstractDynMethod; |
44 | 44 |
import org.gvsig.tools.dynobject.DynClass; |
45 | 45 |
import org.gvsig.tools.dynobject.DynClassName; |
46 |
import org.gvsig.tools.dynobject.DynClass_v2; |
|
46 | 47 |
import org.gvsig.tools.dynobject.DynField; |
47 | 48 |
import org.gvsig.tools.dynobject.DynField_LabelAttribute; |
48 | 49 |
import org.gvsig.tools.dynobject.DynField_v2; |
... | ... | |
363 | 364 |
this.methods = null; |
364 | 365 |
} |
365 | 366 |
|
366 |
public DynClass createDynClass(String name, String description) { |
|
367 |
public DynClass_v2 createDynClass(String name, String description) {
|
|
367 | 368 |
return new DefaultDynClass(this, name, description); |
368 | 369 |
} |
369 | 370 |
|
370 |
public DynClass createDynClass(String namespace, String name, |
|
371 |
public DynClass_v2 createDynClass(String namespace, String name,
|
|
371 | 372 |
String description) { |
372 | 373 |
return new DefaultDynClass(this, namespace, name, description); |
373 | 374 |
} |
... | ... | |
785 | 786 |
} |
786 | 787 |
|
787 | 788 |
@Override |
788 |
public DynField createDynField(String name) { |
|
789 |
public DynField_v2 createDynField(String name) {
|
|
789 | 790 |
return new DefaultDynField(name, DataTypes.STRING); |
790 | 791 |
} |
792 |
|
|
793 |
@Override |
|
794 |
public DynClass_v2 createCopy(DynClass source) { |
|
795 |
DynClass_v2 target = this.createDynClass( |
|
796 |
source.getNamespace(), |
|
797 |
source.getName(), |
|
798 |
source.getDescription() |
|
799 |
); |
|
800 |
for (DynField sourceField : source.getDynFields()) { |
|
801 |
DynField_v2 targetField = (DynField_v2) target.addDynField(sourceField.getName()); |
|
802 |
targetField.copyFrom(sourceField); |
|
803 |
} |
|
804 |
try { |
|
805 |
for (DynMethod sourceMethod : source.getDynMethods()) { |
|
806 |
target.addDynMethod(sourceMethod); |
|
807 |
} |
|
808 |
} catch (DynMethodException ex) { |
|
809 |
} |
|
810 |
return target; |
|
811 |
} |
|
791 | 812 |
|
792 |
|
|
793 | 813 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DefaultDynField.java | ||
---|---|---|
812 | 812 |
|
813 | 813 |
@Override |
814 | 814 |
public DynField setClassOfItems(DynStruct dynStrct) { |
815 |
if (!this.isContainer()) { |
|
815 |
if (dynStrct!=null && !this.isContainer()) {
|
|
816 | 816 |
throw new IllegalStateException("Can't assign classOfItems in non container."); |
817 | 817 |
} |
818 | 818 |
this.itemsType.setClassOfValue(dynStrct); |
... | ... | |
821 | 821 |
|
822 | 822 |
@Override |
823 | 823 |
public DynField setClassOfItems(String theClassNameOfValue) { |
824 |
if (!this.isContainer()) { |
|
824 |
if (theClassNameOfValue!=null && !this.isContainer()) {
|
|
825 | 825 |
throw new IllegalStateException("Can't assign classOfItems in non container."); |
826 | 826 |
} |
827 | 827 |
this.itemsType.setClassOfValue(theClassNameOfValue); |
... | ... | |
830 | 830 |
|
831 | 831 |
@Override |
832 | 832 |
public String getClassNameOfItems() { |
833 |
if( this.itemsType==null || |
|
834 |
this.itemsType.getClassNameOfValue()==null ) { |
|
835 |
return null; |
|
836 |
} |
|
833 | 837 |
if (!this.isContainer()) { |
834 | 838 |
throw new IllegalStateException("Can't get classNameOfItems in non container."); |
835 | 839 |
} |
... | ... | |
838 | 842 |
|
839 | 843 |
@Override |
840 | 844 |
public DynStruct getDynClassOfItems() { |
845 |
if( this.itemsType==null || |
|
846 |
this.itemsType.getDynClassOfValue()==null ) { |
|
847 |
return null; |
|
848 |
} |
|
841 | 849 |
if (!this.isContainer()) { |
842 | 850 |
throw new IllegalStateException("Can't get dynClassOfItems in non container."); |
843 | 851 |
} |
... | ... | |
847 | 855 |
@Override |
848 | 856 |
public DynField setClassOfItems(Class theClass) |
849 | 857 |
throws DynFieldIsNotAContainerException { |
850 |
if (!this.isContainer()) { |
|
858 |
if (theClass!=null && !this.isContainer()) {
|
|
851 | 859 |
throw new IllegalStateException("Can't assign classNameOfItems in non container."); |
852 | 860 |
} |
853 | 861 |
this.itemsType.setClassOfValue(theClass); |
... | ... | |
856 | 864 |
|
857 | 865 |
@Override |
858 | 866 |
public Class getClassOfItems() { |
867 |
if( this.itemsType==null || |
|
868 |
this.itemsType.getClassOfValue()==null ) { |
|
869 |
return null; |
|
870 |
} |
|
859 | 871 |
if (!this.isContainer()) { |
860 | 872 |
throw new IllegalStateException("Can't get classOfItems in non container."); |
861 | 873 |
} |
862 | 874 |
Also available in: Unified diff