Append a report to {@code builder} which contains information, per Kernel subclass, on which device is currently being used for the
kernel class, and which (if any) devices failed to execute a given Kernel.
171805
public void reportDeviceUsage(StringBuilder builder, boolean withProfilingInfo) {
      builder.append("Device Usage by Kernel Subclass");
      if (withProfilingInfo) {
         builder.append(" (showing mean elapsed times in milliseconds)");
      }
      builder.append("\n\n");
      for (PreferencesWrapper wrapper : preferences.values()) {
         KernelPreferences preferences = wrapper.getPreferences();
         Class<? extends Kernel> klass = wrapper.getKernelClass();
         KernelProfile profile = withProfilingInfo ? profiles.get(klass) : null;
         builder.append(klass.getName()).append(":\n\tusing ").append(preferences.getPreferredDevice(null).getShortDescription());
         List<Device> failedDevices = preferences.getFailedDevices();
         if (failedDevices.size() > 0) {
            builder.append(", failed devices = ");
            for (int i = 0; i < failedDevices.size(); ++i) {
               builder.append(failedDevices.get(i).getShortDescription());
               if (i < failedDevices.size() - 1) {
                  builder.append(" | ");
               }
            }
         }
         if (profile != null) {
            builder.append("\n");
            int row = 0;
            for (KernelDeviceProfile deviceProfile : profile.getDeviceProfiles()) {
               if (row == 0) {
                  builder.append(deviceProfile.getTableHeader()).append("\n");
               }
               builder.append(deviceProfile.getAverageAsTableRow()).append("\n");
               ++row;
            }
         }
         builder.append("\n");
      }
   }
1065955
private void addSubDestroyMethods(TypeSpec.Builder classBuilder) {
        MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("finalize")
                .addModifiers(Modifier.PROTECTED)
                .returns(TypeName.VOID)
                .addException(Throwable.class)
                .addStatement("super.finalize()")
                .addAnnotation(Override.class);
        classBuilder.addMethod(methodBuilder.build());

        methodBuilder = MethodSpec.methodBuilder("destroyStub")
                .addModifiers(Modifier.PUBLIC)
                .addAnnotation(Override.class)
                .returns(TypeName.VOID)
                .beginControlFlow("try")
                .addStatement("finalize()")
                .addStatement("this.attachInterface(null, DESCRIPTOR)")
                .addStatement("binderWrapper.binder = null")
                .endControlFlow()
                .beginControlFlow("catch (Throwable t)")
                .endControlFlow()
                .addStatement("serviceImpl = null");

        classBuilder.addMethod(methodBuilder.build());
    }
690520
void putDevice(Context context, boolean collectDeviceID) {
    Device device = new Device();
    String identifier = collectDeviceID ? getDeviceId(context) : traits().anonymousId();
    device.put(Device.DEVICE_ID_KEY, identifier);
    device.put(Device.DEVICE_MANUFACTURER_KEY, Build.MANUFACTURER);
    device.put(Device.DEVICE_MODEL_KEY, Build.MODEL);
    device.put(Device.DEVICE_NAME_KEY, Build.DEVICE);
    put(DEVICE_KEY, device);
  }
