Class XUL2Swing

java.lang.Object
  extended by XUL2Swing

public class XUL2Swing
extends java.lang.Object

tabs need to generate events. Class to transform a XUL document into a Java document. The primary entry point is the translate() method, which requires an XMLDoc object containing the XUL document to translate. The translate() method returns a LinkedList containing the translated java code. The program expects several parameters: 1. The path to the XUL source file. 2. The name of the Java class to generate. 3. The directory in which to store the class file. 4. Several operational options. See setParameters method.

Version:
1.0
Author:
Paul Medlock

Nested Class Summary
 class XUL2Swing.ActionMethods
          Internal class to manage the stack of create methods and action listeners for xlateNode().
 class XUL2Swing.MyException
           
 
Field Summary
private  java.lang.String box
           
private  java.util.LinkedList<java.lang.String> clas
           
private static boolean consts
           
private  boolean firstEvent
           
private static boolean foldem
           
private  boolean fontVars
           
private  java.util.LinkedList<java.lang.String> gets
           
private static boolean handlers
           
private  java.util.LinkedList<java.lang.String> head
           
private  int istg
           
private  java.util.LinkedList<java.util.LinkedList<java.lang.String>> java
           
private  int L2R
           
private static java.lang.String level
           
private  boolean listclass
           
private static boolean listen
           
private  java.util.LinkedList<java.lang.String> load
           
private  boolean loaded
           
private  java.util.LinkedList<java.lang.String> menu
           
private  boolean menus
           
private  XUL2Swing.ActionMethods methods
           
(package private)  java.util.HashMap<java.lang.String,java.lang.String> nameMap
           
private  java.lang.String ndnt
           
private  int ndx
           
private  int nrSubs
           
private  int NRSUBS
           
private  java.lang.String params
           
private  boolean radstring
           
private  java.util.LinkedList<java.lang.String> save
           
private  java.util.LinkedList<java.lang.String> stgs
           
private  int T2B
           
private  int UNK
           
private  java.util.LinkedList<java.lang.String> vars
           
private  XMLDoc xul
           
 
Constructor Summary
XUL2Swing()
           
 
Method Summary
private  void addAction(org.w3c.dom.Node _node, java.lang.String _name)
          Generate an action event handler stub for the specified id.
private  boolean addLoadAndSaveMethods(java.lang.String _methodName, java.lang.String _params)
          Generate the headers for a load and a save method.
private  void boundBox(java.util.LinkedList<java.lang.String> _method, java.lang.String _name, java.lang.String _id, org.w3c.dom.Node _node)
          Set the sizes and position of the specified box.
private  java.lang.String capStr(java.lang.String _s)
           
 java.lang.String capString(java.lang.String _inString)
          Capitalize the first letter of the specified string if it is a letter.
private  java.lang.String fixConst(java.lang.String _id)
          Removes dashes and underlines and capitalizes the next letter in the specified string to create a camelCase name.
private  java.lang.String fixId(java.lang.String _id)
          Removes dashes and underlines and capitalizes the next letter in the specified string to create a camelCase name.
private  int getDirection(org.w3c.dom.Node _node, java.lang.String _default)
          Obtains the box orientation from the specified XUL element.
private  java.lang.String getStyle(org.w3c.dom.Node _node, java.lang.String _style, java.lang.String _default)
          Extracts the style value in the style attribute according to the specified style name.
static void main(java.lang.String[] args)
          Obtain the command line parameters, load the specified XUL file, and start the translation.
private  java.lang.String makeActionStringConst(java.lang.String _value)
          Adds a string final to the strings section of the listener class, and returns the name of the string constant.
private  void makeBox(java.util.LinkedList<java.lang.String> _method, java.lang.String _name, int _dir)
          Make a container according to the value of the box constant.
private  void makeGetter(org.w3c.dom.Node _node, java.lang.String _typeName, java.lang.String _getName, java.lang.String _varName)
           
private  java.lang.String makeName(java.lang.String _name, java.lang.String _id)
          If the id parameter is provided, then returns that.
