layout

com.canoo.ulc.community.layout.application
Class ULCXmlConstraintBuilder

java.lang.Object
  |
  +--com.canoo.ulc.community.layout.application.ULCXmlConstraintBuilder

public class ULCXmlConstraintBuilder
extends Object

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

Adapted to ULC by Seitter.Claus@muenchener-verein.de


Inner Class Summary
static class ULCXmlConstraintBuilder.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.
 
Constructor Summary
ULCXmlConstraintBuilder()
          Sets up the necessary resources for parsing XML specifications.
 
Method Summary
protected  void addComponentConstraint(String component, org.jdom.Element constraint, ULCRelativeLayoutPane layout)
          Utility method called once we have the element corresponding to a constraint that needs to be created.
protected  void addConstraints(org.jdom.Document document, ULCRelativeLayoutPane 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, ULCRelativeLayoutPane layout)
          Add constraints parsed from a file.
 void addConstraints(InputStream stream, ULCRelativeLayoutPane layout)
          Add constraints parsed from an input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTRAINT_SET_DTD_PUBLIC

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

CONSTRAINT_SET_DTD_SYSTEM

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

ULCXmlConstraintBuilder

public ULCXmlConstraintBuilder()
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,
                                      org.jdom.Element constraint,
                                      ULCRelativeLayoutPane layout)
                               throws org.jdom.DataConversionException,
                                      ULCXmlConstraintBuilder.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:
org.jdom.DataConversionException - if there's a problem parsing an attribute.
ULCXmlConstraintBuilder.ParseException - if there's a problem parsing the constraint.

addConstraints

protected void addConstraints(org.jdom.Document document,
                              ULCRelativeLayoutPane layout)
                       throws org.jdom.DataConversionException,
                              ULCXmlConstraintBuilder.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:
org.jdom.DataConversionException - if there's a problem parsing an attribute.
ULCXmlConstraintBuilder.ParseException - if there's a problem parsing the constraint.

addConstraints

public void addConstraints(File file,
                           ULCRelativeLayoutPane layout)
                    throws ULCXmlConstraintBuilder.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:
ULCXmlConstraintBuilder.ParseException - if there is a problem parsing the constraints.

addConstraints

public void addConstraints(InputStream stream,
                           ULCRelativeLayoutPane layout)
                    throws ULCXmlConstraintBuilder.ParseException
Add constraints parsed from an input stream.
Parameters:
stream - the input stream containing XML constraint specifications.
layout - the layout to which the parsed constraints should be added.
Throws:
ULCXmlConstraintBuilder.ParseException - if there is a problem parsing the constraints.

layout

Contact Etienne Studer for feedback.