@Test public void testFindProfile() throws ConfigurationException { DeviceProfile profile = null; DeviceProfileManager manager = new DeviceProfileManager(); manager.updated( "1", getMockedProperties( "SUMP", "\"Sump\"" ) ); manager.updated( "2", getMockedProperties( "OLS", "\"*\", \"Open Logic Sniffer v1.01\"" ) ); manager.updated( "3", getMockedProperties( "BP", "\"BPv3\"" ) ); manager.updated( "4", getMockedProperties( "SHRIMP", "\"Shrimp1.0\"" ) ); profile = manager.findProfile( "Shrimp1.0" ); assertNotNull( "Shrimp", profile ); assertEquals( "SHRIMP", profile.getType() ); profile = manager.findProfile( "Open Logic Sniffer v1.01" ); assertNotNull( "OLS", profile ); assertEquals( "OLS", profile.getType() ); profile = manager.findProfile( "Sump" ); assertNotNull( "Sump", profile ); assertEquals( "SUMP", profile.getType() ); profile = manager.findProfile( "BPv3" ); assertNotNull( "BP", profile ); assertEquals( "BP", profile.getType() ); profile = manager.findProfile( "My Unnamed Device" ); assertNotNull( "Wildcard", profile ); assertEquals( "OLS", profile.getType() ); }
public DeviceProfile findProfile( final String aIdentifier ) { final Collection<DeviceProfile> allProfiles = getProfiles(); boolean allowWildcardMatch = false; for ( int tries = 0; tries < 2; tries++ ) { for ( DeviceProfile profile : allProfiles ) { final String[] metadataKeys = profile.getDeviceMetadataKeys(); if ( matches( aIdentifier, allowWildcardMatch, metadataKeys ) ) { return profile; } } allowWildcardMatch = true; } return null; }
DeviceProfileManager implements ManagedServiceFactory { public DeviceProfile findProfile( final String aIdentifier ) { final Collection<DeviceProfile> allProfiles = getProfiles(); boolean allowWildcardMatch = false; for ( int tries = 0; tries < 2; tries++ ) { for ( DeviceProfile profile : allProfiles ) { final String[] metadataKeys = profile.getDeviceMetadataKeys(); if ( matches( aIdentifier, allowWildcardMatch, metadataKeys ) ) { return profile; } } allowWildcardMatch = true; } return null; } }
DeviceProfileManager implements ManagedServiceFactory { public DeviceProfile findProfile( final String aIdentifier ) { final Collection<DeviceProfile> allProfiles = getProfiles(); boolean allowWildcardMatch = false; for ( int tries = 0; tries < 2; tries++ ) { for ( DeviceProfile profile : allProfiles ) { final String[] metadataKeys = profile.getDeviceMetadataKeys(); if ( matches( aIdentifier, allowWildcardMatch, metadataKeys ) ) { return profile; } } allowWildcardMatch = true; } return null; } DeviceProfileManager(); }
DeviceProfileManager implements ManagedServiceFactory { public DeviceProfile findProfile( final String aIdentifier ) { final Collection<DeviceProfile> allProfiles = getProfiles(); boolean allowWildcardMatch = false; for ( int tries = 0; tries < 2; tries++ ) { for ( DeviceProfile profile : allProfiles ) { final String[] metadataKeys = profile.getDeviceMetadataKeys(); if ( matches( aIdentifier, allowWildcardMatch, metadataKeys ) ) { return profile; } } allowWildcardMatch = true; } return null; } DeviceProfileManager(); @Override void deleted( final String aPid ); DeviceProfile findProfile( final String aIdentifier ); DeviceProfile getDefaultProfile(); @Override String getName(); DeviceProfile getProfile( final String aType ); List<DeviceProfile> getProfiles(); int getSize(); @Override @SuppressWarnings( "rawtypes" ) void updated( final String aPid, final Dictionary aProperties ); }
DeviceProfileManager implements ManagedServiceFactory { public DeviceProfile findProfile( final String aIdentifier ) { final Collection<DeviceProfile> allProfiles = getProfiles(); boolean allowWildcardMatch = false; for ( int tries = 0; tries < 2; tries++ ) { for ( DeviceProfile profile : allProfiles ) { final String[] metadataKeys = profile.getDeviceMetadataKeys(); if ( matches( aIdentifier, allowWildcardMatch, metadataKeys ) ) { return profile; } } allowWildcardMatch = true; } return null; } DeviceProfileManager(); @Override void deleted( final String aPid ); DeviceProfile findProfile( final String aIdentifier ); DeviceProfile getDefaultProfile(); @Override String getName(); DeviceProfile getProfile( final String aType ); List<DeviceProfile> getProfiles(); int getSize(); @Override @SuppressWarnings( "rawtypes" ) void updated( final String aPid, final Dictionary aProperties ); static final String SERVICE_PID; }