public boolean isUserVariableWithTypeString(Sprite sprite) { if (type == ElementType.USER_VARIABLE) { DataContainer userVariableContainer = ProjectManager.getInstance().getSceneToPlay().getDataContainer(); UserVariable userVariable = userVariableContainer.getUserVariable(value, sprite); Object userVariableValue = userVariable.getValue(); return userVariableValue instanceof String; } return false; }
private Object interpretUserVariable(Sprite sprite) { DataContainer userVariables = ProjectManager.getInstance().getSceneToPlay().getDataContainer(); UserVariable userVariable = userVariables.getUserVariable(value, sprite); if (userVariable == null) { return NOT_EXISTING_USER_VARIABLE_INTERPRETATION_VALUE; } Object userVariableValue = userVariable.getValue(); if (userVariableValue instanceof String) { return userVariableValue; } else { return userVariableValue; } }
private int handleLengthUserVariableParameter(Sprite sprite) { DataContainer userVariableContainer = ProjectManager.getInstance().getSceneToPlay().getDataContainer(); UserVariable userVariable = userVariableContainer.getUserVariable(leftChild.value, sprite); Object userVariableValue = userVariable.getValue(); if (userVariableValue instanceof String) { return String.valueOf(userVariableValue).length(); } else { if (isInteger((Double) userVariableValue)) { return Integer.toString(((Double) userVariableValue).intValue()).length(); } else { return Double.toString(((Double) userVariableValue)).length(); } } }