Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.definition.type;
 
 import java.util.List;
 import java.util.Map;

FactType declarations are fact definitions (like classes) that are managed alongside the rules. You then communicate with the rulebase/knowledge base by using instances created by this. There are utility set and get methods on this, as well as in the FactFields. The Object that is used is a javabean (which was generated by the engine). You can also use reflection on it as normal.
 
 public interface FactType
     extends
     java.io.Externalizable {

    
Returns the fully qualified name of the FactType.

Returns:
the name of the fact type.
 
     public String getName();

    
Returns the unqualified name of the FactType.

Returns:
the name of the fact type.
 
     public String getSimpleName();

    
Returns the package this FactType is defined in.

Returns:
the name of the fact type's package.
 
     public String getPackageName();

    
Returns the name of the FactType's super type

Returns:
the name of the fact type's super type.
 
     public String getSuperClass();

    
Returns the list of FactField in this FactType

Returns:
the list of the fields in this FactType
 
     public List<FactFieldgetFields();

    
Returns the FactField identified by the given name.

Parameters:
name the name of the FactField
Returns:
the FactField instance identified by the given name or null if none is found.
 
     public FactField getField(String name);

    
Returns the Class<?> for this FactType. The class object can be used through reflection.

Returns:
the generated class for this FactType
 
     public Class< ? > getFactClass();

    
Create a new fact based on the declared fact type. This object will usually be a javabean.
 
     public Object newInstance() throws InstantiationException,
                                IllegalAccessException;

    
Sets the value of the field on a fact.

Parameters:
bean the object on which the field will be set.
field the name of the field to set.
value the value to be set on the field.
    public void set(Object bean,
                    String field,
                    Object value);

    
Gets the value of the specified field on the dynamic fact.

Parameters:
bean the fact to read the field value from.
field the name of the field to read.
Returns:
the value of the field read from the fact
    public Object get(Object bean,
                      String field);

    
Get a map of the fields and their values for the bean.

Parameters:
bean the bean to read the fields from.
Returns:
a map of field names and corresponding values on the bean.
    public Map<StringObjectgetAsMap(Object bean);

    
Sets the values of the bean from a map.

Parameters:
bean the fact to set the values of the fields on
values a map of field names and values to set
    public void setFromMap(Object bean,
                           Map<StringObjectvalues);


    
Returns the list of class-level annotations used in this class definition

Returns:
the list of class-level annotations
    public List<AnnotationgetClassAnnotations();

    
Returns the annotations of this class definition as key-value pairs.

Returns:
a key-value map of the class-level annotations
    public Map<StringObjectgetMetaData();
New to GrepCode? Check out our FAQ X