Set a value in an any

@param tangoType
@param value
@return the Any
@throws DevFailed
770504
public static Any set(final int tangoType, final Object value) throws DevFailed {
        final Any any = ORBManager.createAny();

        if (value != null) {
            Object array = null;
            if (value.getClass().isArray()) {
                // convert to array of primitives if necessary
                array = org.tango.utils.ArrayUtils.toPrimitiveArray(value);
            } else {
                // put in an array before inserting for scalars
                array = Array.newInstance(AttributeTangoType.getTypeFromTango(tangoType).getType(), 1);
                Array.set(array, 0, value);
            }
            Method method = null;
            try {
                final Class<?> inserterClass = CLASS_MAP.get(tangoType);
                method = inserterClass.getMethod("insert", Any.class, PARAM_MAP.get(tangoType));
                method.invoke(null, any, array);
            } catch (final IllegalArgumentException e) {
                throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName()
                        + " is not of the good type, should be " + method);
            } catch (final IllegalAccessException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final InvocationTargetException e) {
                throw DevFailedUtils.newDevFailed(e.getCause());
            } catch (final SecurityException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final NoSuchMethodException e) {
                throw DevFailedUtils.newDevFailed(e);
            }
        }
        return any;
    }
880638
private void putProperties(Database database) throws DevFailed {
        for (TangoClass clazz : classes) {
            clazz.putProperties(database);
            clazz.putAttributeProperties(database);
            clazz.putPipeProperties(database);
            for (TangoDevice device : clazz) {
                device.putProperties(database);
                device.putAttributeProperties(database);
                device.putPipeProperties(database);
            }
        }
    }
1313831
private static Object toDatabaseSupportedValue(Object value) {
        if (value instanceof java.lang.String ||
                value instanceof byte[] ||
                value instanceof Byte[] ||
                value instanceof java.lang.Long ||
                value instanceof java.lang.Integer ||
                value instanceof java.lang.Boolean ||
                value instanceof java.math.BigInteger ||
                value instanceof java.lang.Float ||
                value instanceof java.lang.Double ||
                value instanceof java.math.BigDecimal ||
                value instanceof java.sql.Date ||
                value instanceof java.util.Date ||
                /*
                because java.sql.Time and java.sql.Timestamp is subclass of java.sql.Date so the checks always return true
                value instanceof java.sql.Time || value instanceof java.sql.Timestamp ||
                */
                value instanceof java.util.Calendar
                ) {
            return value;
        } else {
            return Reflection.toType(value, String.class);
        }
    }
236396
static void checkStatic(final Field field) throws DevFailed {
        if (Modifier.isStatic(field.getModifiers())) {
            throw DevFailedUtils.newDevFailed(DevFailedUtils.TANGO_BUILD_FAILED, field + MUST_NOT_BE_STATIC);
        }
    }
1014604
@SuppressWarnings("unchecked")
    public static <T> T castToType(final Class<T> type, final Object val) throws DevFailed {

	T result;
	if (val == null) {
	    result = null;
	} else if (type.isAssignableFrom(val.getClass())) {
	    result = (T) val;
	} else {
	    LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
	    // if input is not an array and we want to convert it to an array.
	    // Put
	    // the value in an array
	    Object array = val;
	    if (!val.getClass().isArray() && type.isArray()) {
		array = Array.newInstance(val.getClass(), 1);
		Array.set(array, 0, val);
	    }
	    final Transmorph transmorph = new Transmorph(creatConv());
	    try {
		result = transmorph.convert(array, type);
	    } catch (final ConverterException e) {
		LOGGER.error("convertion error", e);
		throw DevFailedUtils.newDevFailed(e);
	    }
	}
	return result;
    }
152162
public static void set_value(final Object value, final Attribute attribute) throws DevFailed {
	try {

	    if (value instanceof Short) {
		attribute.set_value(((Short) value).shortValue());
	    } else if (value instanceof Byte) {
		attribute.set_value(((Byte) value).shortValue());
	    } else if (value instanceof String) {
		attribute.set_value((String) value);
	    } else if (value instanceof Integer) {
		attribute.set_value(((Integer) value).intValue());
	    } else if (value instanceof Long) {
		attribute.set_value(((Long) value).longValue());
	    } else if (value instanceof Float) {
		attribute.set_value(((Float) value).doubleValue());
	    } else if (value instanceof Boolean) {
		attribute.set_value(((Boolean) value).booleanValue());
	    } else if (value instanceof Double) {
		attribute.set_value(((Double) value).doubleValue());
	    } else if (value instanceof DevState) {
		attribute.set_value((DevState) value);
	    } else {
		// System.out.println(value.getClass().getName());
		Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + value.getClass()
			+ " not supported",
			"AttributeHelper.insert(Object value,deviceAttributeWritten)");
	    }
	} catch (final Exception e) {
	    e.printStackTrace();
	}
    }
