J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

Variables and Symbols

Most preprocessing is triggered by directives, which use either symbols or variables. A symbol is like a boolean value - either it is defined or the symbol is not defined. A variable, however, always contains a value, which can be used or compared during the preprocessing.
Symbols and variables are defined in several files:

  • build.xml: with the "symbols"-attribute of the <build> element and with the <variables> element
  • vendors.xml, groups.xml, devices.xml: symbols are defined by the <features> element, whereas variables are defined by the capabilities. Most capabilities also define symbols.

Thanks to the integrated device database, J2ME Polish supports a lot of useful symbols and variables, with which device optimizations are easier than ever.

Device Specific Variables and Symbols

Platform polish.midp1, polish.midp2, polish.midp3 polish.JavaPlatform When a device supports the MIDP 1.0, 2.0 or 3.0 platform, the symbols "polish.midp1", "polish.midp2", and "polish.midp3" respectively are defined. Regardless of the version the "polish.midp" symbol is defined for all devices supporting the MIDP platform.
Platform polish.blackberry polish.JavaPlatform When a device supports the BlackBerry platform, the "polish.blackbery"-symbol is defined.
Platform polish.doja polish.JavaPlatform When a device supports the DoJa platform or NTT Docomo, the "polish.doja"-symbol is defined.
Configuration polish.cldc, polish.cldc1.0, polish.cldc1.1, polish.hasFloatingPoint polish.JavaConfiguration Depending on the supported configuration, either "polish.cldc1.0" or "polish.cldc1.1" is defined. For all CLDC devices the "polish.cldc" symbol is defined. When you want to check if the target device supports floating point calculations, we recommend to check for the "polish.hasFloatingPoint" instead of "polish.cldc1.1", because in this way you can use the Floater tool.
api polish.api.mmapi, polish.api.wmapi, polish.api.nokia-ui, etc. polish.JavaPackage For each API which a device supports, the "polish.api.[api-name]"-symbol is defined. When a device supports the Mobile Media API, the "polish.api.mmapi"-symbol is defined, for example.
audio polish.audio.wav, polish.audio.midi, polish.audio.mp3, etc. polish.SoundFormat For each sound format which is supported by the device, the symbol "polish.audio.[format-name]" is defined.
video polish.video.h.263, polish.video.mpeg-4, polish.video.3gpp, etc. polish.VideoFormat For each video format which is supported by the device, the symbol "polish.video.[format-name]" is defined.
colors polish.BitsPerPixel.12, polish.BitsPerPixel.16, etc. polish.BitsPerPixel Depending on the color depth of a device, the appropriate "polish.BitsPerPixel"-symbol is defined. The color depth can be compared within an "#if"-clause:
//#if polish.BitsPerPixel >= 12
	// this device supports at least 4096 colors.
screen dimension polish.ScreenSize:defined polish.ScreenSize When the screen-size of a device is known, the "polish.ScreenSize:defined" symbol is defined.
screen dimension polish.ScreenWidth:defined polish.ScreenWidth When the screen-size of a device is known, the "polish.ScreenWidth:defined" symbol is defined. The screen width can be used with the "#="-directive:
//#ifdef polish.ScreenWidth:defined
	//#= int width = ${ polish.ScreenWidth };
	int width = getCanvas().getWidth();
screen dimension polish.ScreenHeight:defined polish.ScreenHeight Compare polish.ScreenWidth.
screen dimension polish.CanvasSize:defined polish.CanvasSize The canvas size can differ from the screen size, when no fullscreen mode is available.
screen dimension polish.CanvasWidth:defined polish.CanvasWidth Compare ScreenWidth.
screen dimension polish.CanvasHeight:defined polish.CanvasHeight Compare CanvasWidth.
network polish.JavaProtocol.http, polish.JavaProtocol.https, polish.JavaProtocol.serial, etc. polish.JavaProtocol The JavaProtocol describes the network protocols which are supported by the device.
memory polish.HeapSize:defined polish.HeapSize The heap size defines the maximum possible memory, which can be allocated by an application.

Other Useful Variables and Symbols

Full-screen class polish.classes.fullscreen:defined polish.classes.fullscreen When a device supports a specific full-screen-class, this varible can be used for a flexible inheritance structure:
public class MyCanvas 
//#ifdef polish.classes.fullscreen:defined
	//#= extends ${polish.classes.fullscreen}
	//# extends Canvas
MIDlet classes -- polish.classes.midlet-1, polish.classes.midlet-2, polish.classes.midlet-n For each used MIDlet class the corresponding polish.classes.midlet-n variable is defined.
animation - polish.animationInterval Defines the interval in milliseconds for animations. This defaults to 100 ms, but you can change this value within the <variables> element of the <build> section.
logging polish.debugEnabled - Is defined when the logger is enabled.
logging polish.debugVerbose - Is defined when the verbose-mode of the logger is enabled. Exception should provide more details when the "polish.debugVerbose" symbol is defined.
memory polish.skipArgumentCheck - Can be defined in the symbols-attribute of the <build> element within the "build.xml" file. When this symbol is defined, all GUI classes of J2ME Polish will not check the input variables. This is useful for minimizing the memory footprint when an application is stable.
GUI polish.usePolishGui - Is defined when the GUI of J2ME Polish is used for the current device.
GUI polish.usePolishTitle - When the variable "polish.usePolishTitle" is set to "true", the title-style will be used on MIDP/2.0 devices as well. On such devices usually the native title is used instead, unless a fullscreen mode is used.
back to top