The <deviceRequirements> Section
Select your target devices in the <deviceRequirements> section!
Select the devices that you want to target in the <deviceRequirements> section. You can use any device capabilities for choosing your target devices:
<deviceRequirements if="test"> <requirement name="Identifier" value="Nokia/N95, Sony-Ericsson/K850i" /> </deviceRequirements> <deviceRequirements unless="test"> <requirement name="Term" value="polish.api.mmapi and (polish.midp2 or polish.midp3)" /> </deviceRequirements>
In this example two alternative device-selections are defined - when the test-property is
set to true (by defining it with <property name="test" value="true" />),
only the upper <deviceRequirements> element is used and the second
<deviceRequirements> element is ignored. The actual requirements are defined
with the sub elements <requirement>. Without any clarification, all listed
requirements need to be fulfilled by the device to be selected.
There are <or>, <and>, <not>
and <xor> elements, which can be used to
define the requirements very flexible.
Supported Attributes
Following attributes are supported by the device-requirements section:
| deviceRequirements-Attribute | Required | Explanation |
|---|---|---|
| if | No | The name of the Ant-property which needs to be "true" or "yes" to use this <deviceRequirements>. |
| unless | No | The name of the Ant-property which needs to be "false" or "no" to use this <deviceRequirements>. |
Following nested elements can be used in a <deviceRequirements> element:
| deviceRequirements element | Required | Explanation |
|---|---|---|
| requirement | Yes | The requirement which needs to be fulfilled by the device. |
| and | No | Series of requirements, of which all need to be fulfilled. |
| or | No | Series of requirements, of which at least one needs to be fulfilled. |
| xor | No | Series of requirements, of which one needs to be fulfilled. |
| not | No | Series of requirements, of which none must be fulfilled. |
The actual work is done by the <requirement> element:
| requirement-Attribute | Required | Explanation |
|---|---|---|
| name | Yes | The name of the needed capability, e.g. "BitsPerPixel". |
| value | Yes | The needed value of the capability, e.g. "4+" for a color depth or at least 4 bits per pixel. |
| type | No | The class which controls this requirement. Either a class which extends the
de.enough.polish.ant.requirements.Requirement class, or one of the base types
"Size", "Int", "String", "Version" or "Memory".
Example:
<requirement name="MaxMidletSize" value="100+ kb" type="Memory" /> |
The <or>, <and>, <not> and <xor> elements can be nested in any manner:
<deviceRequirements> <requirement name="BitsPerPixel" value="4+" /> <or> <requirement name="JavaPackage" value="nokia-ui, mmapi" /> <and> <requirement name="JavaPackage" value="mmapi" /> <requirement name="JavaPlatform" value="MIDP/2.0+" /> </and> </or> </deviceRequirements>
In this example each supported device must have a color depth of at least 4 bits per pixel. Additionally the device needs to support either the Nokia-UI-API and the Mobile Media-API (mmapi), or the Mobile Media-API and the MIDP/2.0 platform.
Instead of using such nested requirements, you can also use the "Term" requirement that allows you to select devices with the same power like the #if preprocessing directive. The following example includes the very same requirements like the above one - but only one "Term" requirement is used:
<deviceRequirements> <requirement name="Term" value="(polish.BitsPerPixel >= 4) and ((polish.api.nokia-ui and polish.api.mmapi) or (polish.api.mmapi and polish.midp2))" /> </deviceRequirements>
J2ME Polish provides several requirements that can be used "out of the box":
| requirement-name | Explanation |
|---|---|
| BitsPerPixel | Needed color depth of the device: 1 is monochrome, 4 are 16 colors, 8 = 256 colors, 16 = 65.536 colors, 24 = 16.777.216 colors. Example: "4+" for at least 4 bits per pixel or "16" for precisely 16 bits per pixel.
<requirement name="BitsPerPixel" value="4+" /> |
| ScreenSize | Required width and height of the display, e.g. "120+ x 100+" for a resolution of at least 120 pixels horizontally and 100 pixels vertically.
<requirement name="ScreenSize" value="120+ x 100+" /> |
| ScreenWidth | The needed horizontal resolution of the display , e.g. "120+" for at least 120 pixels.
<requirement name="ScreenWidth" value="120+" /> |
| ScreenHeight | The needed vertical resolution of the display, e.g. "100+" for at least 100 pixels.
<requirement name="ScreenHeight" value="100+" /> |
| CanvasSize | Required width and height of the MIDP-Canvas. Some devices do not allow the usage of the complete screen.
<requirement name="CanvasSize" value="120+ x 100+" /> |
| JavaPlatform | The needed platform, e.g. "MIDP/1.0" or "MIDP/2.0+".
<requirement name="JavaPlatform" value="MIDP/2.0+" />
|
| JavaConfiguration | The needed platfconfiguration, e.g. "CLDC/1.1+".
<requirement name="JavaConfiguration" value="CLDC/1.1+" />
|
| JavaPackage | Needed APIs, e.g. "nokia-ui, mmapi":
<requirement name="JavaPackage" value="nokia-ui, mmapi" />
|
| JavaProtocol | Needed data exchange protocols, e.g. "serial, socket":
<requirement name="JavaProtocol" value="serial,socket" /> |
| HeapSize | The needed heap size of the device, e.g. "200+ kb" or "1.1+ MB"
<requirement name="HeapSize" value="200+kb" /> |
| Vendor | The vendor of the device, e.g. "Nokia" or "Siemens".
<requirement name="Vendor" value="Nokia, SonyEricsson" /> |
| Identifier | The identifier of the device, e.g. "Nokia/N95 ".
<requirement name="Identifier" value="Nokia/N95 , SonyEricsson/P900" /> |
| Feature | A feature which needs to be supported by the device.
<requirement name="Feature" value="supportsPointer" /> |
| Term | A preprocessing term that needs to be fulfilled by the device. You can use this flexible requirement just like the //#if-preprocessing directive in your source code.
<requirement name="Term"
value="polish.mmapi and !polish.isVirtual and (polish.Vendor != Nokia)" /> |