602068
public function convertToPHPValue($value, PlatformInterface $platform)
    {
        if ($value === null) {
            return;
        }

        if (is_string($value)) {
            $value = fopen('data://text/plain;base64,'.base64_encode($value), 'r');
        }

        if (!is_resource($value)) {
            throw TypeException::conversionToPHPFailed($value, $this->getName());
        }

        return $value;
    }
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]);
            }
        }
    }
896774
public function setDebugMode($value): self
    {
        if (is_string($value) || is_array($value)) {
            $value = static::detectDebugMode($value);
        } elseif (!is_bool($value)) {
            throw new InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value)));
        }
        $this->parameters['debugMode'] = $value;
        return $this;
    }
525158
public function setType($value)
    {
        if (!in_array($value, self::allowedRejectionTypes(), true)) {
            throw new DomainException(self::MSG_UNSUPPORTED_TYPE);
        }

        return $this->setAttribute('type', $value);
    }
559391
public function setValue(QtiDatatype $value = null)
    {
        if (Utils::isBaseTypeCompliant($this->getBaseType(), $value) && Utils::isCardinalityCompliant($this->getCardinality(), $value)) {
            $this->value = $value;
        } else {
            Utils::throwBaseTypeTypingError($this->baseType, $value);
        }
    }
359509
private void checkValueType(TemplateParam param, SoyValue value, TemplateNode node) {
    if (!TofuTypeChecks.isInstance(param.type(), value, node.getSourceLocation())) {
      // should this be a soydataexception?
      throw RenderException.createWithSource(
          "Parameter type mismatch: attempt to bind value '"
              + (value instanceof UndefinedData ? "(undefined)" : value)
              + "' (a "
              + value.getClass().getSimpleName()
              + ") to parameter '"
              + param.name()
              + "' which has a declared type of '"
              + param.type()
              + "'.",
          node);
    }
  }
966568
public function setType(?int $value) : Log
    {

        if ($this->data['type'] !== $value) {
            $this->data['type'] = $value;
            $this->setModified('type');
        }

        return $this;
    }
1008034
public void addTangoPipeListener(ITangoPipeListener listener,
                                     String attrName, String[] filters, boolean stateless) throws DevFailed {
        TangoPipe tangoPipe;
        String key = deviceName+"/"+attrName;
        if ((tangoPipe = tango_pipe_source.get(key)) == null) {
            tangoPipe = new TangoPipe(deviceProxy, attrName, filters);
            tango_pipe_source.put(key, tangoPipe);
        }

        synchronized (moni) {
            tangoPipe.addTangoPipeListener(listener, stateless);
        }
    }
1257192
@Override
    public void setValue(final Object value, final long time) throws DevFailed {
        this.setValue(value);
        this.setTime(time);
    }
863113
@Override
    public void updateValue() throws DevFailed {
        xlogger.entry(getName());
        // invoke on device
        // final Profiler profilerPeriod = new Profiler("read attribute " + name);
        // profilerPeriod.start("invoke");
        if (!config.getWritable().equals(AttrWriteType.READ) && behavior instanceof ISetValueUpdater) {
            // write value is managed by the user
            try {
                final AttributeValue setValue = ((ISetValueUpdater) behavior).getSetValue();
                if (setValue != null) {
                    writeValue = (AttributeValue) ((ISetValueUpdater) behavior).getSetValue().clone();
                    // get as array if necessary (for image)
                    writeValue.setValueWithoutDim(ArrayUtils.from2DArrayToArray(writeValue.getValue()));
                } else {
                    writeValue = null;
                }
            } catch (final CloneNotSupportedException e) {
                throw DevFailedUtils.newDevFailed(e);
            }
        }
        if (config.getWritable().equals(AttrWriteType.WRITE)) {
            if (writeValue == null) {
                readValue = new AttributeValue();
                readValue.setValue(AttributeTangoType.getDefaultValue(config.getType()));
            } else {
                readValue = writeValue;
            }
        } else {
            // attribute with a read part
            final AttributeValue returnedValue = behavior.getValue();
            this.updateValue(returnedValue);
        }

        // profilerPeriod.stop().print();
        xlogger.exit(getName());
    }
546001
public void addTangoUserListener(ITangoUserListener listener, String attrName, String[] filters, boolean stateless)
            throws DevFailed {
        TangoUser tangoUser;
        String key = deviceName+"/"+attrName;
        if ((tangoUser = tango_user_source.get(key)) == null) {
            tangoUser = new TangoUser(deviceProxy, attrName, filters);
            tango_user_source.put(key, tangoUser);
        }

        synchronized (moni) {
            tangoUser.addTangoUserListener(listener, stateless);
        }
    }