858560
public void build(final Class<?> clazz, final Field field, final DeviceImpl device, final Object businessObject)
            throws DevFailed {
        xlogger.entry();
        BuilderUtils.checkStatic(field);
        Method getter;
        final String stateName = field.getName();
        final String getterName = BuilderUtils.GET + stateName.substring(0, 1).toUpperCase(Locale.ENGLISH)
                + stateName.substring(1);
        try {
            getter = clazz.getMethod(getterName);
        } catch (final NoSuchMethodException e) {
            throw DevFailedUtils.newDevFailed(e);
        }
        if (getter.getParameterTypes().length != 0) {
            throw DevFailedUtils.newDevFailed(DevFailedUtils.TANGO_BUILD_FAILED, getter + " must not have a parameter");
        }

        logger.debug("Has an status : {}", field.getName());
        if (getter.getReturnType() != String.class) {
            throw DevFailedUtils.newDevFailed(DevFailedUtils.TANGO_BUILD_FAILED, getter + " must have a return type of  "
                    + String.class);
        }
        Method setter;
        final String setterName = BuilderUtils.SET + stateName.substring(0, 1).toUpperCase(Locale.ENGLISH)
                + stateName.substring(1);
        try {
            setter = clazz.getMethod(setterName, String.class);
        } catch (final NoSuchMethodException e) {
            throw DevFailedUtils.newDevFailed(e);
        }
        device.setStatusImpl(new StatusImpl(businessObject, getter, setter));
        final Status annot = field.getAnnotation(Status.class);
        if (annot.isPolled()) {
            device.addAttributePolling(DeviceImpl.STATUS_NAME, annot.pollingPeriod());
        }
        xlogger.exit();
    }
428184
@SuppressWarnings("unchecked")
    public <T> ProcessorBuilder<T> register(final Class<T> type, final ProcessorBuilder<T> builder) {
        return (ProcessorBuilder<T>)this.builderMap.put(type, builder);
    }
775378
public DevicePipe writeReadPipe(String pipeName, PipeBlob pipeBlob) throws DevFailed {
        return writeReadPipe(new DevicePipe(pipeName, pipeBlob));
    }
241211
public void write_attribute(final DeviceProxy deviceProxy, final DeviceAttribute deviceAttribute)
	    	throws DevFailed {
		checkIfTango(deviceProxy, "write_attribute");
		try {
	    	final DeviceAttribute[] array = { deviceAttribute };
	    	write_attribute(deviceProxy, array);
		} catch (final NamedDevFailedList e) {
	    	final NamedDevFailed namedDF = e.elementAt(0);
	    	throw new DevFailed(namedDF.err_stack);
		} catch (final Exception e) {
	    	throw_dev_failed(deviceProxy, e, "device.write_attributes()", false);
		}
    }
786657
void addToRelockList(final DeviceProxy dev, final int validity) throws DevFailed {
        // Check if it is the first relock
        if (relockMap == null) {
            // Create hash table for admin devices object
            relockMap = new Hashtable<String, LockedDeviceAmin>();

            // Create a thread to unlock all devices at exit
            Runtime.getRuntime().addShutdownHook(new ShutdownThread());

            // Create thread fo garbage callector call preiodicaly
            new GarbageThread().start();
        }
        // Check if admin device already exists.
        String adm;
        try {
            adm = dev.adm_name();
        } catch (final DevFailed e) {
            // Give up
            return;
        }
        final LockedDevice ld = new LockedDevice(dev.get_name(), validity);
        LockedDeviceAmin lda;
        if (!relockMap.containsKey(adm)) {
            // if not, crate and add th the list
            lda = new LockedDeviceAmin(adm, ld);
            lda.start();
            relockMap.put(adm, lda);
        } else {
            lda = relockMap.get(adm);
            lda.add(ld);
        }
    }
855231
@Override
    public void unexportDevices() throws DevFailed {
        xlogger.entry();
        final List<DeviceClassBuilder> clazzToRemove = new ArrayList<DeviceClassBuilder>();
        for (final DeviceClassBuilder clazz : deviceClassList) {
            if (!clazz.getDeviceClass().equals(AdminDevice.class)) {
                for (final DeviceImpl device : clazz.getDeviceImplList()) {
                    logger.debug("unexport device {}", device.getName());
                    ORBUtils.unexportDevice(device);
                }
                clazz.clearDevices();
                clazzToRemove.add(clazz);
            }
        }
        for (final DeviceClassBuilder deviceClassBuilder : clazzToRemove) {
            deviceClassList.remove(deviceClassBuilder);
        }
        // unregisterServer();
        // deviceClassList.clear();
        xlogger.exit();
    }
