BundleData { @SuppressWarnings("unchecked") public static BundleData from(CompositeData compositeData) throws IllegalArgumentException { if (compositeData == null) { throw new IllegalArgumentException("Argument compositeData cannot be null"); } if (!compositeData.getCompositeType().equals(BUNDLE_TYPE)) { throw new IllegalArgumentException("Invalid CompositeType [" + compositeData.getCompositeType() + "]"); } BundleData bundleData = new BundleData(); bundleData.exportedPackages = (String[]) compositeData.get(EXPORTED_PACKAGES); bundleData.fragment = (Boolean) compositeData.get(FRAGMENT); bundleData.fragments = toPrimitive((Long[]) compositeData.get(FRAGMENTS)); bundleData.hosts = toPrimitive((Long[]) compositeData.get(HOSTS)); bundleData.identifier = (Long) compositeData.get(IDENTIFIER); bundleData.importedPackages = (String[]) compositeData.get(IMPORTED_PACKAGES); bundleData.lastModified = (Long) compositeData.get(LAST_MODIFIED); bundleData.location = (String) compositeData.get(LOCATION); bundleData.persistentlyStarted = (Boolean) compositeData.get(PERSISTENTLY_STARTED); bundleData.registeredServices = toPrimitive((Long[]) compositeData.get(REGISTERED_SERVICES)); bundleData.removalPending = (Boolean) compositeData.get(REMOVAL_PENDING); bundleData.required = (Boolean) compositeData.get(REQUIRED); bundleData.requiredBundles = toPrimitive((Long[]) compositeData.get(REQUIRED_BUNDLES)); bundleData.requiringBundles = toPrimitive((Long[]) compositeData.get(REQUIRING_BUNDLES)); bundleData.servicesInUse = toPrimitive((Long[]) compositeData.get(SERVICES_IN_USE)); bundleData.bundleStartLevel = (Integer) compositeData.get(START_LEVEL); bundleData.state = (String) compositeData.get(STATE); bundleData.symbolicName = (String) compositeData.get(SYMBOLIC_NAME); bundleData.version = (String) compositeData.get(VERSION); TabularData headerTable = (TabularData) compositeData.get(HEADERS); Collection<CompositeData> headerData = (Collection<CompositeData>) headerTable.values(); for (CompositeData headerRow : headerData) { bundleData.headers.add(Header.from(headerRow)); } return bundleData; } private  BundleData();  BundleData(BundleContext localBundleContext, Bundle bundle, PackageAdmin packageAdmin, StartLevel startLevel); CompositeData toCompositeData(); CompositeData toCompositeData(Collection<String> itemNames); @SuppressWarnings("unchecked") static BundleData from(CompositeData compositeData); String[] getExportedPackages(); boolean isFragment(); long[] getFragments(); List<Header> getHeaders(); long[] getHosts(); long getIdentifier(); String[] getImportedPackages(); long getLastModified(); String getLocation(); boolean isPersistentlyStarted(); long[] getRegisteredServices(); boolean isRemovalPending(); boolean isRequired(); long[] getRequiredBundles(); long[] getRequiringBundles(); long[] getServicesInUse(); int getBundleStartLevel(); String getState(); String getSymbolicName(); String getVersion();  }
@Test public void testHeaderFromCompositeData() throws Exception { CompositeData compositeData = new CompositeDataSupport(HEADER_TYPE, new String[] { KEY, VALUE } , new String [] { "c", "d" }); Header header = Header.from(compositeData); assertEquals("c", header.getKey()); assertEquals("d", header.getValue()); }