import java.io.*;
import WmlSuite.*;
public class TestWml
{
public static void main(String argv[])
{
WmlFrame w=new WmlFrame();
Deck d=new Deck("first");
Card c=new Card("id1","myLabel");
d.addCard(c);
c.addParagraph(w.big("Hello, World!"));
System.out.println(d.toString());
}
}
you will get the following wml file:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="id1" title="myLabel">
<p><big>Hello, World!</big></p>
</card>
</wml>
once more:
import java.io.*;
import WmlSuite.*;
public class TestWml1
{
public static void main(String argv[])
{
Deck d=new Deck("first");
Card c=new Card("id1","myLabel");
d.addCard(c);
c.addParagraph(WmlFrame.Italic("Hello, World!"));
c.setAccept("Next","http://coldjava.hypermart.net?id=1&page=2");
System.out.println(d.toString());
}
}
and wml file is:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="id1" title="myLabel">
<do type="accept" label="Next">
<go href="http://coldjava.hypermart.net?id=1&page=2"/>
</do>
<p><i>Hello, World !</i></p>
</card>
</wml>
Package:
Main object is Deck. Deck contains several Cards.
Class WmlSuite.Deck:
constructor:
public Deck(String sDeckName)
methods:
// get and set Deck name
public String getName()
public void setName(String sDeckName)
// get and set max age (in seconds for cache)
public int getMaxAge()
public void setMaxAge(int sec)
// add Card
public void addCard(Card c)
// returns deck size (bytes)
public int size()
// generates WML code
public String toString()
Class WmlSuite.Card
constructor:
public Card (String card_id, String card_title)
constatns:
// wrap mode
public static String WRAP="wrap";
public static String NOWRAP="nowrap";
// alignment
public static String LEFT="left";
public static String RIGHT="right";
public static String CENTER="center";
methods:
// set/get Id for Card
public void setId(String card_id)
public String getId()
// set/get title for card
public void setTitle(String card_title)
public String getTitle()
// set timer action for card (URL for request
and timeout in seconds)
// You can also clear this action if timeout
is negative.
public void setTimer(String url, int timer_value_in_sec)
// set accept action. Parameters are:
// accept_label and url (http://some_your_url or #card_id)
public void setAcccept(String accept_label, String
url)
// set accept action as a post request. Parameters are:
// accept label
// url
// array with name/value pairs. E.g. { "name1","value1","name2",value2"}
public void setAcccept(String accept_label,String
url,String []posts)
// set options action. Parameters are:
// options_label and url (http://some_your_url or #card_id)
public void setOptions(String options_label, String
url)
// set options action as a post request. Parameters are:
// options label
// url
// array with name/value pairs. E.g. { "name1","value1","name2",value2"}
public void setOptions(String options_label,String
url,String []posts)
// enable/disable Back key
// (by default is enabled)
public void enablePrev(boolean value)
// add paragraph. Default alignment is LEFT. Wrap
mode is on (WmlSuite.Card.WRAP)
public void addParagraph(String paragraph_code)
// add paragraph with specified alignment and
wrap modes
public void addParagraph(String paragraph_code,
String align, String wrap)
// returns card size (bytes)
public int size()
// generates WML code
public String toString()
Class WmlSuite.WmlFrame
Contains common methods
constructor:
public WmlFrame()
methods:
// returns line break
public static String LineBreak()
// returns bold string
public static String Bold(String what)
// returns italic string
public static String Italic(String what)
// returns underlined string
public static String Underline(String what)
// returns big string
public static String Big(String what)
// returns small string
public static String Small(String what)
// returns escaped string
// (replaces < with < etc.)
public static String Escape(String what)
// returns escaped Url
// (replaces & with &)
public static String Url(String what)
// returns unique ID
// (you may add this Id to your requests and avoid caching)
public static String getId(String what)
// returns version of package
public static String getVersion()
For downloading: WmlSuite.jar