• 沒有找到結果。

Application Structure & Component Constraints

Chapter 2 Context adaptation

2.2 Context adaptation process

2.2.3 Application Structure & Component Constraints

Constraints

In order to enable this framework to be aware of the structures of applications, we define Application Structure and Component Constraints (ASCC), an application profile description. Listing 2 illustrates the ASCC profile of the application ImageGathering.

Listing 2. The ASCC profile to describe structure of ImageGathering

1 <?xml version="1.0"?>

2 <ascc xmlns:ascc=http://dcsw3.cis.nctu.edu.tw/project/CAAS ...>

3 <application id="ImageGathering">

4 <function id="ImageRetriever">

5 <default idref="JPEGRetriever"/>

6 <component id="JPEGRetriever" priority="51%"

7 stateful="No" relative="No" carried=”No”>

8 <constraints>

9 <prf:ImageCapable>Yes</prf:ImageCapable>

10 <prf:CcppAccept>image/jpeg</prf:CcppAccept>

11 </constraints>

12 </component>

13 <component id="GIFRetriever" priority="50%"

14 stateful="No" relative="No" carried=”No”>

15 <constraints>

16 <prf:ImageCapable>Yes</prf:ImageCapable>

17 <prf:CcppAccept>image/gif</prf:CcppAccept>

18 </constraints>

19 </component>

20 <component id="PNGRetriever" priority="50%"

21 stateless="No" relative="No" carried=”No”>

22 <constraints>

23 <prf:ImageCapable>Yes</prf:ImageCapable>

24 <prf:CcppAccept>image/png</prf:CcppAccept>

25 <prf:JavaPlatform>MIDP/1.0-compatible</prf:JavaPlatform>

26 </constraints>

27 </component>

28 </function>

29 <function id="Transcoder">

30 <default idref="SizeTailor"/>

31 <component id="SizeTailor" priority="50%"

32 stateful="No" relative="No" carried=”No”>

33 <component id="ColorTransformer" priority="50%"

34 stateful="No" relative="No" carried=”No”>

35 </function>

36 <function id="Cache">

37 <component id="ImageCache"

38 stateful="Yes" relative="No" carried=”Yes”>

39 </function>

40 <function id="DataAccess">

41 <component id="MSAccess" stateful="Yes" relative="Yes">

42 </function>

43 <function id="ImageTransmitter">

44 <component id="HTTPConnector"

46 stateful="Yes" relative="Yes"/>

47 </function>

48 </application>

49</ascc>

As we can see in Listing 2, the <application> element includes five

<function> elements, which can describe the five functions. In each

declare that <component id=”JPEGRetriever” ...>, <component id=”GIFRetriever” ...>, and <component id=”PNGRetriever ” ...>

can implement the Image Retriever function. In advance, within a <component>

element, the properties, stateful, relative, and carried, can be used to set components stateful/stateless, relative/irrelative, and carried/un-carried respectively.

The priority property concerns the priority of a component, one of which is chosen in each application adaptation. Furthermore, to set a component as a default component for a function, we can use the element <default>. If we want to set a component implementing the function which cannot be replaced with others, we can use the property “unchanging=’Yes’”.

Chapter 3 PUML/PGML Transformation

In this chapter, we will show the design of PUML and PGML, the intermediate languages for transformation. After the introduction, we will explain the transformation mechanism, and then the use of the mechanism context adaptation and PUML/PGML transformation.

3.1 Pervasive User Interface Markup Language (PUML)

3.1.1 Conceptual view

The principles of designing PUML including: (1) user interface abstracting; (2) intermediate language fashioning, and (3) OO (Object-oriented) [19] conceptualizing.

To achieve the first, we analyze the characteristics of primary languages, including WML 1.1 [20], J2ME MIDP v1.0 [21], on the small and mobile devices. User interfaces of applications can be divided into two classes roughly. One is plentiful category; the other is fundamental category. User interfaces in the former has abundant widgets to display UI controls. User interfaces of the applications running on PCs, for instance, contains menu bar, tool bar widgets, etc. In addition, displaying

