jdiff

Class XMLToAPI

public class XMLToAPI extends Object

Creates an API object from an XML file. The API object is the internal representation of an API. All methods in this class for populating an API object are static. See the file LICENSE.txt for copyright details.
Field Summary
static booleanvalidateXML
If set, validate the XML which represents an API.
Method Summary
static voidaddClass(String name, String parent, boolean isAbstract, Modifiers modifiers)
Create a new class and add it to the current package.
static voidaddCtor(String type, Modifiers modifiers)
Add a constructor to the current class.
static voidaddException(String name, String type, String currElement)
Add an exception to the current method or constructor.
static voidaddField(String name, String type, boolean isTransient, boolean isVolatile, String value, Modifiers modifiers)
Add a field to the current class.
static voidaddImplements(String name)
Add an inherited interface to the current class.
static voidaddInheritedElements()
Add the inherited methods and fields to each class in turn.
static voidaddInheritedElements(ClassAPI child, ClassAPI parent, String fqParentName)
Add all the inherited methods and fields in the second class to the first class, marking them as inherited from the second class.
static voidaddInterface(String name, String parent, boolean isAbstract, Modifiers modifiers)
Add an new interface and add it to the current package.
static voidaddMethod(String name, String returnType, boolean isAbstract, boolean isNative, boolean isSynchronized, Modifiers modifiers)
Add a method to the current class.
static voidaddPackage(String name)
Create a new package and add it to the API.
static voidaddParam(String name, String type)
Add a parameter to the current method.
static voidnameAPI(String name)
Set the name of the API object.
static APIreadFile(String filename, boolean createGlobalComments, String apiName)
Read the file where the XML representing the API is stored.

Field Detail

validateXML

public static boolean validateXML
If set, validate the XML which represents an API. By default, this is not set for reasons of efficiency, and also because if JDiff generated the XML, it should not need validating.

Method Detail

addClass

public static void addClass(String name, String parent, boolean isAbstract, Modifiers modifiers)
Create a new class and add it to the current package. Called by the XML parser.

Parameters: name The name of the class. parent The name of the parent class, null if no class is extended. modifiers Modifiers for this class.

addCtor

public static void addCtor(String type, Modifiers modifiers)
Add a constructor to the current class. Called by the XML parser.

Parameters: name The name of the constructor. type The type of the constructor. modifiers Modifiers for this constructor.

addException

public static void addException(String name, String type, String currElement)
Add an exception to the current method or constructor. Called by the XML parser.

Parameters: name The name of the parameter. type The type of the parameter. May be null in JDiff1.0.8 and earlier versions. currElement Name of the current element.

addField

public static void addField(String name, String type, boolean isTransient, boolean isVolatile, String value, Modifiers modifiers)
Add a field to the current class. Called by the XML parser.

Parameters: name The name of the field. type The type of the field, null if it is void. modifiers Modifiers for this field.

addImplements

public static void addImplements(String name)
Add an inherited interface to the current class. Called by the XML parser.

Parameters: name The name of the inherited interface.

addInheritedElements

public static void addInheritedElements()
Add the inherited methods and fields to each class in turn.

addInheritedElements

public static void addInheritedElements(ClassAPI child, ClassAPI parent, String fqParentName)
Add all the inherited methods and fields in the second class to the first class, marking them as inherited from the second class. Do not add a method or a field if it is already defined locally. Only elements at the specified visibility level or higher appear in the XML file. All that remains to be tested for a private element, which is never inherited. If the parent class inherits any classes or interfaces, call this method recursively with those parents.

addInterface

public static void addInterface(String name, String parent, boolean isAbstract, Modifiers modifiers)
Add an new interface and add it to the current package. Called by the XML parser.

Parameters: name The name of the interface. parent The name of the parent interface, null if no interface is extended.

addMethod

public static void addMethod(String name, String returnType, boolean isAbstract, boolean isNative, boolean isSynchronized, Modifiers modifiers)
Add a method to the current class. Called by the XML parser.

Parameters: name The name of the method. returnType The return type of the method, null if it is void. modifiers Modifiers for this method.

addPackage

public static void addPackage(String name)
Create a new package and add it to the API. Called by the XML parser.

Parameters: name The name of the package.

addParam

public static void addParam(String name, String type)
Add a parameter to the current method. Called by the XML parser. Constuctors have their type (signature) in an attribute, since it is often shorter and makes parsing a little easier.

Parameters: name The name of the parameter. type The type of the parameter, null if it is void.

nameAPI

public static void nameAPI(String name)
Set the name of the API object.

Parameters: name The name of the package.

readFile

public static API readFile(String filename, boolean createGlobalComments, String apiName)
Read the file where the XML representing the API is stored.

Parameters: filename The full name of the file containing the XML representing the API crateGlobalComments If set, then store possible comments apiName The simple name of the API file. If -oldapidir and -newapidir are not used, then this is the same as the filename parameter