throw new InvalidComponentException("The device [" + this.identifier + "] contains the undefined group [" + this.groupNames[i] + "] - please check either [devices.xml] or [groups.xml].");
throw new InvalidComponentException("The device [" + this.identifier + "] contains the undefined group [" + groupName + "] - please check either [devices.xml] or [groups.xml].");
	public Device(Element definition, String identifier, String deviceName, Vendor vendor, DeviceGroupManager groupManager) 	throws InvalidComponentException {		super( vendor );		this.identifier = identifier;		this.name = deviceName;		this.vendorName = vendor.getIdentifier();				addCapability( NAME, this.name );		addCapability( VENDOR, this.vendorName );		addCapability( IDENTIFIER, this.identifier );				// load capabilities and features:		loadCapabilities( definition, this.identifier, "devices.xml" );				//add groups:		String groupsDefinition = definition.getChildTextTrim( "groups");		if (groupsDefinition != null) {			this.groupNames = TextUtil.splitAndTrim(groupsDefinition, ',');			this.groups = new DeviceGroup[ this.groupNames.length ];			for (int i = 0; i < this.groupNames.length; i++) {				DeviceGroup group = groupManager.getGroup( this.groupNames[i] );				if (group == null) {					throw new InvalidComponentException("The device [" + this.identifier + "] contains the undefined group [" + this.groupNames[i] + "] - please check either [devices.xml] or [groups.xml].");				}				this.groups[i] = group;				addComponent(group);			}		} else {			this.groupNames = new String[0];			this.groups = new DeviceGroup[0];		}				// set specific features:		// set api-support:		this.supportedApisString = getCapability( JAVA_PACKAGE );		if (this.supportedApisString != null) {			//System.out.println(this.identifier +  " found apis: [" + supportedApisStr + "].");			String[] apis = TextUtil.splitAndTrim( this.supportedApisString, ',' );			for (int i = 0; i < apis.length; i++) {				String api = apis[i].toLowerCase();				addFeature( "api." + api );			}			this.supportedApis = apis;		}		// set midp-version:		String midp = getCapability( JAVA_PLATFORM );		if (midp == null) {			throw new InvalidComponentException("The device [" + this.identifier + "] does not define the needed element [" + JAVA_PLATFORM + "].");		}		midp = midp.toUpperCase();		if (midp.startsWith("MIDP/1.")) {			addFeature( "midp1");			this.midpVersion = MIDP_1;		} else if (midp.startsWith("MIDP/2.")) {			addFeature( "midp2");			this.midpVersion = MIDP_2;		}		String supportsPolishGuiText = definition.getAttributeValue("supportsPolishGui");		if (supportsPolishGuiText != null) {			supportsPolishGuiText = supportsPolishGuiText.toLowerCase();			this.supportsPolishGui = "true".equals( supportsPolishGuiText ) 										   || "yes".equals( supportsPolishGuiText );		} else {			// basically assume that any device supports the polish GUI:			this.supportsPolishGui = true;			// when a device has the BitsPerPixel capability defined,			// it needs to have at least 8 bits per pixel (= 2^8 == 256 colors)			String bitsPerPixelDef = getCapability( BITS_PER_PIXEL );			if (bitsPerPixelDef != null) {				int bitsPerPixel = Integer.parseInt( bitsPerPixelDef );				this.supportsPolishGui = (bitsPerPixel >= POLISH_GUI_MIN_BITS_PER_PIXEL);			}			// when the device has the heap size defined,			// it needs to have a minimum heap size of 500 kb:			String heapSizeStr = getCapability( HEAP_SIZE );			if (heapSizeStr != null) {				this.supportsPolishGui = POLISH_GUI_MIN_HEAP_SIZE.matches(heapSizeStr);			}		}		if (this.supportsPolishGui) {			addFeature( SUPPORTS_POLISH_GUI );		}	}