HTML documents on the desktop of PCs has a variety of modules, involving Frames module, Applet module, and etc. Respecting user interfaces on the screen of the small and mobile device, there are not a wide variety of widgets to render UI controls. It merely consists of basic presenting modules, such as Form module, Image module.

In this paper, we attempt designing form-based user interfaces to investigate device independence of the applications on the small and embedded devices. There are three primary reasons. First, the form module is the basic interaction component of user interfaces. Second, it is the module which is in the intersection of the UI components of J2ME and WML applications. It means that the widgets in the intersection module can be rendered both on the user interfaces of WML and J2ME applications. For example, bottom belongs to this kind of the widgets. Scroll bar, however, does not reside in the intersection, because it is incapable to be displayed on either one of them. Finally, to explore problems in approaching device independence via simple target languages, we can comprehend the use of markup languages to approach device independence easily. Moreover, we can gradually add other modules to enrich the PUML capabilities.

From the above considerations, we design PUML as a form-based user interface markup language. A user interface description of PUML comprises several containers.

Each of the containers contains the basic widgets including label, text filed, single-choice listing, multi-choice listing, picture, and action. The following figure shows the conceptual view of PUML. The next section will detail the widgets and document structure of PUML, and a table shows the XML schema of PUML .

Action

1. … 2. … 3. …

ˇ ˇ

1. … 2. … 3. …

Text Field Label Label

Multi-choice Listing

Container

Single-choice Listing

Picture

Fig. 16. The conceptual view of PUML

In terms of the second point, without doubt the language based on XML can serve as an intermediate and transformable language, explained in Section 1. In the third of the principles, we wish that writing PUML and PGML codes is in object-oriented manner. In such a way, programmers can write the PUML/PGML more intuitionally. Additionally, applications can be designed by applying the object-oriented analysis. For the reason, we design that to use a PGML description, e.g. a .pgml file, in a PGML document as an object used in Java [22]. The detail will be detailed in the following sections.

3.1.2 The language description

By exploiting XML, in PUML we define <puml:label>, <puml:textnote>,

<puml:listpaper>, <puml:picture>, and <puml:action> to stand for label, text field, list, image, and action, respectively. These elements are the widgets which are involved in a <puml:board> container. Listing 3 illustrates the document structure of a user interface description using PUML. The DTD [23][24] of PUML can be referred in Appendix B.

The <puml:user-interface> element has three types of child elements, which are <puml:logic-objects>, <puml:board>, and <puml:layout>.

The <puml:logic-objects> element is used to declare the logic object, e.g. .pgml file, and the name used in a PUML document. A <puml:board>

element can contain <puml:textnote>, <puml:listpaper>,

<puml:label>, <puml:picture>, and <puml:action> elements; besides, each of the child elements can occur more than once. All of these elements can be rendered into UI controls capable of interacting with users. The detail of these elements will be explained in the next section.

A <puml:layout> element can specify the layout of the boards in a PUML document. On smart phones or some mobile devices, it has no effect, because their screens cannot display two or more boards meantime. However, if the description is migrated to be rendered on the screen of PCs, displaying of these boards is in disorder.

Hence, we design the <puml:layout> element to state the arrangement of boards for extending the capability of PUML in the future. Other details concerning the elements will be explained in the next two sections.

Listing 3. An overview of the document structure of PUML:

1 <?xml version="1.0"?>

2

3 <puml:user-interface … >

4

5 <puml:logic-objects>

6 …

7 </puml:logic-objects>

8

9 <puml:board … >

10 <puml:logic-objects>

11 …

12 </puml:logic-objects>

13

14 <puml:textnote … />

15

16 <puml:picture … />

17

18 <puml:label … />

19

20 <puml:listpaper … />

21

22 <puml:action …>

23 …

24 </puml:action>

25 </puml:board>

26

27 <puml:board …>

28 …

29 </puml:board>

30

31 <puml:layout … />

32 </puml:user-interface>

3.1.3 The elements of PUML

The top level elements are <puml:logic-objects>, <puml:board>, and

<puml:layout>. A PUML document can has at most one <puml:layout>

element. As mention in last section, it can be used to specify how to layout the board

in that document. <puml:logic-objects> involves several

