Add attribute. Only if not already exists on device.

@param behavior
@throws DevFailed
433343
public void addAttribute(final IAttributeBehavior behavior) throws DevFailed {
        final AttributeConfiguration configuration = behavior.getConfiguration();
        final String attributeName = configuration.getName();
        xlogger.entry("adding dynamic attribute {}", attributeName);
        if (behavior instanceof ForwardedAttribute) {
            // init attribute with either the attribute property value, or the value defined in its constructor
            final ForwardedAttribute att = (ForwardedAttribute) behavior;
            final String deviceName = deviceImpl.getName();
            final String rootAttributeName = behavior.getConfiguration().getAttributeProperties()
                    .loadAttributeRootName(deviceName, attributeName);
            if (rootAttributeName == null || rootAttributeName.isEmpty()
                    || rootAttributeName.equalsIgnoreCase(Constants.NOT_SPECIFIED)) {
                att.init(deviceName);
                // persist root attribute name in tango db
                behavior.getConfiguration().getAttributeProperties()
                        .persistAttributeRootName(deviceName, attributeName);
            } else {
                // use attribute property
                att.init(deviceName, rootAttributeName);
            }
            // check if this attribute is already created
            final String lower = att.getRootName().toLowerCase(Locale.ENGLISH);
            if (forwardedAttributes.contains(lower)) {
                throw DevFailedUtils.newDevFailed(ExceptionMessages.FWD_DOUBLE_USED,
                        "root attribute already used in this device");
            } else {
                forwardedAttributes.add(lower);
            }
        } else {
            // set default properties
            final AttributePropertiesImpl prop = configuration.getAttributeProperties();
            if (prop.getLabel().isEmpty()) {
                prop.setLabel(configuration.getName());
            }
            if (prop.getFormat().equals(Constants.NOT_SPECIFIED)) {
                prop.setDefaultFormat(configuration.getScalarType());
            }
        }
        final AttributeImpl attrImpl = new AttributeImpl(behavior, deviceImpl.getName());
        attrImpl.setStateMachine(behavior.getStateMachine());
        deviceImpl.addAttribute(attrImpl);
        dynamicAttributes.put(attributeName.toLowerCase(Locale.ENGLISH), attrImpl);
        deviceImpl.pushInterfaceChangeEvent(false);
        if (configuration.isPolled() && configuration.getPollingPeriod() > 0) {
            deviceImpl.addAttributePolling(attributeName, configuration.getPollingPeriod());
        }
        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;
	}
    }
1113590
private void manageExceptions(final String method_name) throws DevFailed {
	if (attrval.err_list != null) {
	    if (attrval.err_list.length > 0) {
		throw new WrongData(attrval.err_list);
	    }
	}
	if (attrval.quality == AttrQuality.ATTR_INVALID) {
	    Except.throw_wrong_data_exception("AttrQuality_ATTR_INVALID",
		    "Attribute quality factor is INVALID", "DeviceAttribute."
			    + method_name + "()");
	}
    }
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;
	}
    }
474006
public void update() throws DevFailed {
	xlogger.entry();
	final Map<String, String[]> property = PropertiesUtils.getDeviceProperties(deviceName);

	if (property != null && property.size() != 0) {
	    try {
		propertyMethod.invoke(businessObject, property);
	    } catch (final IllegalArgumentException e) {
		throw DevFailedUtils.newDevFailed(e);
	    } catch (final IllegalAccessException e) {
		throw DevFailedUtils.newDevFailed(e);
	    } catch (final SecurityException e) {
		throw DevFailedUtils.newDevFailed(e);
	    } catch (final InvocationTargetException e) {
		throw DevFailedUtils.newDevFailed(e);
	    }
	}
	xlogger.exit();
    }
569942
public void delete_device_attribute(String devname, String attname) throws DevFailed {
		databaseDAO.delete_device_attribute(this, devname, attname);
	}
673617
public DeviceAttribute[] write_read_attribute(
                final DeviceProxy deviceProxy,
			    final DeviceAttribute[] deviceAttributes) throws DevFailed {
        return write_read_attribute(deviceProxy, deviceAttributes, new String[0]);
    }
1152362
public void addTangoPeriodicListener(ITangoPeriodicListener listener, String attrName, boolean stateless)
            throws DevFailed {
        addTangoPeriodicListener(listener, attrName, new String[0], stateless);
    }
