public class IlrBOMVocabularyBuilder
extends java.lang.Object
implements ilog.rules.vocabulary.model.IlrVocabularyConstants
// create a builder for a given Locale
IlrBOMVocabularyBuilder builder = new IlrBOMVocabularyBuilder(Locale.US);
// create vocabulary elements using addConcept(), addConceptInstance(), addAttributePhrase() and addMethodPhrase() APIs
...
// retrieve the created vocabulary that can be used to initialize a BRL parser for instance
IlrVocabulary voc = builder.getVocabulary();
Another usage of this class is to use one of its helper method which creates the default vocabulary for a given full-filled business object model.
See generateBOMVocabulary(...) static method in this class.. In this case, you relies on the default locale-specific
verbalizer to compute a verbalization for the given object model.
Type Section
An object model represents a type system. A type system usually features a set of Primitive types. The underlying type system of a Vocabulary
relies on a set of primitive types. When specifying the type of an attribute, of method return type or method arguments, you can refer to any
User types you have, using their fully-qualified-names or the following primitive types:
SourceVersion.isName() JDK helper.
Attribute or method name must be a Java Identifier as accepted by SourceVersion.isIdentifier() JDK helper. It also cannot be a
Java keyword as specified by SourceVersion.isKeyword().
The getBOMIdentifier() API allows to get a compliant id from any given identifier.| Modifier and Type | Class and Description |
|---|---|
static class |
IlrBOMVocabularyBuilder.CollectionDomain
This class represents a Collection Domain
|
static class |
IlrBOMVocabularyBuilder.Domain
This nested class represents a Domain that can be associated to a concept, a phrase or a role.
|
static class |
IlrBOMVocabularyBuilder.EnumDomain
This class represents an Enum Domain
|
static interface |
IlrBOMVocabularyBuilder.ErrorReporter
This interface specifies the contract of an error reporter that can be attached to this builder
|
static class |
IlrBOMVocabularyBuilder.LiteralDomain
This class represents a Literal Domain
|
static class |
IlrBOMVocabularyBuilder.MethodSignature
This nested class represent a Method from the underlying Object Model.
|
static class |
IlrBOMVocabularyBuilder.PropertyMap
This nested class is a Map of locale-independent and locale-dependent properties.
|
static class |
IlrBOMVocabularyBuilder.Term
This nested class represents a vocabulary Term that can be used to attached a specific plural, gender and a set of
specific articles to a term.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BOM_BUILDER_INTERNAL_PROP |
static java.lang.String |
COLLECTION_ATTRIBUTE |
| Constructor and Description |
|---|
IlrBOMVocabularyBuilder(IlrBOMVocabulary vocabulary)
This constructor creates an instance of Vocabulary Builder that will be used to populate the provided Vocabulary from an external Object Model and
its associated verbalization.
|
IlrBOMVocabularyBuilder(IlrObjectModel bom,
java.util.Locale locale)
This constructor creates an instance of Vocabulary Builder that will be used to populate a Vocabulary from an external Object Model and
its associated verbalization.
|
IlrBOMVocabularyBuilder(java.util.Locale locale)
This constructor creates an instance of Vocabulary Builder that will be used to populate a Vocabulary from an external Object Model and
its associated verbalization.
|
| Modifier and Type | Method and Description |
|---|---|
IlrSentence |
addAttributeClearerPhrase(java.lang.String classId,
java.lang.String attributeId,
java.lang.String attributeType,
IlrBOMVocabularyBuilder.Term subjectTerm,
java.lang.String phraseTemplate,
IlrBOMVocabularyBuilder.Domain domain,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method creates a new clearer phrase that is associated to a attribute in the underlying Object Model.
|
IlrSentence |
addAttributeGetterPhrase(java.lang.String classId,
java.lang.String attributeId,
java.lang.String attributeType,
IlrBOMVocabularyBuilder.Term subjectTerm,
java.lang.String phraseTemplate,
IlrBOMVocabularyBuilder.Domain domain,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method creates a new getter phrase that is associated to a attribute in the underlying Object Model.
|
IlrSentence[] |
addAttributePhrases(java.lang.String classId,
java.lang.String attributeId,
java.lang.String attributeType,
IlrBOMVocabularyBuilder.Domain domain,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method creates a new getter phrase and setter phrase that are associated to a attribute in the underlying Object Model.
|
IlrSentence |
addAttributeSetterPhrase(java.lang.String classId,
java.lang.String attributeId,
java.lang.String attributeType,
IlrBOMVocabularyBuilder.Term subjectTerm,
java.lang.String phraseTemplate,
IlrBOMVocabularyBuilder.Domain domain,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method creates a new setter phrase that is associated to a attribute in the underlying Object Model.
|
void |
addCollectionManipulationMethods()
This method adds specific methods to manipulate collection attributes available in the Object Model manipulated by this builder.
|
protected void |
addCollectionManipulationMethods(IlrClass cl) |
protected void |
addCollectionManipulationMethods(IlrClass cl,
IlrAttribute a) |
void |
addCollectionManipulationMethods(java.lang.String classId,
java.lang.String attributeId)
This method adds specific methods to manipulate the collection attribute referenced by the given classId and attributeId.
|
IlrConcept |
addConcept(java.lang.String id,
IlrBOMVocabularyBuilder.Term term,
java.util.List<java.lang.String> superConcepts,
IlrBOMVocabularyBuilder.Domain domain,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method add a concept to the Vocabulary whose id is 'id' and which is associated to the given term.
|
IlrConceptInstance |
addConceptInstance(java.lang.String classId,
java.lang.String id,
IlrBOMVocabularyBuilder.Term term,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method add a concept instance to the Vocabulary whose id is 'id' and which is associated to the given term.
|
protected IlrMethod |
addMethod(java.lang.String classId,
IlrBOMVocabularyBuilder.MethodSignature method,
IlrBOMVocabularyBuilder.PropertyMap properties) |
IlrSentence |
addMethodPhrase(java.lang.String classId,
IlrBOMVocabularyBuilder.MethodSignature method,
java.lang.String phraseTemplate,
IlrBOMVocabularyBuilder.Term subjectTerm,
IlrBOMVocabularyBuilder.PropertyMap properties)
This method creates a new phrase that is associated to a method in the underlying Object Model.
|
void |
addTerm(IlrBOMVocabularyBuilder.Term term)
Adds the specified term in the glossary if the given term has a specific plural, gender, or article,
If the term was already defined in the glossary, it is replaced by the new one.
|
IlrBOMVocabularyBuilder.Domain |
createCollectionDomain(java.lang.String collectionType)
This method creates a CollectionDomain object from the given collection element type, which is the FQN of the type.
|
IlrBOMVocabularyBuilder.Domain |
createEnumDomain(java.util.List<java.lang.String> elements)
This method creates an EnumDomain object from the given list of elements.
|
IlrBOMVocabularyBuilder.Domain |
createLiteralDomain(java.util.List<java.lang.String> elements)
This method creates a LiteralDomain object from the given list of elements.
|
IlrBOMVocabularyBuilder.MethodSignature |
createMethodSignature(java.lang.String methodName,
java.lang.String returnType,
java.util.List<java.lang.String> argumentTypes,
boolean isStatic)
This method creates a Method object that represents a method of the underlying object model
|
IlrBOMVocabularyBuilder.MethodSignature |
createMethodSignature(java.lang.String methodName,
java.lang.String returnType,
java.util.List<java.lang.String> argumentTypes,
IlrBOMVocabularyBuilder.Domain methodDomain,
java.util.List<IlrBOMVocabularyBuilder.Domain> argumentDomains,
boolean isStatic)
This method creates a Method object that represents a method of the underlying object model
|
IlrBOMVocabularyBuilder.PropertyMap |
createPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties)
This method creates a PropertyMap from a map of locale-independent properties.
|
IlrBOMVocabularyBuilder.PropertyMap |
createPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties,
java.util.Map<java.lang.String,java.lang.Object> localeProperties)
This method creates a PropertyMap from a map of locale-independent properties and a locale-specific properties.
|
IlrBOMVocabularyBuilder.Term |
createTerm(java.lang.String label)
This method creates a Term object from a non-null label.
|
protected java.lang.String |
generateAddToCollectionMethodName(IlrAttribute collAttr) |
static IlrVocabulary |
generateBOMVocabulary(IlrObjectModel bom,
IlrObjectModel resolutionBom,
java.util.Locale locale,
IlrSelector filter)
This helper method creates a default vocabulary for the given locale for the given business object model.
|
protected java.lang.String |
generateClearMethodName(IlrAttribute collAttr) |
protected java.lang.String |
generateRemovefromCollectionMethodName(IlrAttribute collAttr) |
protected java.lang.String |
generateSetCollectionMethodName(IlrAttribute collAttr) |
static java.lang.String |
getBOMIdentifier(java.lang.String id)
This method returns an id that can be used as BOM class or member identifiers.
|
IlrBOMVocabularyBuilder.ErrorReporter |
getErrorReporter()
This method return the error reporter currently installed on this builder
|
IlrVocabulary |
getUserVocabulary()
This method returns the vocabulary filled-in by this builder.
|
IlrVocabulary |
getVocabulary()
This method returns the vocabulary built by this builder.
|
void |
setErrorReporter(IlrBOMVocabularyBuilder.ErrorReporter errorReporter)
This method set an error reporter to this builder
|
void |
setProperties(IlrBOMVocabularyBuilder.PropertyMap properties)
This method set a map of locale-independent and locale-specific properties.
|
void |
setResolutionObjectModel(IlrObjectModel bom)
Set the BOM that must be used to resolve missing BOM references encountered when generating the vocabulary
|
public static final java.lang.String COLLECTION_ATTRIBUTE
public static final java.lang.String BOM_BUILDER_INTERNAL_PROP
public IlrBOMVocabularyBuilder(java.util.Locale locale)
locale - the Locale for which this vocabulary is built.public IlrBOMVocabularyBuilder(IlrObjectModel bom, java.util.Locale locale)
locale - the Locale for which this vocabulary is built.public IlrBOMVocabularyBuilder(IlrBOMVocabulary vocabulary)
vocabulary - the vocabulary to populatepublic IlrVocabulary getVocabulary()
public IlrVocabulary getUserVocabulary()
public void setResolutionObjectModel(IlrObjectModel bom)
bom - public void setProperties(IlrBOMVocabularyBuilder.PropertyMap properties)
properties - public IlrBOMVocabularyBuilder.Term createTerm(java.lang.String label)
label - a non-null labelpublic IlrBOMVocabularyBuilder.MethodSignature createMethodSignature(java.lang.String methodName, java.lang.String returnType, java.util.List<java.lang.String> argumentTypes, IlrBOMVocabularyBuilder.Domain methodDomain, java.util.List<IlrBOMVocabularyBuilder.Domain> argumentDomains, boolean isStatic)
methodName - the name of the method. Must be a Java Identifier.returnType - the return type of the method. Refer to the Type Section of the Builder documentation.argumentTypes - a list of argument types. Refer to the Type Section of the Builder documentation.methodDomain - a Domain associated to the return value of this method. Can be null.argumentDomains - a list of domains associated to method arguments. This list must have the same number of elements as argumentTypes.
If no domain is associated to an argument, a null value must be put in this list. This list can be null if no domain are set on
method arguments.isStatic - specifies whether a method is static or not.public IlrBOMVocabularyBuilder.MethodSignature createMethodSignature(java.lang.String methodName, java.lang.String returnType, java.util.List<java.lang.String> argumentTypes, boolean isStatic)
methodName - the name of the method. Must be a Java Identifier.returnType - the return type of the method. Refer to the Type Section of the Builder documentation.argumentTypes - a list of argument types. Refer to the Type Section of the Builder documentation.isStatic - specifies whether a method is static or not.public IlrBOMVocabularyBuilder.Domain createLiteralDomain(java.util.List<java.lang.String> elements)
elements - a list of string representation of literal values.public IlrBOMVocabularyBuilder.Domain createEnumDomain(java.util.List<java.lang.String> elements)
elements - a list of concept instance identifiers.public IlrBOMVocabularyBuilder.Domain createCollectionDomain(java.lang.String collectionType)
collectionType - public IlrBOMVocabularyBuilder.PropertyMap createPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties)
properties - a map of key,value propertiespublic IlrBOMVocabularyBuilder.PropertyMap createPropertyMap(java.util.Map<java.lang.String,java.lang.Object> properties, java.util.Map<java.lang.String,java.lang.Object> localeProperties)
properties - a map of key,value propertieslocaleProperties - a map of key,value propertiespublic IlrConcept addConcept(java.lang.String id, IlrBOMVocabularyBuilder.Term term, java.util.List<java.lang.String> superConcepts, IlrBOMVocabularyBuilder.Domain domain, IlrBOMVocabularyBuilder.PropertyMap properties)
id - the id of the concept. Is the fully-qualified class name of the corresponding class in the Object Model. Must be a qualified Java identifier (examples: 'myClassName', 'myPackage.myClassName').term - a term object that associate a verbalization to this concept. If null, a default verbalization will be computed from the class name.superConcepts - a list of concept id from which the created concept will derive. This list is made of the class names of the direct super
classes of the corresponding class. Class names must be qualified Java identifiers.domain - a domain to associate to this concept. Can be nullproperties - a map of properties associated to the created vocabulary element. Can be null.public IlrConceptInstance addConceptInstance(java.lang.String classId, java.lang.String id, IlrBOMVocabularyBuilder.Term term, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class to which this concept instance is related to.id - the id of the created concept instance. It is the name of the static final attribute to which this concept instance is associated to
in the Object Model. Must be a Java Identifier.term - a term object that associate a verbalization to this concept instance. If null, a default verbalization will be computed from the id.properties - a map of properties associated to the created vocabulary element. Can be null.public IlrSentence[] addAttributePhrases(java.lang.String classId, java.lang.String attributeId, java.lang.String attributeType, IlrBOMVocabularyBuilder.Domain domain, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class that hold this attribute in the object model.attributeId - the attribute name. Must be a Java Identifier.attributeType - the type of the attribute.domain - the domain that is associated to this attribute. Can be null.properties - a map of properties associated to the created phrases. Can be null.public IlrSentence addAttributeGetterPhrase(java.lang.String classId, java.lang.String attributeId, java.lang.String attributeType, IlrBOMVocabularyBuilder.Term subjectTerm, java.lang.String phraseTemplate, IlrBOMVocabularyBuilder.Domain domain, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class that hold this attribute in the object model.attributeId - the attribute name. Must be a Java Identifier.attributeType - the type of the attribute.subjectTerm - the term used as subject. If null, a default one is computed from the attribute name.phraseTemplate - the Phrase Template. If null a default template is created.domain - the domain that is associated to this attribute. Can be null.properties - a map of properties associated to the created phrase. Can be null.public IlrSentence addAttributeSetterPhrase(java.lang.String classId, java.lang.String attributeId, java.lang.String attributeType, IlrBOMVocabularyBuilder.Term subjectTerm, java.lang.String phraseTemplate, IlrBOMVocabularyBuilder.Domain domain, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class that hold this attribute in the object model.attributeId - the attribute name. Must be a Java Identifier.attributeType - the type of the attribute.phraseTemplate - the Phrase Template. If null a default template is created.domain - the domain that is associated to this attribute. Can be null.properties - a map of properties associated to the created phrase. Can be null.public IlrSentence addAttributeClearerPhrase(java.lang.String classId, java.lang.String attributeId, java.lang.String attributeType, IlrBOMVocabularyBuilder.Term subjectTerm, java.lang.String phraseTemplate, IlrBOMVocabularyBuilder.Domain domain, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class that hold this attribute in the object model.attributeId - the attribute name. Must be a Java Identifier.attributeType - the type of the attribute.phraseTemplate - the Phrase Template. If null a default template is created.domain - the domain that is associated to this attribute. Can be null.properties - a map of properties associated to the created phrase. Can be null.public IlrSentence addMethodPhrase(java.lang.String classId, IlrBOMVocabularyBuilder.MethodSignature method, java.lang.String phraseTemplate, IlrBOMVocabularyBuilder.Term subjectTerm, IlrBOMVocabularyBuilder.PropertyMap properties)
classId - the id of the class that hold this method in the object model.method - a Method object that represent the method of the underlying Object Model.phraseTemplate - the Phrase Template. If none is provided, a default one may be computed according to the sentence category determined from the method signature.subjectTerm - the term associated to the phrase subject. Its label is referenced as {label} in the phrase template.properties - a map of properties associated to the created phrase. Can be null.protected IlrMethod addMethod(java.lang.String classId, IlrBOMVocabularyBuilder.MethodSignature method, IlrBOMVocabularyBuilder.PropertyMap properties)
public void addTerm(IlrBOMVocabularyBuilder.Term term)
term - The term to add to the glossarypublic IlrBOMVocabularyBuilder.ErrorReporter getErrorReporter()
public void setErrorReporter(IlrBOMVocabularyBuilder.ErrorReporter errorReporter)
errorReporter - an error reporter to setpublic void addCollectionManipulationMethods()
public void addCollectionManipulationMethods(java.lang.String classId,
java.lang.String attributeId)
classId - the fully-qualified name of the class containing the attributeattributeId - the name of the collection attribute.protected void addCollectionManipulationMethods(IlrClass cl)
protected void addCollectionManipulationMethods(IlrClass cl, IlrAttribute a)
protected java.lang.String generateClearMethodName(IlrAttribute collAttr)
protected java.lang.String generateAddToCollectionMethodName(IlrAttribute collAttr)
protected java.lang.String generateRemovefromCollectionMethodName(IlrAttribute collAttr)
protected java.lang.String generateSetCollectionMethodName(IlrAttribute collAttr)
public static IlrVocabulary generateBOMVocabulary(IlrObjectModel bom, IlrObjectModel resolutionBom, java.util.Locale locale, IlrSelector filter)
bom - the source object model for which a given vocabulary is computedresolutionBom - an optional object model used to look-up missing references if any.locale - the Locale for which the vocabulary is computedfilter - an optional filter to control which element of the given object model should be considered.public static java.lang.String getBOMIdentifier(java.lang.String id)
id - a non-null identifier that may contain whitespaces and other non-compliant characters.© Copyright IBM Corp. 1987, 2017