org.drools.factmodel
Class ClassDefinition

java.lang.Object
  extended by org.drools.factmodel.ClassDefinition
All Implemented Interfaces:
Externalizable, Serializable, org.drools.definition.type.FactType
Direct Known Subclasses:
EnumClassDefinition

public class ClassDefinition
extends Object
implements org.drools.definition.type.FactType

Declares a class to be dynamically created

See Also:
Serialized Form

Constructor Summary
ClassDefinition()
           
ClassDefinition(String className)
           
ClassDefinition(String className, String superClass)
           
ClassDefinition(String className, String superClass, String[] interfaces)
           
 
Method Summary
 void addAnnotation(AnnotationDefinition annotationDefinition)
           
 void addField(FieldDefinition attr)
          Adds a field definition to this class
 Object get(Object bean, String field)
           
 List<AnnotationDefinition> getAnnotations()
           
 Map<String,Object> getAsMap(Object bean)
           
 String getClassName()
           
 Class<?> getDefinedClass()
           
 Class<?> getFactClass()
           
 FieldDefinition getField(int index)
          Returns the field at position index, as defined by the builder using the @position annotation
 FieldDefinition getField(String fieldName)
          Returns the field definition object for the given field name
 List<org.drools.definition.type.FactField> getFields()
           
 Collection<FieldDefinition> getFieldsDefinitions()
           
 String[] getInterfaces()
           
 String getName()
           
 String getSuperClass()
           
 boolean isTraitable()
           
 Object newInstance()
           
 void readExternal(ObjectInput in)
           
 void set(Object bean, String field, Object value)
           
 void setClassName(String className)
           
 void setDefinedClass(Class<?> definedClass)
           
 void setFromMap(Object bean, Map<String,Object> data)
           
 void setInterfaces(String[] interfaces)
           
 void setSuperClass(String superClass)
           
 void setTraitable(boolean traitable)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassDefinition

public ClassDefinition()

ClassDefinition

public ClassDefinition(String className)

ClassDefinition

public ClassDefinition(String className,
                       String superClass)

ClassDefinition

public ClassDefinition(String className,
                       String superClass,
                       String[] interfaces)
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

getClassName

public final String getClassName()
Returns:
Returns the name.

setClassName

public final void setClassName(String className)
Parameters:
className - The name to set.

getDefinedClass

public final Class<?> getDefinedClass()
Returns:
Returns the className.

setDefinedClass

public void setDefinedClass(Class<?> definedClass)
Parameters:
definedClass - The class to set.

addField

public final void addField(FieldDefinition attr)
Adds a field definition to this class

Parameters:
attr -

getFieldsDefinitions

public final Collection<FieldDefinition> getFieldsDefinitions()
Returns:
Returns an unmodifiable collection of field definitions

getField

public final FieldDefinition getField(String fieldName)
Returns the field definition object for the given field name

Specified by:
getField in interface org.drools.definition.type.FactType
Parameters:
fieldName -
Returns:

getField

public FieldDefinition getField(int index)
Returns the field at position index, as defined by the builder using the @position annotation

Parameters:
index -
Returns:
the index-th field

getInterfaces

public final String[] getInterfaces()
Returns:
Returns the interfaces.

setInterfaces

public final void setInterfaces(String[] interfaces)
Parameters:
interfaces - The interfaces to set.

getSuperClass

public final String getSuperClass()
Returns:
Returns the superClass.

setSuperClass

public final void setSuperClass(String superClass)
Parameters:
superClass - The superClass to set.

getName

public String getName()
Specified by:
getName in interface org.drools.definition.type.FactType

newInstance

public Object newInstance()
                   throws InstantiationException,
                          IllegalAccessException
Specified by:
newInstance in interface org.drools.definition.type.FactType
Throws:
InstantiationException
IllegalAccessException

getFactClass

public Class<?> getFactClass()
Specified by:
getFactClass in interface org.drools.definition.type.FactType

getFields

public List<org.drools.definition.type.FactField> getFields()
Specified by:
getFields in interface org.drools.definition.type.FactType

get

public Object get(Object bean,
                  String field)
Specified by:
get in interface org.drools.definition.type.FactType

set

public void set(Object bean,
                String field,
                Object value)
Specified by:
set in interface org.drools.definition.type.FactType

getAsMap

public Map<String,Object> getAsMap(Object bean)
Specified by:
getAsMap in interface org.drools.definition.type.FactType

setFromMap

public void setFromMap(Object bean,
                       Map<String,Object> data)
Specified by:
setFromMap in interface org.drools.definition.type.FactType

addAnnotation

public void addAnnotation(AnnotationDefinition annotationDefinition)

getAnnotations

public List<AnnotationDefinition> getAnnotations()

isTraitable

public boolean isTraitable()

setTraitable

public void setTraitable(boolean traitable)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.