jaxx.compiler
Class CompiledObject

java.lang.Object
  extended by jaxx.compiler.CompiledObject
Direct Known Subclasses:
BeanValidatorHandler.CompiledBeanValidator, JSpinnerHandler.CompiledSpinner, JTabbedPaneHandler.CompiledTabbedPane, ScriptInitializer

public class CompiledObject
extends Object

Represents an object in the .java file being generated during compilation. There is a CompiledObject for each class tag encountered, and certain tags may generate additional objects for various reasons.


Nested Class Summary
 class CompiledObject.ChildRef
           
 
Constructor Summary
CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler)
          Creates a new CompiledObject.
CompiledObject(String id, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force)
          Creates a new CompiledObject.
CompiledObject(String id, String javaCode, ClassDescriptor objectClass, JAXXCompiler compiler, boolean force)
          Creates a new CompiledObject.
 
Method Summary
 void addChild(CompiledObject child, JAXXCompiler compiler)
          Adds a child component to this container.
 void addChild(CompiledObject child, String constraints, JAXXCompiler compiler)
          Adds a child component to this container.
 void addClientProperty(String property, String value)
           
 void addEventHandler(String eventId, MethodDescriptor addMethod, MethodDescriptor listenerMethod, String code, JAXXCompiler compiler)
          Adds an event listener to this object.
 void addEventHandler(String eventId, Method addMethod, Method listenerMethod, String code, JAXXCompiler compiler)
           
 void addProperty(String property, String value)
          Stores a property for this object.
 void appendAdditionCode(String code)
          Appends code to the addition code block.
 void appendInitializationCode(String code)
          Appends code to the initialization code block.
 void finalizeCompiler(JAXXCompiler compiler)
           
 String getAdditionCode()
          Returns Java code to complete final setup on this object.
 String getAdditionMethodName()
          Returns the name of the method that should be generated in the compiled .java file in order to add children to this object.
 List<CompiledObject.ChildRef> getChilds()
           
 Map<String,String> getClientProperties()
           
 String getClientProperty(String key)
           
 String getConstructorParams()
          Returns a list of comma-separated Java code snippets that represent the parameters to pass to this object's constructor.
 String getCreationMethodName()
          Returns the name of the method that should be generated in the compiled .java file in order to create this object.
 CompiledObjectDecorator getDecorator()
           
 String getGenericTypes()
           
 int getGenericTypesLength()
           
 String getGetterName()
           
 String getId()
          Returns this object's id.
protected  String getInitializationCode(EventHandler handler, JAXXCompiler compiler)
           
 String getInitializationCode(JAXXCompiler compiler)
          Returns the code that performs basic initialization of this object, after it has already been constructed.
 String getInitializer()
           
 String getJavaBeanInitCode()
           
 String getJavaCode()
          Returns Java code used to refer to this object in the compiled Java file.
 String getJavaCodeForProperty(String property)
           
 ClassDescriptor getObjectClass()
          Returns the type of this object.
 ClassDescriptor getOverrideType()
           
 CompiledObject getParent()
          Returns this object's parent container.
 Map<?,?> getProperties()
          Returns all properties which have been set for this object.
 String getStyleClass()
          Returns this object's CSS style class.
 boolean hasClientProperties()
           
 boolean isJavaBean()
           
 boolean isOverride()
          True if this object overrides an object in the superclass of the class being compiled.
 boolean isOverrideType()
          true when overrides an object in the superclass of the class being compiled AND type is also override.
static boolean isValidID(String id)
           
 void setConstructorParams(String constructorParams)
          Sets the parameters to pass to this object's constructor.
 void setDecorator(CompiledObjectDecorator decorator)
           
 void setGenericTypes(String[] genericTypes)
           
 void setInitializer(String initializer)
           
 void setJavaBean(boolean javaBean)
           
 void setJavaBeanInitCode(String javaBeanInitCode)
           
 void setOverride(boolean override)
          Sets whether this class overrides an identically-named object in the parent class.
 void setOverrideType(ClassDescriptor overrideType)
           
 void setParent(CompiledObject parent)
          Sets this object's parent container.
 void setStyleClass(String styleClass)
          Sets this object's CSS style class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompiledObject

