JFormDesigner 5.0.4 Runtime API

com.jformdesigner.runtime
Class FormLoader

java.lang.Object
  extended by com.jformdesigner.runtime.FormLoader

public class FormLoader
extends java.lang.Object

Loads the form model from a JFormDesigner .jfd file into memory. Use FormCreator to create Swing component instances.

The separation of the file loading and the component creation into two classes (FormLoader and FormCreator) enables you to cache the form model in memory. Using FormCreator it's possible to create multiple instances of a form from one form model.


Method Summary
static FormModel load(java.io.File file)
          Loads a form model from the specified file.
static FormModel load(java.io.InputStream in)
          Loads a form model from the given input stream.
static FormModel load(java.io.InputStream in, java.lang.ClassLoader classLoader)
          Loads a form model from the given input stream.
static FormModel load(java.lang.String resourceName)
          Loads a form model from the specified resource using the default class loader.
static FormModel load(java.lang.String resourceName, java.lang.ClassLoader classLoader)
          Loads a form model from the specified resource using the specified class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static FormModel load(java.lang.String resourceName)
                      throws java.lang.Exception
Loads a form model from the specified resource using the default class loader. Uses ClassLoader.getResourceAsStream(java.lang.String) to locate and load the form file.

Parameters:
resourceName - The name of the resource containing a form (e.g. "com/jformdesigner/examples/LoaderExample.jfd").
Returns:
The form model.
Throws:
java.lang.Exception - See load(InputStream) for details.

load

public static FormModel load(java.lang.String resourceName,
                             java.lang.ClassLoader classLoader)
                      throws java.lang.Exception
Loads a form model from the specified resource using the specified class loader. Uses ClassLoader.getResourceAsStream(java.lang.String) to locate and load the form file.

Parameters:
resourceName - The name of the resource containing a form (e.g. "com/jformdesigner/examples/LoaderExample.jfd").
classLoader - The class loader.
Returns:
The form model.
Throws:
java.lang.Exception - See load(InputStream) for details.

load

public static FormModel load(java.io.File file)
                      throws java.lang.Exception
Loads a form model from the specified file.

Parameters:
file - The file containing a form.
Returns:
The form model.
Throws:
java.lang.Exception - See load(InputStream) for details.

load

public static FormModel load(java.io.InputStream in)
                      throws java.lang.Exception
Loads a form model from the given input stream. Use this method if you want read a form e.g. from a database.

A BufferedInputStream is used to improve performance.

Parameters:
in - The input stream. Closed when this method returns.
Returns:
The form model.
Throws:
java.lang.IllegalArgumentException - If the input stream is null.
java.io.IOException - If an error occurred when reading from the input stream.
SAXParseException - If an error occurred when parsing the XML content.
java.lang.ClassNotFoundException - If a class used in the XML content is not found.
java.lang.ClassCastException - If the root object in the XML content is not a FormModel.
java.lang.Exception - If an other error occurred when decoding the XML content.

load

public static FormModel load(java.io.InputStream in,
                             java.lang.ClassLoader classLoader)
                      throws MultiException
Loads a form model from the given input stream. Use this method if you want read a form e.g. from a database.

A BufferedInputStream is used to improve performance.

Parameters:
in - The input stream. Closed when this method returns.
classLoader - The class loader used to load classes.
Returns:
The form model.
Throws:
java.lang.IllegalArgumentException - If the input stream is null.
MultiException - If a problem occurred when encoding the form model to XML.
java.lang.ClassCastException - If the root object in the XML content is not a FormModel.
Since:
1.0.1

JFormDesigner 5.0.4 Runtime API

Copyright (C) 2004-2012 FormDev Software GmbH. All rights reserved.