private  java.lang.String makeStringConst(java.lang.String _prefix, java.lang.String _id, java.lang.String _value)
          Adds a string final to the strings section of the class, and returns the name of the string constant.
 org.w3c.dom.Document newDocument()
          Convenience method to create an empty document.
 void serialize(org.w3c.dom.Document _doc, java.lang.String _fileName)
          Convenience method to serialize the specified Document object to the specified file.
static void serialize(java.util.LinkedList<java.lang.String> _list, java.lang.String _fileName)
          Convenience method to serialize the specified LinkedList object that contains String objects to the specified file.
private static void setParameters(java.lang.String[] args)
          Visit each command-line parameter after the first three to determine the operational parameters for the run.
private  boolean shareRef(java.lang.String _id)
          Returns true if the specified string begins with a question mark, which indicates the the id is to be private.
private  java.lang.String text2html(java.lang.String _text)
          Place the specified string inside an element, converting all occurances of "\n" to
.
 void translate(java.lang.String _name, XMLDoc _xul, java.lang.String _dir)
          Initialize the output object, and then translate the XUL input.
private  java.lang.String xlateBox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateButton(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateCheckbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateDeck(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateDescription(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateGrid(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateGroupbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateHbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateLabel(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateListbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateMenu(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateMenubar(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateMenuitem(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateMenulist(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
          TBD: This method and the other menu object translators below should translate into something appropriate when the menulist element is not within a menubar element.
private  java.lang.String xlateMenupopup(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateNode(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
          Traverse the XUL document to create the Swing components equivalent to the XUL objects.
private  java.lang.String xlateRadio(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateRadiogroup(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateTabbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateTabpanel(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateTextbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
          Creates a JTextField object if rows is missing or its value is 0 or 1.
private  java.lang.String xlateVbox(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
private  java.lang.String xlateWindow(org.w3c.dom.Node _node, java.util.LinkedList<java.lang.String> _method, java.lang.String _pName, int _dir, boolean _ldSave, java.lang.String _param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NRSUBS

private final int NRSUBS
See Also:
Constant Field Values

UNK

private final int UNK
See Also:
Constant Field Values

T2B

private final int T2B
See Also:
Constant Field Values

L2R

private final int L2R
See Also:
Constant Field Values

ndnt

private final java.lang.String ndnt
See Also:
Constant Field Values

params

private final java.lang.String params
See Also:
Constant Field Values

box

private java.lang.String box

consts

private static boolean consts

foldem

private static boolean foldem

listen

private static boolean listen

level

private static java.lang.String level

handlers

private static boolean handlers

loaded

private boolean loaded

listclass

private boolean listclass

radstring

private boolean radstring

menus

private boolean menus

firstEvent

private boolean firstEvent

fontVars

private boolean fontVars

nrSubs

private int nrSubs

ndx

private int ndx

istg

private int istg

xul

private XMLDoc xul

head

private java.util.LinkedList<java.lang.String> head

clas

private java.util.LinkedList<java.lang.String> clas

stgs

private java.util.LinkedList<java.lang.String> stgs

vars

private java.util.LinkedList<java.lang.String> vars

gets

private java.util.LinkedList<java.lang.String> gets

load

private java.util.LinkedList<java.lang.String> load

save

private java.util.LinkedList<java.lang.String> save

menu

private java.util.LinkedList<java.lang.String> menu

java

private java.util.LinkedList<java.util.LinkedList<java.lang.String>> java

methods

private XUL2Swing.ActionMethods methods

nameMap

java.util.HashMap<java.lang.String,java.lang.String> nameMap
Constructor Detail

XUL2Swing

public XUL2Swing()
Method Detail

capString

public java.lang.String capString(java.lang.String _inString)
Capitalize the first letter of the specified string if it is a letter.

Parameters:
_inString - is the string to capitalize.
Returns:
the capitalized string.

newDocument

public org.w3c.dom.Document newDocument()
Convenience method to create an empty document.

Returns:
a new Document object.

serialize

public void serialize(org.w3c.dom.Document _doc,
                      java.lang.String _fileName)
Convenience method to serialize the specified Document object to the specified file. Useful for taking a snapshot of the document while debugging.

Parameters:
_doc - contains the document to be serialized.
_fileName - names the file to which to serialize the document.

serialize

public static void serialize(java.util.LinkedList<java.lang.String> _list,
                             java.lang.String _fileName)
Convenience method to serialize the specified LinkedList object that contains String objects to the specified file.

Parameters:
_list - contains the message to be serialized.
_fileName - names the file to which to serialize the document.

text2html

private java.lang.String text2html(java.lang.String _text)
Place the specified string inside an element, converting all occurances of "\n" to
. Implements multi-line tooltips from standard XUL tooltips, which, by the way, don't actually do anything with the \n.

Parameters:
_text - is the specified string to convert.
Returns:
the html string.

makeStringConst

private java.lang.String makeStringConst(java.lang.String _prefix,
                                         java.lang.String _id,
                                         java.lang.String _value)
Adds a string final to the strings section of the class, and returns the name of the string constant.

Parameters:
_value - is the string constant.
Returns:
the name of the generated string constant.

makeActionStringConst

private java.lang.String makeActionStringConst(java.lang.String _value)
Adds a string final to the strings section of the listener class, and returns the name of the string constant.

Parameters:
_value - is the string constant.
Returns:
the name of the generated string constant.

makeName

private java.lang.String makeName(java.lang.String _name,
                                  java.lang.String _id)
If the id parameter is provided, then returns that. Otherwise, increments the ndx, and appends it as a four-digit string to the specified name.

Parameters:
_name - to use to build the Java variable name.
_id - trumps the name parameter if available.
Returns:
the id parameter or the string composed of the specified name and the index.

capStr

private java.lang.String capStr(java.lang.String _s)

shareRef

private boolean shareRef(java.lang.String _id)
Returns true if the specified string begins with a question mark, which indicates the the id is to be private. In that case, XUL2Swing will not provide a getter for the variable.

Parameters:
_id - is the string to test.
Returns:
true when the string starts with a question mark.

fixId

private java.lang.String fixId(java.lang.String _id)
Removes dashes and underlines and capitalizes the next letter in the specified string to create a camelCase name.

Parameters:
_id - is the string to convert from using dashes.
Returns:
the camelCase form of the string.

fixConst

private java.lang.String fixConst(java.lang.String _id)
Removes dashes and underlines and capitalizes the next letter in the specified string to create a camelCase name.

Parameters:
_id - is the string to convert from using dashes.
Returns:
the camelCase form of the string.

getDirection

private int getDirection(org.w3c.dom.Node _node,
                         java.lang.String _default)
Obtains the box orientation from the specified XUL element.

Parameters:
_node - is the XUL element to examine.
_default - is default orientation for the XUL element.
Returns:
the orientation constant T2B or L2R.

getStyle

private java.lang.String getStyle(org.w3c.dom.Node _node,
                                  java.lang.String _style,
                                  java.lang.String _default)
Extracts the style value in the style attribute according to the specified style name. Form of the style attribute value is stylename:stylevalue[;stylename:stylevalue]

Parameters:
_node - is the element from which to obtain the style.
_style - is the style name.
_default - is the default value to use if the specified style doesn't exist.
Returns:
the value of the specified style, or the specified default if the specified style is empty.

makeBox

private void makeBox(java.util.LinkedList<java.lang.String> _method,
                     java.lang.String _name,
                     int _dir)
Make a container according to the value of the box constant. This is for testing. It should be either "Box" or "Container".

Parameters:
_name - is the variable name for a container.
_dir - specifies if child components are to be arranged vertically or horizontally, if the container is a Box.

boundBox

private void boundBox(java.util.LinkedList<java.lang.String> _method,
                      java.lang.String _name,
                      java.lang.String _id,
                      org.w3c.dom.Node _node)
Set the sizes and position of the specified box. Also disable, set color, and add a tooltip as appropriate.

Parameters:
_name - is the name of the variable referring to the component.
_node - is the XUL node being translated.

addLoadAndSaveMethods

private boolean addLoadAndSaveMethods(java.lang.String _methodName,
                                      java.lang.String _params)
Generate the headers for a load and a save method. The names are generated by appending either "load_" or "save_" to the specified method name, as appropriate.

Parameters:
_methodName - is the root name of the method.
_params - are the parameters to expect to be provided.

addAction

private void addAction(org.w3c.dom.Node _node,
                       java.lang.String _name)
Generate an action event handler stub for the specified id.

Parameters:
_node - is the XUL information node being processed.
_name - is the id associated with the XUL node.

makeGetter

private void makeGetter(org.w3c.dom.Node _node,
                        java.lang.String _typeName,
                        java.lang.String _getName,
                        java.lang.String _varName)

xlateBox

private java.lang.String xlateBox(org.w3c.dom.Node _node,
                                  java.util.LinkedList<java.lang.String> _method,
                                  java.lang.String _pName,
                                  int _dir,
                                  boolean _ldSave,
                                  java.lang.String _param)
                           throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateButton

private java.lang.String xlateButton(org.w3c.dom.Node _node,
                                     java.util.LinkedList<java.lang.String> _method,
                                     java.lang.String _pName,
                                     int _dir,
                                     boolean _ldSave,
                                     java.lang.String _param)
                              throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateCheckbox

private java.lang.String xlateCheckbox(org.w3c.dom.Node _node,
                                       java.util.LinkedList<java.lang.String> _method,
                                       java.lang.String _pName,
                                       int _dir,
                                       boolean _ldSave,
                                       java.lang.String _param)
                                throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateDeck

private java.lang.String xlateDeck(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateDescription

private java.lang.String xlateDescription(org.w3c.dom.Node _node,
                                          java.util.LinkedList<java.lang.String> _method,
                                          java.lang.String _pName,
                                          int _dir,
                                          boolean _ldSave,
                                          java.lang.String _param)
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.

xlateGrid

private java.lang.String xlateGrid(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateGroupbox

private java.lang.String xlateGroupbox(org.w3c.dom.Node _node,
                                       java.util.LinkedList<java.lang.String> _method,
                                       java.lang.String _pName,
                                       int _dir,
                                       boolean _ldSave,
                                       java.lang.String _param)
                                throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateHbox

private java.lang.String xlateHbox(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateLabel

private java.lang.String xlateLabel(org.w3c.dom.Node _node,
                                    java.util.LinkedList<java.lang.String> _method,
                                    java.lang.String _pName,
                                    int _dir,
                                    boolean _ldSave,
                                    java.lang.String _param)
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.

xlateListbox

private java.lang.String xlateListbox(org.w3c.dom.Node _node,
                                      java.util.LinkedList<java.lang.String> _method,
                                      java.lang.String _pName,
                                      int _dir,
                                      boolean _ldSave,
                                      java.lang.String _param)
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.

xlateMenubar

private java.lang.String xlateMenubar(org.w3c.dom.Node _node,
                                      java.util.LinkedList<java.lang.String> _method,
                                      java.lang.String _pName,
                                      int _dir,
                                      boolean _ldSave,
                                      java.lang.String _param)
                               throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateMenu

private java.lang.String xlateMenu(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateMenulist

private java.lang.String xlateMenulist(org.w3c.dom.Node _node,
                                       java.util.LinkedList<java.lang.String> _method,
                                       java.lang.String _pName,
                                       int _dir,
                                       boolean _ldSave,
                                       java.lang.String _param)
                                throws XUL2Swing.MyException
TBD: This method and the other menu object translators below should translate into something appropriate when the menulist element is not within a menubar element. Right now the code just bails.

Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateMenupopup

private java.lang.String xlateMenupopup(org.w3c.dom.Node _node,
                                        java.util.LinkedList<java.lang.String> _method,
                                        java.lang.String _pName,
                                        int _dir,
                                        boolean _ldSave,
                                        java.lang.String _param)
                                 throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateMenuitem

private java.lang.String xlateMenuitem(org.w3c.dom.Node _node,
                                       java.util.LinkedList<java.lang.String> _method,
                                       java.lang.String _pName,
                                       int _dir,
                                       boolean _ldSave,
                                       java.lang.String _param)
                                throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateRadiogroup

private java.lang.String xlateRadiogroup(org.w3c.dom.Node _node,
                                         java.util.LinkedList<java.lang.String> _method,
                                         java.lang.String _pName,
                                         int _dir,
                                         boolean _ldSave,
                                         java.lang.String _param)
                                  throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateRadio

private java.lang.String xlateRadio(org.w3c.dom.Node _node,
                                    java.util.LinkedList<java.lang.String> _method,
                                    java.lang.String _pName,
                                    int _dir,
                                    boolean _ldSave,
                                    java.lang.String _param)
                             throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateTabbox

private java.lang.String xlateTabbox(org.w3c.dom.Node _node,
                                     java.util.LinkedList<java.lang.String> _method,
                                     java.lang.String _pName,
                                     int _dir,
                                     boolean _ldSave,
                                     java.lang.String _param)
                              throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateTabpanel

private java.lang.String xlateTabpanel(org.w3c.dom.Node _node,
                                       java.util.LinkedList<java.lang.String> _method,
                                       java.lang.String _pName,
                                       int _dir,
                                       boolean _ldSave,
                                       java.lang.String _param)
                                throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateTextbox

private java.lang.String xlateTextbox(org.w3c.dom.Node _node,
                                      java.util.LinkedList<java.lang.String> _method,
                                      java.lang.String _pName,
                                      int _dir,
                                      boolean _ldSave,
                                      java.lang.String _param)
                               throws XUL2Swing.MyException
Creates a JTextField object if rows is missing or its value is 0 or 1. Creates a JTextArea otherwise.

Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateVbox

private java.lang.String xlateVbox(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateWindow

private java.lang.String xlateWindow(org.w3c.dom.Node _node,
                                     java.util.LinkedList<java.lang.String> _method,
                                     java.lang.String _pName,
                                     int _dir,
                                     boolean _ldSave,
                                     java.lang.String _param)
                              throws XUL2Swing.MyException
Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

xlateNode

private java.lang.String xlateNode(org.w3c.dom.Node _node,
                                   java.util.LinkedList<java.lang.String> _method,
                                   java.lang.String _pName,
                                   int _dir,
                                   boolean _ldSave,
                                   java.lang.String _param)
                            throws XUL2Swing.MyException
Traverse the XUL document to create the Swing components equivalent to the XUL objects. Each component is represented by an object variable or a local variable depending on the component. A getter method is added for each object variable. Code is added to the create() method to instantiate and initialize the component. Note that not all attributes are supported for all XUL elements.

Parameters:
_node - is the XUL node from which to generate Java output.
_method - is either the menu context or window context list
_pName - is the name of the parent of the Swing object
_dir - is the direction of the parent (T2B or L2R)
_ldSave - is a boolean indicator that the component can be added to a load/save method. If so, generate code to load and save the component from an XML data object if the xpath attribute is specified for the XUL object.
_param - is a free parameter whose meaning and value is determined by the caller.
Returns:
the name of the reference variable for the component.
Throws:
XUL2Swing.MyException

translate

public void translate(java.lang.String _name,
                      XMLDoc _xul,
                      java.lang.String _dir)
Initialize the output object, and then translate the XUL input.

Parameters:
_name - is the name of the class to generate.
_xul - is the input XUL document.
_dir - is the name of the output directory.

setParameters

private static void setParameters(java.lang.String[] args)
Visit each command-line parameter after the first three to determine the operational parameters for the run. Parameters are based on keywords rather than position just to make this a little bit easier. Here are the keywords and their meanings: STRING generates a string constant group at the top of the module. FOLD removes duplicate strings when STRING is specified. LOG sets the log level in the generated code to one (1). DEBUG sets the log level in the generated code to two (2). DEEP sets the log level in the generated code to three (3). VERBOSE sets the log level in the generated code to four (4). LISTENER generates ActionListener implemention modules.

Parameters:
args - are the command line parameters.

main

public static void main(java.lang.String[] args)
Obtain the command line parameters, load the specified XUL file, and start the translation.

Parameters:
args - arg1 = path of the XUL file arg2 = name of Java class to generate arg3 = directory into which to store the generated file(s) arg4 = option to generate string constants for localization. (true/default=false) arg5 = option to not fold string constants. (default=true/false) arg6 = optional log level for the generated classes (0..) arg7 = optional directive to generate action listener file (true/default=false)