public CompiledObject(String id,
                      ClassDescriptor objectClass,
                      JAXXCompiler compiler)
Creates a new CompiledObject. To be useful, the object should be registered with a JAXXCompiler using registerCompiledObject.

Parameters:
id - the object's id
objectClass - the object's class
compiler - the current JAXXCompiler
Throws:
NullPointerException - if id or class is null

CompiledObject

public CompiledObject(String id,
                      ClassDescriptor objectClass,
                      JAXXCompiler compiler,
                      boolean force)
Creates a new CompiledObject. To be useful, the object should be registered with a JAXXCompiler using registerCompiledObject.

Parameters:
id - the object's id
objectClass - the object's class
compiler - the current JAXXCompiler
force - true to force acceptance of invalid ids
Throws:
NullPointerException - if id or class is null

CompiledObject

public CompiledObject(String id,
                      String javaCode,
                      ClassDescriptor objectClass,
                      JAXXCompiler compiler,
                      boolean force)
               throws CompilerException
Creates a new CompiledObject. To be useful, the object should be registered with a JAXXCompiler using registerCompiledObject.

Parameters:
id - the object's id
javaCode - Java code referring to the object
objectClass - the object's class
force - true to force acceptance of invalid ids
compiler - the current JAXXCompiler
Throws:
CompilerException - if the id is not a valid Java identifier
NullPointerException - if id or class is null
Method Detail

isValidID

public static boolean isValidID(String id)

isOverride

public boolean isOverride()
True if this object overrides an object in the superclass of the class being compiled. For this to be true, the class currently being compiled must be a subclass of another JAXXObject which has an identically-named object.

Returns:
true if this object is an override
See Also:
setOverride(boolean)

isOverrideType

public boolean isOverrideType()
true when overrides an object in the superclass of the class being compiled AND type is also override.

Returns:
true if this object is an override AND override type

setOverride

public void setOverride(boolean override)
Sets whether this class overrides an identically-named object in the parent class.

Parameters:
override - true if this object is an override
See Also:
isOverride()

getStyleClass

public String getStyleClass()
Returns this object's CSS style class.

Returns:
the value of the styleClass attribute

setStyleClass

public void setStyleClass(String styleClass)
Sets this object's CSS style class.

Parameters:
styleClass - the new style class

getParent

public CompiledObject getParent()
Returns this object's parent container. Non-visual components (and the root container) return null.

Returns:
the object's parent container

setParent

public void setParent(CompiledObject parent)
               throws IllegalArgumentException
Sets this object's parent container.

Parameters:
parent - the parent container
Throws:
IllegalArgumentException - if parent is not a Container

getCreationMethodName

public String getCreationMethodName()
Returns the name of the method that should be generated in the compiled .java file in order to create this object. This is just a suggestion and may be ignored.

Returns:
the suggested name of the method which initializes this object

getAdditionMethodName

public String getAdditionMethodName()
Returns the name of the method that should be generated in the compiled .java file in order to add children to this object. This is just a suggestion and may be ignored.

Returns:
the suggested name of the method which completes this object's setup

getObjectClass

public ClassDescriptor getObjectClass()
Returns the type of this object.

Returns:
the class this CompiledObject represents

getId

public String getId()
Returns this object's id. Generally, a field with this name will be created in the compiled .java file in order to represent this object.

Returns:
the id used to refer to this object

getJavaCode

public String getJavaCode()
Returns Java code used to refer to this object in the compiled Java file. This is usually the same as its id.

Returns:
the Java code for this object

getJavaCodeForProperty

public String getJavaCodeForProperty(String property)

getConstructorParams

public String getConstructorParams()
Returns a list of comma-separated Java code snippets that represent the parameters to pass to this object's constructor.

Returns:
the raw constructor params
See Also:
setConstructorParams(java.lang.String)

setConstructorParams

public void setConstructorParams(String constructorParams)
Sets the parameters to pass to this object's constructor.

Parameters:
constructorParams - comma-separated Java code snippets representing constructor params
See Also:
getConstructorParams()

getInitializer

public String getInitializer()

setInitializer

public void setInitializer(String initializer)

getInitializationCode