373045
private void buildReport(Context context) {
        try {
            buildBaseReport();
            buildApplicationData(context);
            buildDeviceData(context);
            buildLog();
            report.put("application", app);
            report.put("device", device);
            report.put("log", logs);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
320604
private void append(final StringBuilder builder, final String string,
            final String separator) {
        if (string != null) {
            builder.append(string);
        }
        builder.append(separator);
    }
1280737
private static void exportDeviceWithDatabase(final DeviceImpl dev, final String hostName, final String pid)
            throws DevFailed {
        XLOGGER.entry(dev.getName());

        final ORB orb = ORBManager.getOrb();
        // Activate the CORBA object incarnated by the Java object
        final Device_5 d = dev._this(orb);

        // Get the object id and store it

        final POA poa = ORBManager.getPoa();

        try {
            dev.setObjId(poa.reference_to_id(d));
        } catch (final WrongAdapter e) {
            throw DevFailedUtils.newDevFailed(e);
        } catch (final WrongPolicy e) {
            throw DevFailedUtils.newDevFailed(e);
        }

        final DeviceExportInfo info = new DeviceExportInfo(dev.getName(), orb.object_to_string(d), hostName,
                Integer.toString(DeviceImpl.SERVER_VERSION), pid, dev.getClassName());
        DatabaseFactory.getDatabase().exportDevice(info);

        XLOGGER.exit();
    }
608014
private synchronized void add(final String... attributes) throws DevFailed {
        userAttributesNames = new String[attributes.length];
        devices = new DeviceProxy[attributes.length];
        int i = 0;
        for (final String attributeName : attributes) {
            final String deviceName = TangoUtil.getfullDeviceNameForAttribute(attributeName)
                    .toLowerCase(Locale.ENGLISH);
            final String fullAttribute = TangoUtil.getfullAttributeNameForAttribute(attributeName).toLowerCase(
                    Locale.ENGLISH);
            userAttributesNames[i] = fullAttribute;
            try {
                final DeviceProxy device = ProxyFactory.getInstance().createDeviceProxy(deviceName);
                devices[i++] = device;
                if (!devicesMap.containsKey(deviceName)) {
                    devicesMap.put(deviceName, device);
                }
            } catch (final DevFailed e) {
                if (throwExceptions) {
                    throw e;
                } else {
                    devices[i++] = null;
                    if (!devicesMap.containsKey(deviceName)) {
                        devicesMap.put(deviceName, null);
                    }
                }
            }
            final String attribute = fullAttribute.split("/")[3];
            if (!attributesMap.containsKey(deviceName)) {
                final List<String> attributesNames = new ArrayList<String>();
                attributesNames.add(attribute);
                attributesMap.put(deviceName, attributesNames);
            } else {
                attributesMap.get(deviceName).add(attribute);
            }
        }
    }
166681
def attach_kernel_driver(self, interface):
        
        """
        self._ctx.managed_open()
        self._ctx.backend.attach_kernel_driver(
            self._ctx.handle,
            interface)
729014
public UnitMeta appendDescription(String descriptionToBeAppended) {
        if (getDescription() != null) {
            setDescription(getDescription().concat(descriptionToBeAppended));
        } else {
            setDescription(descriptionToBeAppended);
        }
        return this;
    }
1270276
public void setDeviceStatusDetails(java.util.Collection<DeviceStatusDetail> deviceStatusDetails) {
        if (deviceStatusDetails == null) {
            this.deviceStatusDetails = null;
            return;
        }

        this.deviceStatusDetails = new java.util.ArrayList<DeviceStatusDetail>(deviceStatusDetails);
    }
1259922
public void add_device(Database database, String deviceName, String classname, String serverName)
            throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        DbDevInfo devinfo = new DbDevInfo(deviceName, classname, serverName);
        DeviceData argIn = new DeviceData();
        argIn.insert(devinfo.toStringArray());
        command_inout(database, "DbAddDevice", argIn);
        //System.out.println(devinfo.name + " created");
    }