1340171
public void putDevicePipeProperty(String deviceName, ArrayList<DbPipe> dbPipes) throws DevFailed {
        for (DbPipe dbPipe : dbPipes)
            databaseDAO.putDevicePipeProperty(this, deviceName, dbPipe);
    }
29630
public void putDevicePipeProperty(Database database, String deviceName, DbPipe dbPipe) throws DevFailed {
        DeviceData argIn = new DeviceData();
        String[]    array = ApiUtil.toStringArray(deviceName, dbPipe);
        argIn.insert(array);
        database.command_inout("DbPutDevicePipeProperty", argIn);
    }
1123996
@Override
    public void setAttributeProperties(final String deviceName, final String attributeName,
            final Map<String, String[]> properties) throws DevFailed {
        final DeviceData argin = new DeviceData();
        final List<String> args = new ArrayList<String>();
        args.add(deviceName);
        args.add(Integer.toString(1)); // attribute number
        args.add(attributeName);
        args.add(Integer.toString(properties.size())); // property number
        for (final Map.Entry<String, String[]> entry : properties.entrySet()) {
            args.add(entry.getKey());
            final String[] propValues = entry.getValue();
            args.add(Integer.toString(propValues.length));
            for (final String propValue : propValues) {
                args.add(propValue);
            }
        }
        argin.insert(args.toArray(new String[args.size()]));
        database.command_inout("DbPutDeviceAttributeProperty2", argin);
    }
881980
public void poll_attribute(final DeviceProxy deviceProxy, final String attname, final int period)
	    throws DevFailed {
    	poll_object(deviceProxy, attname, "attribute", period);
    }
452547
public void remove_attribute(final String attname) throws DevFailed {
	// Remove property in database
	if (Util._UseDb) {
	    final DeviceProxy dev = new DeviceProxy(device_name);
	    final DbAttribute da = dev.get_attribute_property(attname);
	    dev.delete_attribute_property(da);

	}
	dev_attr.remove_attribute(attname);
    }
1101138
public void write_attribute_asynch(DeviceAttribute[] attribs, CallBack cb) throws DevFailed {
        deviceProxyDAO.write_attribute_asynch(this, attribs, cb);
    }
112194
public synchronized void addAttribute(final AttributeImpl attribute) throws DevFailed {
        // add attribute only if it doesn't exists
        AttributeImpl result = null;
        for (final AttributeImpl attr : attributeList) {
            if (attr.getName().equalsIgnoreCase(attribute.getName())) {
                result = attribute;
                break;
            }
        }
        if (result == null) {
            attributeList.add(attribute);
            // set default polling configuration
            if (attrPollRingDepth.containsKey(attribute.getName().toLowerCase(Locale.ENGLISH))) {
                attribute.setPollRingDepth(attrPollRingDepth.get(attribute.getName().toLowerCase(Locale.ENGLISH)));
            } else {
                attribute.setPollRingDepth(pollRingDepth);
            }
        }
    }
257719
public void removeAttribute(final String attributeName) throws DevFailed {
        final AttributeImpl toRemove = dynamicAttributes.get(attributeName.toLowerCase(Locale.ENGLISH));
        if (toRemove == null)
            throw DevFailedUtils.newDevFailed("API_AttributeNotFound", "Attribute \'" + attributeName + "\' not found");
        if (toRemove.getBehavior() instanceof ForwardedAttribute) {
            final ForwardedAttribute att = (ForwardedAttribute) toRemove.getBehavior();
            final String lower = att.getRootName().toLowerCase(Locale.ENGLISH);
            forwardedAttributes.remove(lower);
        }
        deviceImpl.removeAttribute(toRemove);
        dynamicAttributes.remove(attributeName);
        deviceImpl.pushInterfaceChangeEvent(false);
    }
329846
public static void insertFromInteger(final Integer integerValue,
	    final DeviceAttribute deviceAttributeWritten) throws DevFailed {

	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.insertFromInteger(Integer 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.insertFromInteger(Integer 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:
	    try {
		deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue()));
	    } catch (final org.omg.CORBA.BAD_PARAM badParam) {
		Except.throw_exception("TANGO_WRONG_DATA_ERROR", "Cannot sent"
			+ integerValue.intValue() + "for input Tango_DEV_STATE type",
			"AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)");
	    }
	    break;
	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceAttributeWritten.getType() + " not supported",
		    "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)");
	    break;
	}
    }