-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addresses #3006 by implementing a different "check in among" for floats
- Loading branch information
1 parent
b3d34ed
commit 507895f
Showing
2 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 33 additions & 41 deletions
74
msi.gama.headless/src/msi/gama/headless/common/DataTypeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,51 @@ | ||
/********************************************************************************************* | ||
* | ||
* | ||
* 'DataTypeFactory.java', in plugin 'msi.gama.headless', is part of the source code of the | ||
* GAMA modeling and simulation platform. | ||
* (v. 1.8.1) | ||
* | ||
* 'DataTypeFactory.java', in plugin 'msi.gama.headless', is part of the source code of the GAMA modeling and simulation | ||
* platform. (v. 1.8.1) | ||
* | ||
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners | ||
* | ||
* | ||
* Visit https://github.com/gama-platform/gama for license information and developers contact. | ||
* | ||
* | ||
* | ||
* | ||
**********************************************************************************************/ | ||
package msi.gama.headless.common; | ||
|
||
//gama.getexperiment.getOutputManager... | ||
// gama.getexperiment.getOutputManager... | ||
|
||
public final class DataTypeFactory { | ||
|
||
public static DataType getObjectMetaData(Object val) | ||
{ | ||
|
||
public static DataType getObjectMetaData(final Object val) { | ||
DataType type; | ||
if(val==null) | ||
{ | ||
return DataType.UNDEFINED; | ||
if (val == null) { return DataType.UNDEFINED; } | ||
if (val instanceof Integer || val instanceof Long) { | ||
type = DataType.INT; | ||
} else if (val instanceof Float || val instanceof Double) { | ||
type = DataType.FLOAT; | ||
} else if (val instanceof Boolean) { | ||
type = DataType.BOOLEAN; | ||
} else if (val instanceof String) { | ||
type = DataType.STRING; | ||
/* | ||
* else if(val instanceof pams.common.dataTypes.Combined ) type=DataType.COMBINED; | ||
*/ | ||
/* | ||
* else if(val instanceof Display2D) type=DataType.DISPLAY2D; | ||
*/ | ||
} else { | ||
type = DataType.UNDEFINED; | ||
} | ||
if(val instanceof Integer||val instanceof Long) | ||
type=DataType.INT; | ||
else if(val instanceof Float||val instanceof Double) | ||
type=DataType.FLOAT; | ||
else if(val instanceof Boolean) | ||
type=DataType.BOOLEAN; | ||
else if(val instanceof String ) | ||
type=DataType.STRING; | ||
/*else if(val instanceof pams.common.dataTypes.Combined ) | ||
type=DataType.COMBINED;*/ | ||
/*else if(val instanceof Display2D) | ||
type=DataType.DISPLAY2D; | ||
*/ | ||
|
||
else type=DataType.UNDEFINED; | ||
return type; | ||
} | ||
|
||
public static Object getObjectFromText(String val, DataType t) | ||
{ | ||
if(t.equals(DataType.INT)) | ||
return Integer.valueOf(val); | ||
if(t.equals(DataType.BOOLEAN)) | ||
return Boolean.valueOf(val); | ||
if(t.equals(DataType.FLOAT)) | ||
return Float.valueOf(val); | ||
if(t.equals(DataType.STRING)) | ||
return val; | ||
|
||
public static Object getObjectFromText(final String val, final DataType t) { | ||
if (t.equals(DataType.INT)) { return Integer.valueOf(val); } | ||
if (t.equals(DataType.BOOLEAN)) { return Boolean.valueOf(val); } | ||
// See #3006 | ||
if (t.equals(DataType.FLOAT)) { return Double.valueOf(val); } | ||
if (t.equals(DataType.STRING)) { return val; } | ||
return val; | ||
} | ||
|
||
|
||
} |