All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.ide.common.server.util.DRLConstraintValueBuilder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2011 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.ide.common.server.util;

/**
 * A Helper class for building parts of DRL from higher-order representations
 * (i.e. Guided Rule Editor, Guided Template Rule Editor and Guided Decision
 * Table).
 */
public abstract class DRLConstraintValueBuilder {

    public static DRLConstraintValueBuilder getBuilder(String dialect) {
        if ( BRDRLPersistence.DEFAULT_DIALECT.equalsIgnoreCase( dialect ) ) {
            return new MvelDRLConstraintValueBuilder();
        }
        return new JavaDRLConstraintValueBuilder();
    }

    /**
     * Concatenate a String to the provided buffer suitable for the fieldValue
     * and fieldType. Strings and Dates are escaped with double-quotes, whilst
     * Numerics, Booleans, (Java 1.5+) enums and all other fieldTypes are not
     * escaped at all. Guvnor-type enums are really a pick list of Strings and
     * in these cases the underlying fieldType is a String.
     * 
     * @param buf
     * @param constraintType
     * @param fieldType
     * @param fieldValue
     */
    public abstract void buildLHSFieldValue(StringBuilder buf,
                                            int constraintType,
                                            String fieldType,
                                            String fieldValue);

    /**
     * Concatenate a String to the provided buffer suitable for the fieldType
     * and fieldValue. Strings are escaped with double-quotes, Dates are wrapped
     * with a call to a pre-constructed SimpleDateFormatter, whilst Numerics,
     * Booleans, (Java 1.5+) enums and all other fieldTypes are not escaped at
     * all. Guvnor-type enums are really a pick list of Strings and in these
     * cases the underlying fieldType is a String.
     * 
     * @param buf
     * @param fieldType
     * @param fieldValue
     */
    public abstract void buildRHSFieldValue(StringBuilder buf,
                                            String fieldType,
                                            String fieldValue);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy