AROM-2_2_13

arom.kr.parser
Interface KBReader

All Known Implementing Classes:
InstancesReader, StandardReader

public interface KBReader

This interface is implemented by any object that is enable to read AROM descriptions. These descriptions could be a complete knowledge base or only a part of it. The description of the knowledge base is read from an InputStream object. The description read from the InputStream object must conform to the format expected by the object implementing this interface. If the format is different, an InvalidFormatException is thrown.

A description of the available format defined in the current implementation is accessible from here.

The StandardReader class is the default implementation of this interface A StandardReader object reads an AROM knowledge base description that comply to the AROM language and instantiates this knowledge base through calls to the AROM API methods. This default implementation is quite inefficient but is independent of the AROM implementation used.

Author:
Christophe Bruley
See Also:
StandardReader

Field Summary
static int REPLACE_DUPLICATE_INSTANCE
          If an instance is described twice, this reader will erase existing instance by new instance description.
static int SKIP_DUPLICATE_INSTANCE
          If an instance is described twice, this reader will ignore the new instance description.
static int WARN_DUPLICATE_INSTANCE
          If an instance is described twice, this reader will set an error or a warning depending on the Reader implementation.
 
Method Summary
 KnowledgeBase createKB(InputStream input, int instanceAction, TestResult result)
          Creates a knowledge base object by reading it's description from the supplied InputStream object.
 KnowledgeBase createKB(InputStream input, TestResult result)
          Creates a knowledge base object by reading it's description from the supplied InputStream object.
 void displayWarning(boolean enable)
          Specify if the warnings which occured during a read operation should be display on the standard output or not.
 AMAssociation readContent(AMAssociation container, InputStream input, TestResult result)
          Reads the content of the supplied AMAssociation from the InputStream object.
 AMClass readContent(AMClass container, InputStream input, TestResult result)
          Reads the content of the supplied AMClass from the InputStream object.
 KnowledgeBase readContent(KnowledgeBase kb, InputStream input, int instanceAction, TestResult result)
          Reads the content of the supplied knowledge base from the InputStream object.
 KnowledgeBase readContent(KnowledgeBase kb, InputStream input, TestResult result)
          Reads the content of the supplied knowledge base from the InputStream object.
 FacetModifier readFacetModifier(Class facetType, InputStream input, TestResult result)
          Reads a facet's accessor from the InputStream object.
 Object readValue(DeltaType valueType, InputStream input, TestResult result)
          Reads an AROM value from the InputStream object.
 boolean verifyIdentifier(InputStream reader, TestResult result)
          Verify that the specified InputStream is a valid identifier (entity name) for this KBReader format.
 boolean verifyIdentifier(String reader, TestResult result)
          Verify that the specified String is a valid identifier (entity name) for this KBReader format.
 

Field Detail

WARN_DUPLICATE_INSTANCE

public static final int WARN_DUPLICATE_INSTANCE
If an instance is described twice, this reader will set an error or a warning depending on the Reader implementation.

See Also:
Constant Field Values

REPLACE_DUPLICATE_INSTANCE

public static final int REPLACE_DUPLICATE_INSTANCE
If an instance is described twice, this reader will erase existing instance by new instance description.

See Also:
Constant Field Values

SKIP_DUPLICATE_INSTANCE

public static final int SKIP_DUPLICATE_INSTANCE
If an instance is described twice, this reader will ignore the new instance description.

See Also:
Constant Field Values
Method Detail

createKB

public KnowledgeBase createKB(InputStream input,
                              TestResult result)
                       throws InvalidFormatException,
                              InvalidDescriptionException,
                              IOException
Creates a knowledge base object by reading it's description from the supplied InputStream object. The description should follow the format expected by this KBReader.If a description of an existing entity is found, a warning or an error (depending on the reader format) will be set.

Parameters:
input - the InputStream from which the knowledge base description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the created knowledge base.
Throws:
InvalidFormatException - If the description can't be read by this KBReader.
InvalidDescriptionException - if the description is invalid.
IOException - if the specified reader is null.

createKB

public KnowledgeBase createKB(InputStream input,
                              int instanceAction,
                              TestResult result)
                       throws InvalidFormatException,
                              InvalidDescriptionException,
                              IOException
Creates a knowledge base object by reading it's description from the supplied InputStream object. The description should follow the format expected by this KBReader.
instanceAction specify what the reader should do when an existing instance description is found.

readContent

public KnowledgeBase readContent(KnowledgeBase kb,
                                 InputStream input,
                                 TestResult result)
                          throws InvalidFormatException,
                                 InvalidDescriptionException,
                                 IOException
