Revision 1405 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/ValueType.java
ValueType.java | ||
---|---|---|
6 | 6 |
import org.gvsig.tools.dynobject.DynObject; |
7 | 7 |
import org.gvsig.tools.dynobject.DynStruct; |
8 | 8 |
|
9 |
public class ValueType { |
|
9 |
public class ValueType implements org.gvsig.tools.lang.Cloneable {
|
|
10 | 10 |
|
11 | 11 |
DataType type; |
12 | 12 |
Class theClass; |
... | ... | |
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
public void setClassOfValue(Class theClass) { |
64 |
if( theClass == null ) { |
|
65 |
this.theClass = null; |
|
66 |
return; |
|
67 |
} |
|
68 |
|
|
64 | 69 |
if ( this.type == null || type.getType() == DataTypes.UNKNOWN ) { |
65 | 70 |
this.type = ToolsLocator.getDataTypesManager().get(DataTypes.OBJECT); |
66 | 71 |
} |
... | ... | |
73 | 78 |
} |
74 | 79 |
|
75 | 80 |
public void setClassOfValue(DynStruct dynStrct) { |
81 |
if( dynStrct == null ) { |
|
82 |
this.theDynClass = null; |
|
83 |
return; |
|
84 |
} |
|
76 | 85 |
if ( this.type == null || type.getType() == DataTypes.UNKNOWN ) { |
77 | 86 |
this.type = ToolsLocator.getDataTypesManager().get(DataTypes.DYNOBJECT); |
78 | 87 |
} |
... | ... | |
83 | 92 |
} |
84 | 93 |
|
85 | 94 |
public void setClassOfValue(String theClassNameOfValue) { |
95 |
if( theClassNameOfValue == null ) { |
|
96 |
this.theDynClass = null; |
|
97 |
this.theClass = null; |
|
98 |
return; |
|
99 |
} |
|
86 | 100 |
if ( this.type == null ) { |
87 | 101 |
throw new IllegalStateException("Need to set type before assign classOfValue by name"); |
88 | 102 |
} |
89 | 103 |
if ( type.getType() == DataTypes.DYNOBJECT ) { |
90 |
this.theDynClass = (DynStruct) ToolsLocator.getDynObjectManager().createDynClassName(theClassNameOfValue); |
|
104 |
// Probablemente habria que posponer la busqueda de la clase hasta que se |
|
105 |
// invoque al metodo getDynClassOfValue, ya que si se esta cargando la |
|
106 |
// DynClass desde un fichero xml puede que aun no esten disponibles las |
|
107 |
// clases del fichero xml para ser usadas en este momento. |
|
108 |
// |
|
109 |
this.theDynClass = ToolsLocator.getDynObjectManager().get(theClassNameOfValue); |
|
91 | 110 |
if ( this.theDynClass == null ) { |
92 | 111 |
throw new IllegalArgumentException("DynClass of type '" + theClassNameOfValue + "' not found."); |
93 | 112 |
} |
... | ... | |
132 | 151 |
return this.type.toString(); |
133 | 152 |
} |
134 | 153 |
|
154 |
@Override |
|
155 |
public Object clone() throws CloneNotSupportedException { |
|
156 |
ValueType other = (ValueType) super.clone(); |
|
157 |
return other; |
|
158 |
} |
|
135 | 159 |
} |
Also available in: Unified diff