Convert the value according the type of DeviceData.

@param booleanValues
the value to insert on DeviceData
@param deviceDataArgin
the DeviceData attribute to write
@param dataType
the type of inserted data
@throws DevFailed
767341
public static void insertFromBooleanArray(final boolean[] booleanValues,
	    final DeviceData deviceDataArgin, final int dataType) throws DevFailed {
	// by default for xdim = 1, send the sum.
	boolean firstBoolean = false;
	if (booleanValues.length > 0) {
	    firstBoolean = booleanValues[0];
	}

	Integer intValue = new Integer(0);
	if (firstBoolean) {
	    intValue = new Integer(1);
	}

	switch (dataType) {
	case TangoConst.Tango_DEV_SHORT:
	    deviceDataArgin.insert(intValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    deviceDataArgin.insert_us(intValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "CommandHelper.insertFromBooleanArray(boolean[] values,deviceDataArgin)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    deviceDataArgin.insert(intValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_LONG:
	    deviceDataArgin.insert(intValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceDataArgin.insert_ul(intValue.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    deviceDataArgin.insert(intValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    deviceDataArgin.insert_u64(intValue.longValue());
	    break;
	case TangoConst.Tango_DEV_INT:
	    deviceDataArgin.insert(intValue.intValue());
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    deviceDataArgin.insert(intValue.floatValue());
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    deviceDataArgin.insert(intValue.doubleValue());
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceDataArgin.insert(intValue.toString());
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    deviceDataArgin.insert(firstBoolean);
	    break;
	case TangoConst.Tango_DEV_STATE:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_STATE not supported",
		    "CommandHelper.insertFromBooleanArray(boolean[] values,deviceDataArgin)");
	    break;

	// Array input type
	case TangoConst.Tango_DEVVAR_SHORTARRAY:
	    final short[] shortValues = new short[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    shortValues[i] = 1;
		} else {
		    shortValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert(shortValues);
	    break;
	case TangoConst.Tango_DEVVAR_USHORTARRAY:
	    final short[] ushortValues = new short[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    ushortValues[i] = 1;
		} else {
		    ushortValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert(ushortValues);
	    break;
	case TangoConst.Tango_DEVVAR_CHARARRAY:
	    final byte[] byteValues = new byte[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    byteValues[i] = Short.valueOf((short) 1).byteValue();
		} else {
		    byteValues[i] = Short.valueOf((short) 0).byteValue();
		}
	    }
	    deviceDataArgin.insert(byteValues);
	    break;
	case TangoConst.Tango_DEVVAR_LONGARRAY:
	    final int[] longValues = new int[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    longValues[i] = 1;
		} else {
		    longValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert(longValues);
	    break;
	case TangoConst.Tango_DEVVAR_ULONGARRAY:
	    final long[] ulongValues = new long[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    ulongValues[i] = 1;
		} else {
		    ulongValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert_ul(ulongValues);
	    break;
	case TangoConst.Tango_DEVVAR_LONG64ARRAY:
	    final int[] long64Values = new int[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    long64Values[i] = 1;
		} else {
		    long64Values[i] = 0;
		}
	    }
	    deviceDataArgin.insert(long64Values);
	    break;
	case TangoConst.Tango_DEVVAR_ULONG64ARRAY:
	    final long[] ulong64Values = new long[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    ulong64Values[i] = 1;
		} else {
		    ulong64Values[i] = 0;
		}
	    }
	    deviceDataArgin.insert_u64(ulong64Values);
	    break;
	case TangoConst.Tango_DEVVAR_FLOATARRAY:
	    final float[] floatValues = new float[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    floatValues[i] = 1;
		} else {
		    floatValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert(floatValues);
	    break;
	case TangoConst.Tango_DEVVAR_DOUBLEARRAY:
	    final double[] doubleValues = new double[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		if (booleanValues[i]) {
		    doubleValues[i] = 1;
		} else {
		    doubleValues[i] = 0;
		}
	    }
	    deviceDataArgin.insert(doubleValues);
	    break;
	case TangoConst.Tango_DEVVAR_STRINGARRAY:
	    final String[] stringValues = new String[booleanValues.length];
	    for (int i = 0; i < booleanValues.length; i++) {
		stringValues[i] = Boolean.valueOf(booleanValues[i]).toString();
	    }
	    deviceDataArgin.insert(stringValues);
	    break;

	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceDataArgin.getType() + " not supported",
		    "insertFromBooleanArray.insertFromLongArray(boolean[] values,deviceDataArgin)");
	    break;
	}
    }
308971
public void pushAttributeErrorEvent(final String deviceName, final String attributeName, final DevFailed devFailed)
            throws DevFailed {
        xlogger.entry();
        for (final EventType eventType : EventType.values()) {
            final String fullName = EventUtilities.buildEventName(deviceName, attributeName, eventType);
            final EventImpl eventImpl = getEventImpl(fullName);
            if (eventImpl != null) {
                for (ZMQ.Socket eventSocket : eventEndpoints.values()) {
                    eventImpl.pushDevFailedEvent(devFailed, eventSocket);
                }
            }
        }
        xlogger.exit();
    }
74201
public static void insertFromDevState(final DevState devStateValue,
	    final DeviceAttribute deviceAttributeWritten) throws DevFailed {

	final Integer integerValue = Integer.valueOf(devStateValue.value());
	switch (deviceAttributeWritten.getType()) {
	case TangoConst.Tango_DEV_SHORT:
	    deviceAttributeWritten.insert(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    deviceAttributeWritten.insert_us(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    deviceAttributeWritten.insert_uc(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_LONG:
	    deviceAttributeWritten.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceAttributeWritten.insert_ul(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_LONG64 not supported",
		    "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    deviceAttributeWritten.insert_u64(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_INT:
	    deviceAttributeWritten.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    deviceAttributeWritten.insert(integerValue.floatValue());
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    deviceAttributeWritten.insert(integerValue.doubleValue());
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceAttributeWritten.insert(integerValue.toString());
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    if (integerValue.doubleValue() == 1) {
		deviceAttributeWritten.insert(true);
	    } else {
		deviceAttributeWritten.insert(false);
	    }
	    break;
	case TangoConst.Tango_DEV_STATE:
	    deviceAttributeWritten.insert(devStateValue);
	    break;
	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceAttributeWritten.getType() + " not supported",
		    "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)");
	    break;
	}
    }
1111725
public void delete_device_attribute_property(String devname, DbAttribute[] attr) throws DevFailed {
		databaseDAO.delete_device_attribute_property(this, devname, attr);
	}
1195831
@Override
    public void write_attributes_4(final AttributeValue_4[] values, final ClntIdent clIdent) throws MultiDevFailed,
            DevFailed {
        MDC.setContextMap(contextMap);
        xlogger.entry();
        checkInitialization();
        final String[] names = new String[values.length];
        for (int i = 0; i < names.length; i++) {
            names[i] = values[i].name;
        }
        logger.debug("writing {}", Arrays.toString(names));
        deviceMonitoring.startRequest("write_attributes_4 " + Arrays.toString(names), clIdent);
        clientIdentity.set(clIdent);
        if (!name.equalsIgnoreCase(getAdminDeviceName())) {
            clientLocking.checkClientLocking(clIdent, names);
        }
        final Object lock = deviceLock.getAttributeLock();
        try {
            synchronized (lock != null ? lock : new Object()) {
                AttributeGetterSetter.setAttributeValue4(values, attributeList, stateImpl, aroundInvokeImpl, clIdent);
            }
        } catch (final Exception e) {
            deviceMonitoring.addError();
            if (e instanceof MultiDevFailed) {
                throw (MultiDevFailed) e;
            } else {
                // with CORBA, the stack trace is not visible by the client if
                // not inserted in DevFailed.
                throw DevFailedUtils.newDevFailed(e);
            }
        }
        xlogger.exit();
    }
549664
public void insert(final Object... value) throws DevFailed {
        if (value.length == 1) {
            for (int i = 0; i < group.get_size(true); i++) {
                final int arginType = group.get_device(i + 1).command_query(commandName).in_type;
                InsertExtractUtils.insert(inData[i], arginType, value);
            }
        } else {
            if (value.length != group.get_size(true)) {
                throw DevFailedUtils.newDevFailed(TANGO_WRONG_DATA_ERROR, group.get_size(true) + " values must be provided");
            }
            for (int i = 0; i < group.get_size(true); i++) {
                final int arginType = group.get_device(i + 1).command_query(commandName).in_type;
                InsertExtractUtils.insert(inData[i], arginType, value[i]);
            }
        }
    }
1278437
public static void insertFromDevVarLongStringArray(final DevVarLongStringArray value,
	    final DeviceData deviceDataArgin, final int dataType) throws DevFailed {
	if (dataType == TangoConst.Tango_DEVVAR_LONGSTRINGARRAY) {
	    deviceDataArgin.insert(value);
	} else {
	    Except
		    .throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
			    + deviceDataArgin.getType() + " not supported",
			    "CommandHelper.insertFromDevVarLongStringArray(DevVarLongStringArray value,deviceDataArgin)");
	}
    }
955092
public static void insertFromDevState(final DevState devStateValue,
	    final DeviceData deviceDataArgin, final int dataType) throws DevFailed {

	final Integer integerValue = Integer.valueOf(devStateValue.value());
	switch (deviceDataArgin.getType()) {
	case TangoConst.Tango_DEV_SHORT:
	    deviceDataArgin.insert(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    deviceDataArgin.insert_us(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "CommandHelper.insertFromDevState(DevState value,deviceDataArgin)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    deviceDataArgin.insert(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_LONG:
	    deviceDataArgin.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceDataArgin.insert_ul(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    deviceDataArgin.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    deviceDataArgin.insert_u64(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_INT:
	    deviceDataArgin.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    deviceDataArgin.insert(integerValue.floatValue());
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    deviceDataArgin.insert(integerValue.doubleValue());
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceDataArgin.insert(integerValue.toString());
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    if (integerValue.doubleValue() == 1) {
		deviceDataArgin.insert(true);
	    } else {
		deviceDataArgin.insert(false);
	    }
	    break;
	case TangoConst.Tango_DEV_STATE:
	    deviceDataArgin.insert(devStateValue);
	    break;
	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceDataArgin.getType() + " not supported",
		    "CommandHelper.insertFromDevState(DevState value,deviceDataArgin)");
	    break;
	}
    }
874727
public void pushAttributeDataReadyEvent(final String deviceName, final String attributeName, final int counter)
            throws DevFailed {
        xlogger.entry();
        final String fullName = EventUtilities.buildEventName(deviceName, attributeName, EventType.DATA_READY_EVENT);
        final EventImpl eventImpl = getEventImpl(fullName);
        if (eventImpl != null) {
            for (ZMQ.Socket eventSocket : eventEndpoints.values()) {
                eventImpl.pushAttributeDataReadyEvent(counter, eventSocket);
            }
        }
        xlogger.exit();
    }
623073
public static void insertFromBoolean(final Boolean booleanValue,
	    final DeviceAttribute deviceAttributeWritten) throws DevFailed {

	Integer integerValue = 0;
	if (booleanValue.booleanValue()) {
	    integerValue = 1;
	}

	switch (deviceAttributeWritten.getType()) {
	case TangoConst.Tango_DEV_SHORT:
	    deviceAttributeWritten.insert(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    deviceAttributeWritten.insert_us(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    deviceAttributeWritten.insert_uc(integerValue.shortValue());
	    break;
	case TangoConst.Tango_DEV_LONG:
	    deviceAttributeWritten.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceAttributeWritten.insert_ul(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_LONG64 not supported",
		    "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    deviceAttributeWritten.insert_u64(integerValue.longValue());
	    break;
	case TangoConst.Tango_DEV_INT:
	    deviceAttributeWritten.insert(integerValue.intValue());
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    deviceAttributeWritten.insert(integerValue.floatValue());
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    deviceAttributeWritten.insert(integerValue.doubleValue());
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceAttributeWritten.insert(Boolean.toString(booleanValue.booleanValue()));
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    deviceAttributeWritten.insert(booleanValue.booleanValue());
	    break;
	case TangoConst.Tango_DEV_STATE:
	    deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue()));
	    break;
	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceAttributeWritten.getType() + " not supported",
		    "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)");
	    break;
	}
    }
521676
@Deprecated
    public void insert_u(final DeviceData deviceData, final int[] argin) {
        DevVarULongArrayHelper.insert(deviceData.getAny(), argin);
    }
1122113
public void insert(final DeviceData deviceData, final DevVarLongStringArray argin) {
        DevVarLongStringArrayHelper.insert(deviceData.getAny(), argin);
    }
1015911
@Override
    public DeviceImportInfo importDevice(final String toBeImported) throws DevFailed {
        final DeviceData argin = new DeviceData();
        argin.insert(toBeImported);
        final DeviceData argout = database.command_inout("DbImportDevice", argin);
        final DevVarLongStringArray info = argout.extractLongStringArray();
        return new DeviceImportInfo(info);
    }
699963
public DeviceAttribute[] write_read_attribute(DeviceAttribute[] deviceAttributes,
                                                  String[] readNames) throws DevFailed {
        return deviceProxyDAO.write_read_attribute(this, deviceAttributes, readNames);
    }
930687
public static Integer extractToInteger(final DeviceData deviceDataArgout) throws DevFailed {
	final Object value = CommandHelper.extract(deviceDataArgout);
	Integer argout = null;
	if (value instanceof Short) {
	    argout = Integer.valueOf(((Short) value).intValue());
	} else if (value instanceof String) {
	    try {
		argout = Integer.valueOf((String) value);
	    } catch (final Exception e) {
		Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value
			+ " is not a numerical", "CommandHelper.extractToInteger(deviceDataArgin)");
	    }
	} else if (value instanceof Integer) {
	    argout = (Integer) value;
	} else if (value instanceof Long) {
	    argout = Integer.valueOf(((Long) value).intValue());
	} else if (value instanceof Float) {
	    argout = Integer.valueOf(((Float) value).intValue());
	} else if (value instanceof Boolean) {
	    if (((Boolean) value).booleanValue()) {
		argout = Integer.valueOf(1);
	    } else {
		argout = Integer.valueOf(0);
	    }
	} else if (value instanceof Double) {
	    argout = Integer.valueOf(((Double) value).intValue());
	} else if (value instanceof DevState) {
	    argout = Integer.valueOf(((DevState) value).value());
	} else {
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass()
		    + " not supported",
		    "CommandHelper.extractToInteger(Object value,deviceDataArgin)");
	}

	return argout;
    }
1169480
public void insert(final DevState argin) {
	final DevState[] values = new DevState[1];
	values[0] = argin;
	attrval.r_dim.dim_x = 1;
	attrval.r_dim.dim_y = 0;
	DevVarStateArrayHelper.insert(attrval.value, values);
    }
1291037
public void setAttributePropertyInDB(final String attributeName, final String propertyName, final String value)
            throws DevFailed {
        xlogger.entry(propertyName);

        // insert value in db only if input value is different and not a
        // default value
        // if (checkCurrentValue) {
        // final String presentValue = getAttributePropertyFromDB(attributeName, propertyName);
        // final boolean isADefaultValue = presentValue.isEmpty()
        // && (value.equalsIgnoreCase(AttributePropertiesImpl.NOT_SPECIFIED)
        // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_DIPLAY_UNIT)
        // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_UNIT) || value
        // .equalsIgnoreCase(AttributePropertiesImpl.NO_STD_UNIT));
        // if (!isADefaultValue && !presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) {
        // LOGGER.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value });
        // final Map<String, String[]> propInsert = new HashMap<String, String[]>();
        // propInsert.put(propertyName, new String[] { value });
        // DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert);
        // }
        // } else {
        logger.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value });
        final Map<String, String[]> propInsert = new HashMap<String, String[]>();
        propInsert.put(propertyName, new String[] { value });
        DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert);
        // }
        xlogger.exit();
    }