예제: 색상 값 디스크립터 작성
색상을 나타내는 값 유형의 경우 색상 값 디스크립터를 정의합니다.
이 태스크 정보
BOM 클래스 sample.Color를 색상을 나타내는 값 유형으로 사용하려면 색상 값 디스크립터를 정의해야 합니다.
프로시저
색상 값 디스크립터를 정의하려면 다음을 수행하십시오.
- IlrAbstractValueDescriptor 클래스를 확장하십시오.
class ValueColorDescriptor extends IlrAbstractValueDescriptor { public ValueColorDescriptor(Concept concept) { super(concept); } { // Checks the value (but here no check is needed) public boolean checkValue(IlrSyntaxTree.Node node, Object value) { return true; } // Converts the persistent text form of the value to an instance of Color public Object getValue(String persistentText) { return Color.decode(persistentText); } // Converts the instance of Color into a persistent text form public String getPersistentText(Object value) { return '#' + Integer.toHexString(((Color) value).getRGB()); } //Converts the localized text form of the value into an instance of Color public Object getValue(String text, IlrBRLDefinition definition) { return Color.decode(text); // Here the text form is not locale dependent } // Converts the instance of Color into a localized text form public String getLocalizedText(Object value, IlrBRLDefinition definition) { return '#' + Integer.toHexString(((Color) value).getRGB()); // Here the text form is still not locale dependent } // Returns the default value in a localized text form public String getDefaultValue(IlrBRLDefinition definition) { return "#000000"; // By default, returns the value black } } - 이 클래스에서 사용자 정의 특성 valueDecriptor를 정의하여
BOM 클래스 sample.Color에 값 디스크립터를 첨부하십시오.
valueDescriptor = sample.valueDescriptor.Color - 구문 분석할 수 있는 값의 표현을 지정하십시오.
이를 위해 BOM 편집기에서 사용자 정의 특성
valueDescriptor.parsableRepresentation을 클래스 sample.Color에 추가하고 다음 값을 제공하십시오.
#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F] - 다음 매개변수를 사용하여 확장점 ilog.rules.studio.model.brl.valueDescriptors를 선언하여
값 디스크립터를 Rule
Designer에 통합하십시오.
ID: sample.valueDescriptor.Color
키: sample.valueDescriptor.Color
클래스: sample.ValueColorDescriptor
결과
Rule Designer에서 색상 값 디스크립터를 사용할 수 있습니다.