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

Package (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.rule
Class Package

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

public class Package
extends Object
implements Externalizable

Collection of related Rules.

Version:
$Id: Package.java,v 1.1 2005/07/26 01:06:31 mproctor Exp $
Author:
bob mcwhirter
See Also:
Rule, Serialized Form

Constructor Summary
Package()
          Default constructor - for Externalizable.
Package(String name)
          Construct.
Package(String name, ClassLoader parentClassLoader)
          Construct.
 
Method Summary
 void addFactTemplate(FactTemplate factTemplate)
           
 void addFunction(String functionName)
           
 void addGlobal(String identifier, Class clazz)
           
 void addImport(String importEntry)
           
 void addRule(Rule rule)
          Add a Rule to this Package.
 void addStaticImport(String functionImport)
           
 void checkValidity()
          This will throw an exception if the package is not valid
 void clear()
           
 boolean equals(Object object)
           
 String getErrorSummary()
          This will return the error summary (if any) if the package is invalid.
 FactTemplate getFactTemplate(String name)
           
 List getFunctions()
           
 Map getGlobals()
           
 List getImports()
           
 String getName()
          Retrieve the name of this Package.
 PackageCompilationData getPackageCompilationData()
           
 Rule getRule(String name)
          Retrieve a Rule by name.
 Rule[] getRules()
          Retrieve all Rules in this Package.
 List getStaticImports()
           
 int hashCode()
           
 boolean isValid()
           
 void readExternal(ObjectInput stream)
          Handles the read serialization of the Package.
 void removeFunction(String functionName)
           
 void removeFunctionImport(String functionImport)
           
 void removeGlobal(String identifier)
           
 void removeImport(String importEntry)
           
 void removeRule(Rule rule)
           
 void setError(String summary)
          Once this is called, the package will be marked as invalid
 String toString()
           
 void writeExternal(ObjectOutput stream)
          Handles the write serialization of the Package.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Package

public Package()
Default constructor - for Externalizable. This should never be used by a user, as it will result in an invalid state for the instance.


Package

public Package(String name)
Construct.

Parameters:
name - The name of this Package.

Package

public Package(String name,
               ClassLoader parentClassLoader)
Construct.

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

writeExternal

public void writeExternal(ObjectOutput stream)
                   throws 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 Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput stream)
                  throws IOException,
                         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 Externalizable
Throws:
IOException
ClassNotFoundException

getName

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

Returns:
The name of this Package.

addImport

public void addImport(String importEntry)

removeImport

public void removeImport(String importEntry)

getImports

public List getImports()

addStaticImport

public void addStaticImport(String functionImport)

addFunction

public void addFunction(String functionName)

getFunctions

public List getFunctions()

removeFunctionImport

public void removeFunctionImport(String functionImport)

getStaticImports

public List getStaticImports()

addGlobal

public void addGlobal(String identifier,
                      Class clazz)

removeGlobal

public void removeGlobal(String identifier)

getGlobals

public Map getGlobals()

removeFunction

public void removeFunction(String functionName)

getFactTemplate

public FactTemplate getFactTemplate(String name)

addFactTemplate

public void addFactTemplate(FactTemplate factTemplate)

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(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.

getPackageCompilationData

public PackageCompilationData getPackageCompilationData()

toString

public String toString()
Overrides:
toString in class Object

setError

public void setError(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 String getErrorSummary()
This will return the error summary (if any) if the package is invalid.


equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clear

public void clear()


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.