Java Card,XML
Java Card,XML
Software processes the data and information. Software is generated by a set of (a)
statements, functions, service routines, threads, objects and classes written in a high-level
language, (b) codes using a framework or (c) codes using a development tool.
In addition to phone which includes SMS, MMS, other additions to teleservices and
various supplementary services, there are many mobile applications. A mobile application
can be developed through any one of the following three approaches:
Using a language like Java that complies and runs on diversified operating systems
and hardware platforms.
Using a language supported by the operating system which provides a development
platform such that compiled program can run on the hardware supported by that OS.
Using common framework and OS platform which supports different languages.
8.2 XML
1
An XML document can make non-textual use of text. A tag can represent a command
to process the data using the command name within the pair of start and end tags in
the document text.
A tag along with its attributes can specify the command , source files and data to
process the command
Below is the example of an XML document which can be used as contacts in mobile
smartphones.
2
8.2.1 Document Type definition and Parsing of XML Documents
PARSER:
Parser is a software written in JAVA or any other language. Its functions are
to validate and parse the tags, their attributes, and the text within each pair of
start and end tags and to enable extraction of specified information either from
the document file or using document and DTD files.
A parser first validates an XML document and then handles the specified
document structures. Validation means investigating about (i) whether the
document contains a root element with the same name as of DTD (ii) whether
it contains the header information for the version, encoding, and reference to
other files (iii) whether it contains DTD with declaration of the mark-ups in
the document or in a linked external DTD document.
The XML document has .xml extension and the external DTD document has
file extension .dtd.
There are two models of an XML document and correspondingly two types of parsers.
They are as follows:
3
DOM Model of an XML Document
DOM ( Document Object Model) is the one in which each set of elements is
dependent and derives from a root element and whole document forms a tree-
like structure.
DOM model document is always hierarchically arranged.
The whole document is parsed initially to create a hash table of keys and
corresponding values for each key.
An advantage of DOM parsing is that the structure is well-defined and the
same parser can be used for parsing all XML documents and later the
interpreter or processing program is able to extract the desired information by
simply using the keys.
Extracting and parsing a program for a DOM model document and parser is
not complex.
Below example shows SAX model of parsing of an XML document
corresponding to Contacts.
4
8.2.3 Applications of Parsed Information and Data
An application uses the extracted output information and data from the parser after a
further processing using a programming language. The parsed data is interpreted at the
application. An application can also use the metadata in XML document to speed up and
enrich searching for the resources, organising the information and managing the data. An
application in addition to XML data can thus also use the metadata during the processing.
The following are the examples of XML usage:
5
Used internally for specifying the information in an application or framework.
Used by HTML browser after translating XML information into HTML information
using a technology called XSLT (Extensible style-sheet language transformation).
XHTML-MP format of XML can be used as HTML web pages with portability and
extensibility in mobile devices.
XML is an extensible language. The tags and attributes, and markup language format
can be standardized for applications.
XForms is a form of in XML format which specifies a data processing model for
XML data and UIs for the XML data.
XForms controls are <textarea>, <input>, and <secret> and a string data type is
attached with these fields. Other XForms controls are <selectOne>, <choices>,
<item>, and <itemset>.The attributes of XForms inout control are ref and
xml:lang.xml:lang =”en”,accessKey, navIndex and class. The elements of XForms
are <alert>, <caption>, <hint> and <extension>. There are client-side as well as
server-side validations before processing of the XForms.
XML user Interface (XUI) is a framework in XML and Java for mobile and mobile
handheld device applications.
WBXML (WAP binary markup language) is a format in which WAP presents XML
document as binary numbers.
VoiceXML (VXML) 2.0 is a version of an XML-based language for interactive
talking between a human being and a computer.
SSML ( Speech synthesis markup language) is used in TTS ( text to speech
converter). It is for synthesizing the speech by interpretation of a text by synthesizer.
It creates audio book.
Speech recognition grammar specification (SRGS) is used in SSML. It lets speech
recognizer to define the pattern of sentences.
Call control extensible markup language (CCXML) is a standard for an XML- based
languagewhich can be used independently or with VXML for telephony support.
CCXML commands the browser to handle the calls of the voice channel.
8.3 JAVA
Java is a language which compiles into byte codes and the code runs on virtual
machine. Therefore these can run on any operating system and hardware platform on
which JVM is installed.
The JVM provides execution engine and native interfaces to run the codes on the
given OS and hardware. Java is the most popular language used for mobile
computing. Java 2 standard Edition (J2SE) is standard Edition.
Java is used to program the application threads, applets, servlets and aglets.
Application threads – these are the programs of the application, each one of which
is assigned a priority and runs concurrently.
6
Servlets – these are the programs running on a web server. The life cycle of a
servlet consists of the sequential step – init( ), service( ) and destroy( ).
Applets – these are the programs running on a client. The life cycle of a applet
consists of the sequential step – init( ), start( ), stop( ) and destroy( ).
Aglet – it is the mobile agents which run on host. The life cycle of an aglet
consists of the sequential steps – creation, dispatch, activation, deactivation and
disposition.
A class is a construct in Java or C++, which is used to define a common set of
variables, fields, and methods and whole instances give the objects.
Characteristic features
Java is object-oriented language. Each class is a set of codes that has number
of members – fields, methods, etc., so that objects can be created as instances
of class.
Platform-independence is the most important characteristics of Java, which
means that the program code compiled in Java are independent of the CPU
and the OS used in the system.
Robustness is one of the characteristics of Java. All references to memory,
freeing of the memory, de-allocation, and validation of object types and arrays
indices are done internally at compile and run time.
Standard APIs enforcement is another characteristics of Java. APIs help Java
program to connect an application to a program, database, distributed object,
or server developed on other platforms.
7
Classes and Beans
Java has packages consisting of the classes and interfaces. The packages help in
fast development of the code. Some of the widely used packages are:
java.lang – package for fundamental classes of Java
java.io – package for input, output and file access.
java.math – package for classes for the mathematical methods.
java.awt – package for Java foundation classes for creating GUIs.
java.swing – package for Java swing classes for creating lightweight GUIs.
java.net– package for network related classes like TCP/IP, UDP, HTTP and
FTP.
java.security – package for classes in Java security framework.
java.sound – package for audio processing.
java.io.Serializable –it has serializable interfaces.
Below fig shows an N-tier architecture in which a client device connects to the enterprise
databases.
8
A container has EJB as Session Beans and Entity Beans. It provides transactions,
security, scalability, pooling of resources, and concurrent execution of the application.
Resources are pooled by transactions between Entity Beans and backend servers for
the resource at the enterprise tier. Entity Beans connect to enterprise tier which can
have a database server. Transactions maintain persistency of data at enterprise server.
J2ME is a micro edition of J2SE which provides for configuring the run time
environment.
J2ME is a set of Java APIs which require small memory while developing Java
applications. It is also a platform for development of mobile games.
Windows mobile devices do not support J2ME or Java based Virtual machine. Java
platform binary implementation and virtual implementation are done by another
source not from Windows.
9
Profiles
A profile means a standardized agreed-upon subset and interpretation of a
specification. A profile may also mean a specification for a set of configuration
settings and other data which are used in the APIs for a device, user, or group of
devices.
Mobile information device profile (MIDP) is the profile for mobile devices with
small screen option for GUIs, wireless connectivity, and greater than 128kB flash
memory.
A MIDlet is a J2ME application (similar to applet) for embedded devices which
runs with MIDP. MIDlet are programmed to run games and phone applications.
Also they are compiled once and are platform-independent. Below table shows
the MIDP source packages and sets of Java class libraries.
Configurations
A configuration is a subset of profile.
CLDC ( connected limited device configuration) is a configuration for limited
connected devices. CLDC defines a base set of APIs and VM for the resource-
constrained mobile phones or handheld computers. CLDC configuration is a
subset of MIDP used for developing Java applications.
10
CDC (Connected device Configuration) is a configuration for connected devices.
CDC is a Java framework for developing an application that can be shared in
networked devices. CDC provides a J2ME framework for applications which run
on wirelessly connected devices and APIs for HTTP.
Below table gives source profiles, packages for the configurations of CLDC and CDC
and the required Virtual Machine.
8.5 JavaCard
JavaCard ( Java for card) is a micro-edition for Java for the cards. JavaCard is a
limited-memory sized edition for cards, labels, tokens, and similar devices which have
limited memory as well as processing capability.
JavaCard 2.2.2 provides interoperability for cards and APIs for highly memory-
efficient applications. It has multiple communication interfaces for inter card-host
contact/contactless communication.
JavaCard framework (javacard.framework) provides the library functions, Card
interfaces, PIN and APIs for Card applet.JCardSystem is a class in JavaCard. It has a
method called TransientArray( ). The method creates a transient array and it persists
till power is down.
Card profile is a set of limited class libraries. JavaCard profile is smartcard profile
which has a separate virtual machine called card VM. Card VM has an instruction set
for a subset of Java language. It installs applets and libraries into JavaCard-based
devices.
CardVM is a virtual machine which has no char, double precision, or single precision
and no floating point mathematical operations support. It has limited exception
handling, no object clones, no String class libraries, no automatic garbage collection,
no SecurityManager class libraries and no multi-threading.
11
The card applet creates card-specific byte code on compilation. Java applet has
lifecycle starting from init( ),start( ),stop( ) and destroy( ). Objects created in card
applet are persistent.
JCRE ( JavaCard runtime environment) interprets the card byte codes and implements
them using JavaCard Virtual Machine. It does not support inter- communication
between different card applets and provides runtime support to the various different
services.
An operating system (OS) is the master control program in a system that manages all
software and hardware resources. It controls, allocates, frees, and modifies the memory by
increasing or decreasing it. An OS has utility programs like file manager and configuration of
OS.
12
Mobile Operating System
Mobile OS is an OS which enables running of application tasks taking into
account of various hardware constraints like CPU speed, memory, battery file,
display and size of input device.
An application consists of application task. The OS provides the functions
used for scheduling the multiple tasks in a system.
Mobile Os also provides the configurable libraries for the GUI in the device. It
provides for multi-channel and multi-model user interfaces.
8.6 PalmOS
PalmOS is one of the most popular OS for handheld device. It offers high
performance. Below table shows the highlight features of PalmOS.
13
14
Below fig shows the architectural layers of PalmOS.
The lowest level in OS is a Kernel. This layer directly interfaces the assembler,
firmware and hardware. PalmOS has a micro-kernel.
15
Memory Management
PalmOS assumes that there is a 256MB memory card. The card can have
RAM, ROM, and flash memories. A memory has logical hexadecimal addresses from
00000h to 3FFFFh. Ram is used for stacks of processes and for the global variables in
the running processes of the applications. Below fig shows the functions of the
memory manager of the PalmOS.
File Management
PalmOS file manager manages each file as a database which has multiple records
and information fields. Each record can have following attributes – protected
record, deleted record, locked record and updated record.
The info fields of each record have record ID and record attributes. Info fields
about the file have – (i) name, (ii) file attributes, (iii) version of application
database, (iv) modification number and access counter, and (v) file local ID.
The file local ID is a number used to identify the file locally when an application is
running. A local file sorting table uses the file local ID to sort the file in the
required order.
16
Communication APIs
PalmOS provides communication and network APIs for serial, IrDA, and TCP/IP
communication.
Serial Communication uses a cradle. A Serial Manager (SM) provides interface to
the device on cradle. Connection management (CM) protocol, modem manager
(MM), or serial link protocol (SLP) interacts with SM to transmit the data to PC. A
device receives the data from the other end through serial manager and SLP, MM
or CM. SLP has on top of it a packet assembly and disassembly protocol (PADP).
IrDA asynchronous serial or synchronous serial communication uses exchange
manager as session layer and IrDA library functions at lower level. Exchange
manager enables data interchange directly without HotSync.
17
Application Development Packages
PalmOS supports development packages – Palm SDK ( software development
kit) and CDK ( conduit development kit). A conduit is a path. A CDK conduit
of Palm provides a two-way path for data exchanges and synchronisation
between a desktop PC application and the applications running on a device.
8.7 Windows CE
18
19
ARCHITECTURE:
Architecture of Windows CE consists of Application layer which supports the
following APIs—Bluetooth, WiFi, Word mobile with embedded graphics, Excel
mobile, Powerpoint mobile, set of hardware application buttons, email download etc.
Next to application layer is Windows CE which consists of virtual memory managers,
process manager, thread, and interrupt handlers, and user interfaces. This layer
supports priority allocation to processes, interrupt service threads, handles real-time
latency etc.
The Windows CE layer next to the above is kernel source code. Hardware abstraction
layer is layer added for customising Windows CE for device hardware.
20
Below shows the architectural layers of Windows CE.
Windows CE can be in three states – (i) ON with the clock frequency lowered
in idle state, (ii) suspend with power to unused system units and port peripherals
disconnected, memory data persistent, CPU idle till next interrupt, and clock running,
and (iii) dead with power disconnected.
Windows Mobile
Handheld PC using Windows OS is also known as PocketPC. Windows
mobile is a suite of basic applications for handheld devices along with the
compact OS.
It enables PIM, Internet explorer, Windows Media Player, various audio and
video formats, Voice over IP, pocket Excel, Pocket word, Microsoft Outlook
etc.
The Windows Mobile Microsoft .NET platform is an open platform.
21
Memory and File management
Windows CE assumes that there is 4GB virtual memory. A system can have
RAM,ROM and flash memories.
A memory has logical hexadecimal addresses from 000000000h to
FFFFFFFFFh.
A ROM image is the footprint of OS, Data and the applications at the
permanently installed ROM. When the OS is configured and customized for an
embedded application, then OS footprint is the ROM image. The Customisation
reduces the OS footprint.
There is a dynamic heap of application process stacks, TCP/IP stack, OS
functions stack, application and OS function dynamic-memory spaces,
Bluetooth stack ,Wi-Fi stack etc in the program memory.
OS and system functions are saved in the ROM.
Windows CE memory manager has four different types of access mechanism
as follows:
22
Communication, Network, Device, and Peripheral Drivers
Windows CE provides communication and network APIs for serial, IrDA, TCP/IP,
Bluetooth stack, and Wi-Fi stack.
Windows CE integrates Microsoft Smartphone software which enables the application
of Windows CE device as cellular GSM.CDMA phone.
Serial communication uses a cradle. A serial manager(SM) provides interface to the
device on cradle. Connection management is by using the serial link interface protocol
(SLIP) and point-to-point (PPP) protocol.
IrDA asynchronous serial or synchronous serial communication uses ActiveSync.
Windows CE uses TCP/IP network library functions to transmit or receive the stacks
and application requests and response on or from the network.
Windows CE provides device driver and peripheral driver functions for low-level
drivers at the kernel. USB connectivity is provided for the peripherals.
Application Development
Windows CE considers threads of process to be a fundamental unit of execution and
providing access of CPU. Application are developed by coding for the threads. It
supports 256 priority levels for assignment of threads.
23
Corresponding to event, there is an event handler. An event sends interrupt signal
which is checked for source and is identified whether it is hardware event, software
exception, user-action-based event etc.
Event handler is called Interrupt service thread (IST) in windows CE device. An IST
has 8 priority levels. Highest priority levels means time critical priority and the lowest
priority level means idle priority.
An external interrupt is notified to the OS and for each request, there is an ISR
assigned by the OS on notice.
An application development needs to define processes and each process has threads.
Below fig shows how an application program runs on Windows CE platform as event-driven
number of ISTs and application threads.
8.8 Symbian OS
Symbian is one of the most popular Oss for handheld Smartphones and mobile
handhelds with phone and multi-modal communication. Multi-modal means usage of
different modes—text, image, video, or audio. Symbian OS supports application development
in C/C++ as well as Java and many communication protocols.
24
25
The below fig gives the architectural layers of Symbian OS. The lowest level layer in OS is a
kernel which directly interfaces the assembler, firmware and hardware.
26
Communication and network APIs
Symbian provides communication using WAP, WiFi, and network APIs for serial
Bluetooth, TrDA, and TCP/IP, communication APIs for HTTP, TCP/IP, DNS,SSL,
WAP, PPP, GUI/VUI framework, and communication interfaces for TCP/IP etc.
Linux is one of the type of OS which is best suited for different sorts of hardware and
software applications. It enables the user to customize their device to suite their specific
needs. It is also considered more secure OS. Its main features are as listed below:
27