<puml:object> elements, each of which declares a PGML document used in

<puml:board> elements. Besides, the <puml:logic-objects> element can be directly applied into <puml:board> element. When a

<puml:logic-objects> element is used in a board, the visibility scope of the

<puml:object> elements, declared within the <puml:logic-objects>

element, is limited in this board. It means that the names of the <puml:object>

elements, each of which stands for a PGML file, can be used in the board container only. <puml:board>, as mentioned above, is the basic container element, which includes the following child elements: <puml:picture>, <puml:label>,

<puml:textnote>, <puml:listpaper>, <puml:action>, and

<puml:logic-objects>. Moreover, it has the three attributes: name, title, and seqNo. The name attribute can be used to identify a board of the boards described in a PUML document. For the attribute, some value must be assigned by programmers. Concerning the meaning of the seqNo attribute, the seqNo attribute specify its priority. If the value of this attribute were 0, the board would be displayed first. If it were 1, the board, displayed on the screen, would follow the first one, and vise versa.

A <puml:picture> element, in a <puml:board> … <puml:board>

block, can be used to show an image. It has four attributes: name, source, altText, and align attributes. A source attribute can be assigned to locate an image, which is specified to be exhibited. altText is the attribute which can be set a text value so as to be shown instead when the image cannot be displayed. The align attribute points the alignment of the image. Three attribute, left, center, and right, could be chosen to assign to this attribute.

A <puml:label> is similar to the label of the windows on the PCs. It can display a read-only text string on the screen. Its main attribute is showText, which can be assigned a string value to be displayed on the screen. We can use this element to show some title or prompt information. Oppositely, <puml:textnote> can get

a string from the user’s input. Namely, it allows users to input a certain value. Besides this attribute, the type attribute of the element can be assigned two values: text and password. If we set the attribute text, the value of the element would be rendered into the input value on the screen directly. If we set the attribute password, the value will be displayed with a character * to replace each character in the original string. It signifies that displaying of the input value is encrypted.

The <puml:listpaper> element serves as a choice group for picking a single item of a listing, or selecting a group of options among the items of the listing.

The child content, within the element, includes at least one <puml:item> element as the optional items. To make the element be a multiple-choice or single-choice listing control, the mode attribute of the element can be set multi or single, respectively. Sharing the same function with the name attribute mentioned above, the iname attribute is assigned an ID for the element. Specifically, it emphasizes that it is a variable recording index values of the chosen items, instead of the values themselves. The ivalue attribute is the attribute which records indexes of the chosen <puml:item> elements in the <puml:listpaper> block. In single mode, the index value is an integer, counted from 1. The index value, differently, records a string value that could be 1, 1;2, 1;3, 1;3;4, and so on. As regards

<puml:item> elements, each of them has a showText attribute displaying a prompt text to users, a value attribute recording the value of the item, and a selected attribute indicating whether it has been chosen.

<puml:action> elements can bind the events, which are triggered by the widgets of a PUML document, to the event-handling method of a PGML document.

On the user interfaces of WAP-capable phones or J2ME smart-phones, it is rendered into a push item, which can be selected by users. For example, it could be a bottom if

it is displayed on the user interface of PCs. Child elements of the element could be

<puml:use-object>, <puml:change>, and <puml:nextboard>. Using

<puml:use-object> can declare that a name of an object, e.g. a PUML document, and the object owns a method to handle the events caused by the trigger of the action (shown as Line 3 in Listing 4). An object can be used in the board, if declared in this board or in the root element <puml:user-interface> via

<puml:use-object> and <puml:object> elements. It means that the object, like a global variable, can be used in each of the <puml:board> elements within the <puml:user-interface> region.

To input parameters into a method, we can use <puml:param> elements as the child elements of the <puml:use-object>. Every <puml:param> element has a name and a value attribute; besides, the arrangement of the <puml:param> needs to conform to the order of the arguments of this method. Particularly, the usage of the attributes in a <puml:param> is either using only a select attribute, or using an attribute pair (type and value) alternatively. In the former, the select attribute can be assigned the value which refers to the name attribute of some widget element declared in the same board. It indicates that using this element as a variable; besides, the value attribute of this element can be retrieved at runtime. Alternatively, the latter can be used if programmers would like to input a value to the method directly. Line 5-8 and Line 10-12 in Listing 3 illustrate the two examples of using the select element and the type and value pair, respectively. In addition, the returned value from the method can update the attribute value of some widget which is specified by means of the <puml:change> element, shown in Line 14-19. Respecting the

