public CompositeData toCompositeData()

in jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleData.java [237:315]


    public CompositeData toCompositeData(Collection<String> itemNames) {
        Map<String, Object> items = new HashMap<String, Object>();
        items.put(IDENTIFIER, this.identifier);

        if (itemNames.contains(EXPORTED_PACKAGES))
            items.put(EXPORTED_PACKAGES, this.exportedPackages);

        if (itemNames.contains(FRAGMENT))
            items.put(FRAGMENT, this.fragment);

        if (itemNames.contains(FRAGMENTS))
            items.put(FRAGMENTS, toLong(this.fragments));

        if (itemNames.contains(HOSTS))
            items.put(HOSTS, toLong(this.hosts));

        if (itemNames.contains(IMPORTED_PACKAGES))
            items.put(IMPORTED_PACKAGES, this.importedPackages);

        if (itemNames.contains(LAST_MODIFIED))
            items.put(LAST_MODIFIED, this.lastModified);

        if (itemNames.contains(LOCATION))
            items.put(LOCATION, this.location);

        if (itemNames.contains(PERSISTENTLY_STARTED))
            items.put(PERSISTENTLY_STARTED, this.persistentlyStarted);

        if (itemNames.contains(REGISTERED_SERVICES))
            items.put(REGISTERED_SERVICES, toLong(this.registeredServices));

        if (itemNames.contains(REMOVAL_PENDING))
            items.put(REMOVAL_PENDING, this.removalPending);

        if (itemNames.contains(REQUIRED))
            items.put(REQUIRED, this.required);

        if (itemNames.contains(REQUIRED_BUNDLES))
            items.put(REQUIRED_BUNDLES, toLong(this.requiredBundles));

        if (itemNames.contains(REQUIRING_BUNDLES))
            items.put(REQUIRING_BUNDLES, toLong(this.requiringBundles));

        if (itemNames.contains(SERVICES_IN_USE))
            items.put(SERVICES_IN_USE, toLong(this.servicesInUse));

        if (itemNames.contains(START_LEVEL))
            items.put(START_LEVEL, this.bundleStartLevel);

        if (itemNames.contains(STATE))
            items.put(STATE, this.state);

        if (itemNames.contains(SYMBOLIC_NAME))
            items.put(SYMBOLIC_NAME, this.symbolicName);

        if (itemNames.contains(VERSION))
            items.put(VERSION, this.version);

        if (itemNames.contains(HEADERS)) {
            TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
            for (Header header : this.headers) {
                headerTable.put(header.toCompositeData());
            }
            items.put(HEADERS, headerTable);
        }

        String[] allItemNames = BUNDLE_TYPE.keySet().toArray(new String [] {});
        Object[] itemValues = new Object[allItemNames.length];
        for (int i=0; i < allItemNames.length; i++) {
            itemValues[i] = items.get(allItemNames[i]);
        }

        try {
            return new CompositeDataSupport(BUNDLE_TYPE, allItemNames, itemValues);
        } catch (OpenDataException e) {
            throw new IllegalStateException("Failed to create CompositeData for BundleData [" + this.identifier
                    + "]", e);
        }
    }