public String getInitializationCode(JAXXCompiler compiler)
Returns the code that performs basic initialization of this object, after it has already been constructed. This basic code should not reference any other CompiledObjects as they may not have been created yet.

Parameters:
compiler - compiler to use
Returns:
the code which initializes this object

getInitializationCode

protected String getInitializationCode(EventHandler handler,
                                       JAXXCompiler compiler)

getAdditionCode

public String getAdditionCode()
Returns Java code to complete final setup on this object. This code may reference other CompiledObjects, as they are guaranteed to have all been created by this point.

Returns:
code which adds children and performs final setup

appendInitializationCode

public void appendInitializationCode(String code)
Appends code to the initialization code block. A line separator is automatically appended to the end.

Parameters:
code - the code to add to the initialization block
See Also:
getInitializationCode(jaxx.compiler.JAXXCompiler)

appendAdditionCode

public void appendAdditionCode(String code)
Appends code to the addition code block. A line separator is automatically appended to the end.

Parameters:
code - the code to add to the addition block
See Also:
getAdditionCode()

addProperty

public void addProperty(String property,
                        String value)
Stores a property for this object. The only effect of calling this method is that the property will be returned by getProperties().

Parameters:
property - the name of the property
value - the property's value
See Also:
getProperties()

hasClientProperties

public boolean hasClientProperties()

addClientProperty

public void addClientProperty(String property,
                              String value)

getClientProperty

public String getClientProperty(String key)

getClientProperties

public Map<String,String> getClientProperties()

getProperties

public Map<?,?> getProperties()
Returns all properties which have been set for this object.

Returns:
a Map containing all properties defined for this object
See Also:
addProperty(java.lang.String, java.lang.String)

addEventHandler

public void addEventHandler(String eventId,
                            Method addMethod,
                            Method listenerMethod,
                            String code,
                            JAXXCompiler compiler)

addEventHandler

public void addEventHandler(String eventId,
                            MethodDescriptor addMethod,
                            MethodDescriptor listenerMethod,
                            String code,
                            JAXXCompiler compiler)
Adds an event listener to this object. The generated code will appear in the initialization block.

Parameters:
eventId - unique (per CompiledObject) identifier for the event handler
addMethod - the method which adds the event listener
listenerMethod - the method (in the listener class) which is called when the event is fired
code - the Java code for the listenerMethod's body
compiler - the current JAXXCompiler
See Also:
getInitializationCode(jaxx.compiler.JAXXCompiler)

addChild

public void addChild(CompiledObject child,
                     JAXXCompiler compiler)
              throws CompilerException
Adds a child component to this container. The child is added without layout constraints.

Parameters:
child - the component to add
compiler - the current JAXXCompiler
Throws:
CompilerException - if this object is not a container
See Also:
addChild(CompiledObject, String, JAXXCompiler)

addChild

public void addChild(CompiledObject child,
                     String constraints,
                     JAXXCompiler compiler)
              throws CompilerException
Adds a child component to this container. This variant allows the Java code for a layout constraints object to be specified.

Parameters:
child - the component to add
constraints - Java code for the layout constraints object
compiler - the current JAXXCompiler
Throws:
CompilerException - if this object is not a container
See Also:
addChild(CompiledObject, JAXXCompiler)

toString

public String toString()
Overrides:
toString in class Object

getGenericTypes

public String getGenericTypes()

setGenericTypes

public void setGenericTypes(String[] genericTypes)

isJavaBean

public boolean isJavaBean()

setJavaBean

public void setJavaBean(boolean javaBean)

getOverrideType

public ClassDescriptor getOverrideType()

setOverrideType

public void setOverrideType(ClassDescriptor overrideType)

getJavaBeanInitCode

public String getJavaBeanInitCode()

setJavaBeanInitCode

public void setJavaBeanInitCode(String javaBeanInitCode)

getChilds

public List<CompiledObject.ChildRef> getChilds()

getDecorator

public CompiledObjectDecorator getDecorator()

setDecorator

public void setDecorator(CompiledObjectDecorator decorator)

finalizeCompiler

public void finalizeCompiler(JAXXCompiler compiler)

getGenericTypesLength

public int getGenericTypesLength()

getGetterName

public String getGetterName()


Copyright © 2008-2010 CodeLutin. All Rights Reserved.