org.glassfish.pfl.dynamic.codegen.impl
Class ClassGeneratorImpl

java.lang.Object
  extended by org.glassfish.pfl.dynamic.codegen.impl.ClassInfoBase
      extended by org.glassfish.pfl.dynamic.codegen.impl.ClassGeneratorImpl
All Implemented Interfaces:
AttributedObject, Node, ClassGenerator, ClassInfo

public final class ClassGeneratorImpl
extends ClassInfoBase
implements ClassGenerator, Node

Class used to generate a description of a class or interface. An interface is an abstract class, all of whose methods are abstract. Interfaces do not have a super class, an initializer, or constructors. Interfaces also do not have variables.

Note: the hashCode of a ClassGeneratorImpl changes whenever a method, constructor, or field is added, so do not put ClassGenerators into sets or maps unless they are fully populated.


Method Summary
 void accept(Visitor visitor)
          Accept the visitor and allow it to perform actions on this Node.
 FieldGenerator addField(int modifiers, Type type, String name)
           
 List<Object> attributes()
          Internal method for dynamic attribute support.
 Set<MethodInfo> constructorInfo()
           
 List<MethodGenerator> constructors()
           
<T extends Node>
T
copy(Class<T> cls)
          Make a deep copy of this node.
<T extends Node>
T
copy(Node newParent, Class<T> cls)
          Copy setting a new parent in the result.
 List<FieldGenerator> fields()
           
 Object get(int index)
          Internal method for dynamic attribute support.
<T extends Node>
T
getAncestor(Class<T> type)
          Return the first ancestor of this node of the given type, if any.
 int id()
          Return the unique ID of this node.
 BlockStatement initializer()
           
 void methodComplete(MethodGenerator mg)
           
 List<MethodGenerator> methods()
           
 Node parent()
          Return the Node that contains (and created) this Node.
 void parent(Node node)
          Set the parent to a new value.
 void set(int index, Object obj)
          Internal method for dynamic attribute support.
 MethodGenerator startConstructor(int modifiers, List<Type> exceptions)
           
 MethodGenerator startMethod(int modifiers, Type rtype, String name, List<Type> exceptions)
           
 
Methods inherited from class org.glassfish.pfl.dynamic.codegen.impl.ClassInfoBase
addConstructorInfo, addFieldInfo, addMethodInfo, className, equals, fieldInfo, findConstructorInfo, findFieldInfo, findMethodInfo, hashCode, impls, initializeClass, initializeInterface, isInterface, isSubclass, methodInfoByName, modifiers, name, pkgName, superType, thisType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.glassfish.pfl.dynamic.codegen.spi.ClassGenerator
name
 
Methods inherited from interface org.glassfish.pfl.dynamic.codegen.spi.ClassInfo
className, fieldInfo, findConstructorInfo, findFieldInfo, findMethodInfo, impls, isInterface, isSubclass, methodInfoByName, modifiers, pkgName, superType, thisType
 

Method Detail

parent

public Node parent()
Description copied from interface: Node
Return the Node that contains (and created) this Node.

Specified by:
parent in interface Node

id

public int id()
Description copied from interface: Node
Return the unique ID of this node. This starts at 1 and is incremented for each new Node that is created.

Specified by:
id in interface Node

parent

public void parent(Node node)
Description copied from interface: Node
Set the parent to a new value. Should only be called inside NodeBase.

Specified by:
parent in interface Node

getAncestor

public <T extends Node> T getAncestor(Class<T> type)
Description copied from interface: Node
Return the first ancestor of this node of the given type, if any. Throws IllegalArgumentException if not found.

Specified by:
getAncestor in interface Node

copy

public <T extends Node> T copy(Class<T> cls)
Description copied from interface: Node
Make a deep copy of this node. If nn = n.copy(), then n.parent() == nn.parent(), which also means that the parent is NOT copied.

Specified by:
copy in interface Node

copy

public <T extends Node> T copy(Node newParent,
                               Class<T> cls)
Description copied from interface: Node
Copy setting a new parent in the result.

Specified by:
copy in interface Node

get

public Object get(int index)
Description copied from interface: AttributedObject
Internal method for dynamic attribute support. Return the value of the attribute at index. If the attribute at index is not set, set it to the default value and return the default.

Specified by:
get in interface AttributedObject

set

public void set(int index,
                Object obj)
Description copied from interface: AttributedObject
Internal method for dynamic attribute support. Set the attribute at index to obj.

Specified by:
set in interface AttributedObject

attributes

public List<Object> attributes()
Description copied from interface: AttributedObject
Internal method for dynamic attribute support. Return all attributes for this node (may be null).

Specified by:
attributes in interface AttributedObject

initializer

public BlockStatement initializer()

fields

public List<FieldGenerator> fields()

methods

public List<MethodGenerator> methods()

constructors

public List<MethodGenerator> constructors()

constructorInfo

public Set<MethodInfo> constructorInfo()
Specified by:
constructorInfo in interface ClassInfo
Overrides:
constructorInfo in class ClassInfoBase

startMethod

public MethodGenerator startMethod(int modifiers,
                                   Type rtype,
                                   String name,
                                   List<Type> exceptions)

startConstructor

public MethodGenerator startConstructor(int modifiers,
                                        List<Type> exceptions)

methodComplete

public void methodComplete(MethodGenerator mg)

addField

public FieldGenerator addField(int modifiers,
                               Type type,
                               String name)

accept

public void accept(Visitor visitor)
Description copied from interface: Node
Accept the visitor and allow it to perform actions on this Node.

Specified by:
accept in interface Node


Copyright © 2013 Oracle. All Rights Reserved.