Reads the content of the supplied knowledge base from the InputStream object. The supplied reader must not contains knowledge base description. Only Arom entities which container is the knowledge base are expected: Structures or instances descriptions. If a description of an existing entity is found, a warning or an error (depending on the reader format) will be set.

Parameters:
kb - the knowledge base to complete. If null, a new knowledge base will be created, as with createKB method. In this case the reader should contain knowledge base description.
input - the InputStream from which the knowledge base content description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the supplied knowledge base.
Throws:
InvalidFormatException - if the description that is read is not conform to the expected format.
InvalidDescriptionException - if the description that is read is invalid.
IOException - Description of Exception

readContent

public KnowledgeBase readContent(KnowledgeBase kb,
                                 InputStream input,
                                 int instanceAction,
                                 TestResult result)
                          throws InvalidFormatException,
                                 InvalidDescriptionException,
                                 IOException
Reads the content of the supplied knowledge base from the InputStream object. The supplied reader must not contains knowledge base description. Only Arom entities which container is the knowledge base are expected: Structures or instances descriptions. instanceAction specify what the reader should do when an existing instance description is found.

readContent

public AMClass readContent(AMClass container,
                           InputStream input,
                           TestResult result)
                    throws InvalidFormatException,
                           InvalidDescriptionException,
                           IOException
Reads the content of the supplied AMClass from the InputStream object. This content should only be variables descriptions, which container is the specified Arom class.

Parameters:
container - the AMClass to complete, must not be null.
input - the InputStream from which the Arom class content description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the supplied AMClass.
Throws:
InvalidFormatException - if the description that is read is not conform to the expected format.
InvalidDescriptionException - if the description that is read is invalid.
IOException - Description of Exception

readContent

public AMAssociation readContent(AMAssociation container,
                                 InputStream input,
                                 TestResult result)
                          throws InvalidFormatException,
                                 InvalidDescriptionException,
                                 IOException
Reads the content of the supplied AMAssociation from the InputStream object. This content should be variables or roles descriptions which container is the specified association.

Parameters:
container - the AMAssociation to complete, must not be null.
input - the InputStream from which the Arom association content description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the supplied AMAssociation.
Throws:
InvalidFormatException - if the description that is read is not conform to the expected format.
InvalidDescriptionException - if the description that is read is invalid.
IOException - Description of Exception

readFacetModifier

public FacetModifier readFacetModifier(Class facetType,
                                       InputStream input,
                                       TestResult result)
                                throws InvalidFormatException,
                                       InvalidDescriptionException,
                                       IOException
Reads a facet's accessor from the InputStream object.

Parameters:
facetType - The type of the facet the accessor refers to.
input - the InputStream from which the knowledge base description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the facet's accessor whose description has been read from the Reader object.
Throws:
InvalidFormatException - if the description that is read is not conform to the expected format.
InvalidDescriptionException - if the description that is read is invalid.
IOException - Description of Exception

readValue

public Object readValue(DeltaType valueType,
                        InputStream input,
                        TestResult result)
                 throws InvalidFormatException,
                        InvalidDescriptionException,
                        IOException
Reads an AROM value from the InputStream object. An AROM Value is any value which could be valid for an instance slot value. If valueType is specified, the value should belongs to it, else, if valueType is null the value is returned if it belongs to a known valid type.

Parameters:
valueType - The DeltaType to which the value should belong to.
input - the InputStream from which the value description is read.
result - A TestResult object where warnings messages will be stored.
Returns:
the value in AROM Format.
Throws:
InvalidFormatException - if the description that is read is not conform to the expected format.
InvalidDescriptionException - if the description that is read is invalid.
IOException - Description of Exception

verifyIdentifier

public boolean verifyIdentifier(InputStream reader,
                                TestResult result)
Verify that the specified InputStream is a valid identifier (entity name) for this KBReader format.

Parameters:
reader - the InputStream from which the identifier is read.
result - A TestResult object where errors messages will be stored.
Returns:
true if the specified identifier is valid, false otherwise.

verifyIdentifier

public boolean verifyIdentifier(String reader,
                                TestResult result)
Verify that the specified String is a valid identifier (entity name) for this KBReader format.

Parameters:
result - A TestResult object where errors messages will be stored.
Returns:
true if the specified identifier is valid, false otherwise.

displayWarning

public void displayWarning(boolean enable)
Specify if the warnings which occured during a read operation should be display on the standard output or not. Default is disabled.

Parameters:
enable - if true the warnings will be displayed

AROM-2_2_13