com.brunchboy.util.swing.relativelayout
Class XmlConstraintBuilder

java.lang.Object
  |
  +--com.brunchboy.util.swing.relativelayout.XmlConstraintBuilder

public class XmlConstraintBuilder
extends Object

A helper class providing the ability to add constraints to a RelativeLayout by parsing XML definition files.

Version:
$Id: XmlConstraintBuilder.java,v 1.2 2002/08/16 05:13:04 jim Exp $
Author:
James Elliott, jim@brunchboy.com

Nested Class Summary
static class XmlConstraintBuilder.ParseException
          An exception subclass with which we'll wrap any exceptions thrown in parsing the constraints specifications, to shield our clients from details about the libraries we use, unless they want to know about them.
 
Field Summary
static String CONSTRAINT_SET_DTD_PUBLIC
          The public identifier by which our constraint-set DTD can be resolved.
static String CONSTRAINT_SET_DTD_SYSTEM
          The system identifier by which our constraint-set DTD is loaded.
static String VERSION
          Provides access to the CVS version of this class.
 
Constructor Summary
XmlConstraintBuilder()
          Sets up the necessary resources for parsing XML specifications.
 
Method Summary
protected  void addComponentConstraint(String component, Element constraint, RelativeLayout layout)
          Utility method called once we have the element corresponding to a constraint that needs to be created.
protected  void addConstraints(Document document, RelativeLayout layout)
          Utility method to do the work of walking the document tree generated by parsing the supplied XML constraint specifications, and turning these into actual constraints to be added to the layout.
 void addConstraints(File file, RelativeLayout layout)
          Add constraints parsed from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Provides access to the CVS version of this class.

See Also:
Constant Field Values

CONSTRAINT_SET_DTD_PUBLIC

public static final String CONSTRAINT_SET_DTD_PUBLIC
The public identifier by which our constraint-set DTD can be resolved.

See Also:
Constant Field Values

CONSTRAINT_SET_DTD_SYSTEM

public static final String CONSTRAINT_SET_DTD_SYSTEM
The system identifier by which our constraint-set DTD is loaded.

See Also:
Constant Field Values
Constructor Detail

XmlConstraintBuilder

public XmlConstraintBuilder()
Sets up the necessary resources for parsing XML specifications. You can reuse an instance multiple times, but should not share one between threads.

Method Detail

addComponentConstraint

protected void addComponentConstraint(String component,
                                      Element constraint,
                                      RelativeLayout layout)
                               throws DataConversionException,
                                      XmlConstraintBuilder.ParseException
Utility method called once we have the element corresponding to a constraint that needs to be created. Creates the corresponding object and adds it to the layout.

Parameters:
component - the name of the component being constrained.
constraint - the XML element representing the constraint.
layout - the layout to which the constraints should be added.
Throws:
DataConversionException - if there's a problem parsing an attribute.
XmlConstraintBuilder.ParseException - if there's a problem parsing the constraint.
XmlConstraintBuilder.ParseException

addConstraints

protected void addConstraints(Document document,
                              RelativeLayout layout)
                       throws DataConversionException,
                              XmlConstraintBuilder.ParseException
Utility method to do the work of walking the document tree generated by parsing the supplied XML constraint specifications, and turning these into actual constraints to be added to the layout.

Parameters:
document - the parsed constraint document.
layout - the layout to which the constraints should be added.
Throws:
DataConversionException - if there's a problem parsing an attribute.
XmlConstraintBuilder.ParseException - if there's a problem parsing the constraint.
XmlConstraintBuilder.ParseException

addConstraints

public void addConstraints(File file,
                           RelativeLayout layout)
                    throws XmlConstraintBuilder.ParseException
Add constraints parsed from a file.

Parameters:
file - the file containing XML constraint specifications.
layout - the layout to which the parsed constraints should be added.
Throws:
XmlConstraintBuilder.ParseException - if there is a problem parsing the constraints.
XmlConstraintBuilder.ParseException