站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 3.0.6 API 英文版文档

Package - JBoss RULES 3.0.6 API 英文版文档


org.drools.rule
Class Package

java.lang.Object
  extended by org.drools.rule.Package
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Package
extends java.lang.Object
implements java.io.Externalizable

Collection of related Rules.

See Also:
Rule, Serialized Form

Field Summary
static Package[] EMPTY_ARRAY
          Empty Package array.
 
Constructor Summary
Package()
          This is a default constructor purely for externalization
Package(java.lang.String name)
          Construct.
Package(java.lang.String name, java.lang.ClassLoader parentClassLoader)
          Construct.
 
Method Summary
 void addGlobal(java.lang.String identifier, java.lang.Class clazz)
           
 void addImport(java.lang.String importEntry)
           
 void addRule(Rule rule)
          Add a Rule to this Package.
 void checkValidity()
          This will throw an exception if the package is not valid
 void clear()
           
 boolean equals(java.lang.Object object)
           
 java.lang.String getErrorSummary()
          This will return the error summary (if any) if the package is invalid.
 java.util.Map getGlobals()
           
 java.util.List getImports()
           
 java.lang.String getName()
          Retrieve the name of this Package.
 PackageCompilationData getPackageCompilationData()
           
 Rule getRule(java.lang.String name)
          Retrieve a Rule by name.
 Rule[] getRules()
          Retrieve all Rules in this Package.
 TypeResolver getTypeResolver()
           
 int hashCode()
           
 boolean isValid()
           
 void readExternal(java.io.ObjectInput stream)
          Handles the read serialization of the Package.
 void removeFunction(java.lang.String functionName)
           
 void removeGlobal(java.lang.String identifier)
           
 void removeImport(java.lang.String importEntry)
           
 void removeRule(Rule rule)
           
 void setError(java.lang.String summary)
          Once this is called, the package will be marked as invalid
 void setTypeSolver(TypeResolver typeResolver)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput stream)
          Handles the write serialization of the Package.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final Package[] EMPTY_ARRAY
Empty Package array.

Constructor Detail

Package

public Package()
This is a default constructor purely for externalization


Package

public Package(java.lang.String name)
Construct.

Parameters:
name - The name of this Package.

Package

public Package(java.lang.String name,
               java.lang.ClassLoader parentClassLoader)
Construct.

Parameters:
name - The name of this Package.
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput stream)
                   throws java.io.IOException
Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput stream)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules. A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getName

public java.lang.String getName()
Retrieve the name of this Package.

Returns:
The name of this Package.

addImport

public void addImport(java.lang.String importEntry)

removeImport

public void removeImport(java.lang.String importEntry)

getImports

public java.util.List getImports()

addGlobal

public void addGlobal(java.lang.String identifier,
                      java.lang.Class clazz)

removeGlobal

public void removeGlobal(java.lang.String identifier)

getGlobals

public java.util.Map getGlobals()

removeFunction

public void removeFunction(java.lang.String functionName)

addRule

public void addRule(Rule rule)
Add a Rule to this Package.

Parameters:
rule - The rule to add.
Throws:
DuplicateRuleNameException - If the Rule attempting to be added has the same name as another previously added Rule.
InvalidRuleException - If the Rule is not valid.

removeRule

public void removeRule(Rule rule)

getRule

public Rule getRule(java.lang.String name)
Retrieve a Rule by name.

Parameters:
name - The name of the Rule to retrieve.
Returns:
The named Rule, or null if not such Rule has been added to this Package.

getRules

public Rule[] getRules()
Retrieve all Rules in this Package.

Returns:
An array of all Rules in this Package.

setTypeSolver

public void setTypeSolver(TypeResolver typeResolver)

getTypeResolver

public TypeResolver getTypeResolver()

getPackageCompilationData

public PackageCompilationData getPackageCompilationData()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setError

public void setError(java.lang.String summary)
Once this is called, the package will be marked as invalid


isValid

public boolean isValid()
Returns:
true (default) if there are no build/structural problems.

checkValidity

public void checkValidity()
This will throw an exception if the package is not valid


getErrorSummary

public java.lang.String getErrorSummary()
This will return the error summary (if any) if the package is invalid.


equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clear

public void clear()