<puml:nextboard> element (Line 21), an name of some board can be assigned to the goto attribute of the element. It can change the screen to display the board

specified, when its parent element <puml:action> is triggered.

Listing 4. Examples of <puml:use-object>, <puml:param>, and <puml:change>

1 <puml:action name="action" showText="actionDemo">

2

3 <puml:use-object name="object1" method="getRandNum" />

4

5 <puml:use-object name="object1" method="getMax">

6 <puml:param select="note1" />

7 <puml:param select="note2" />

8 </puml:use-object>

9

10 <puml:use-object name="object1" method="getAbsVal">

11 <puml:param type="int" value="-1" />

12 </puml:use-object>

13

14 <puml:change container="board1" component="note2" update="value">

15 <puml:use-object name="object1" method="getMax">

16 <puml:param select="note1" />

17 <puml:param select="note2" />

18 </puml:use-object>

19 </puml:change>

20

21 <puml:nextboard goto="board2" />

22

23 </puml:action>

3.2 Pervasive LoGic Markup Language (PGML)

3.2.1 Design Principle

In [15], we mentioned the markup language of the event-handling logic. Currently, we have revised the language and rename it Pervasive loGic Markup Language (PGML).

We endeavor to enable the language to support a wide range of devices to approach device independence. Initially, we concentrate on applying the language to the small and mobile devices. Like PUML, the design principles of the language we consider are: (1) computation generalizing, (2) intermediate language fashioning, and (3) OO conceptualizing.

The first means that, logic languages, such as C, Java, or WML Script, have the primary statements to declare variables and function blocks, and flow-control and condition-control mechanisms to complete basic computation. Therefore, we abstract the primary expressions and statements to define PGML. The second and third points are explained in Section 1 and 2.1. From the three points, we make PGML own the following capabilities:

z The object-oriented concept

z Local and global variables declaration

z Mathematical, logical, and boolean expressions z Flow-control and condition-control statements z Method declarations.

3.2.2 The design of PGML

Peripherally the features of PGML and PUML are different, but essentially the two languages have the same intention. PGML aims to describe the computational logic in the XML format. The computational logic is a section of an application, containing mathematical, comparison computations, and method invocations, etc. Figure 17 demonstrates a PGML object in a tree view of the XML Schema [25]. An object, e.g.

a PGML file, is composed of a variable declaration <declaration> and a least one method <method>. Listing 5 shows an overview of the PGML document structure.

Fig. 17. A tree view of the XML Schema of PGML

Listing 5. The document structure of PGML:

1 <?xml version="1.0"?>

2 <pgml:object … >

3

4 <pgml:declaration>

5 …

6 <variable …>

7

8 </pgml:declaration>

9

10 <pgml:method … >

11

12 <pgml:in> … </pgml:in>

13

14 <pgml:declaration> … </pgml:declaration>

15

16 <pgml:action … >

17 …

18 <pgml:if> … </pgml:if>

19 <for> … </for>

20 <assign … > … </assign>

21 …

22 <pgml:return … />

23 </pgml:action>

24

25 </pgml:method>

26

27 </pgml:object>

To explain expressing computational logic in XML in advance, we take four simple examples of <add>, shown in the following listing. Line 2-5, Line 7-10, and Line 12-15 denotes that a+b, 5+6, and s=5+6, respectively. In detail, Figure 18 presents that an <add>

contains two child elements as its operands. One of the two elements could be one in the elements of the MathExpression Group, or in those of the OperandGroup group, such

17-23), and consequently the code of PGML will be transformed into s=(3+4)+5. Other cases of using PGML and converting PGML expressions into the Java syntax are illustrated in

17-23), and consequently the code of PGML will be transformed into s=(3+4)+5. Other cases of using PGML and converting PGML expressions into the Java syntax are illustrated in