text:
package org.dvare.test.predefined;

import org.dvare.binding.data.InstancesBinding;
import org.dvare.binding.model.ContextsBinding;
import org.dvare.binding.model.TypeBinding;
import org.dvare.binding.rule.RuleBinding;
import org.dvare.config.RuleConfiguration;
import org.dvare.evaluator.RuleEvaluator;
import org.dvare.exceptions.interpreter.InterpretException;
import org.dvare.exceptions.parser.ExpressionParseException;
import org.dvare.expression.Expression;
import org.dvare.parser.ExpressionParser;
import org.dvare.test.dataobjects.ArithmeticOperation;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class PredefinedStringOperationTest {

    @Test
    public void prependAppendContainTest() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable5->prepend('dvare')->append('Test')->contains('framework')";

        Expression expression = factory.getParser().fromString(expr, ArithmeticOperation.class);

        RuleBinding rule = new RuleBinding(expression);

        ArithmeticOperation ArithmeticOperation = new ArithmeticOperation();
        ArithmeticOperation.setVariable5("framework");

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, ArithmeticOperation);
        Assertions.assertTrue(result);
    }

    @Test
    public void prependTestWhenValueIsNull() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable5->prepend('dvare') = null";

        Expression expression = factory.getParser().fromString(expr, ArithmeticOperation.class);

        RuleBinding rule = new RuleBinding(expression);

        ArithmeticOperation ArithmeticOperation = new ArithmeticOperation();
        ArithmeticOperation.setVariable5(null);

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, ArithmeticOperation);
        Assertions.assertTrue(result);
    }

    @Test
    public void subStringTest() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String exp = "not self.Variable5->substring(2,2)->toInteger() " +
                "between [80,90] and not self.Variable5->substring(2,2)->toInteger() " +
                "between [40,50] and  not self.Variable5->substring(2,2)->toInteger() between [30,40]";

        TypeBinding typeBinding = ExpressionParser.translate(ArithmeticOperation.class);
        ContextsBinding contexts = new ContextsBinding();
        contexts.addContext("self", typeBinding);

        Expression expression = factory.getParser().fromString(exp, contexts);
        RuleBinding rule = new RuleBinding(expression);

        ArithmeticOperation arithmeticOperation = new ArithmeticOperation();
        arithmeticOperation.setVariable5("D74F");

        InstancesBinding instancesBinding = new InstancesBinding();
        instancesBinding.addInstance("self", arithmeticOperation);

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, instancesBinding);
        Assertions.assertTrue(result);

    }

    @Test
    public void trimStringTest() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable5 -> trim() = 'dvare'";
        Expression expression = factory.getParser().fromString(expr, ArithmeticOperation.class);

        RuleBinding rule = new RuleBinding(expression);

        ArithmeticOperation ArithmeticOperation = new ArithmeticOperation();
        ArithmeticOperation.setVariable5("dvare ");

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, ArithmeticOperation);
        Assertions.assertTrue(result);
    }

    @Test
    public void trimStringTestWhenValueIsNull() throws ExpressionParseException, InterpretException {

        RuleConfiguration factory = new RuleConfiguration();

        String expr = "Variable5 -> trim() = 'dvare'";
        Expression expression = factory.getParser().fromString(expr, ArithmeticOperation.class);

        RuleBinding rule = new RuleBinding(expression);

        ArithmeticOperation ArithmeticOperation = new ArithmeticOperation();
        ArithmeticOperation.setVariable5(null);

        RuleEvaluator evaluator = factory.getEvaluator();
        boolean result = (Boolean) evaluator.evaluate(rule, ArithmeticOperation);
        Assertions.assertFalse(result);
    }
}


text:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bc;

import be.EstadoLetrasPagoCanje;
import java.util.List;
import javax.ejb.Local;

/**
 *
 * @author root
 */
@Local
public interface EstadoLetrasPagoCanjeFacadeLocal {

    void create(EstadoLetrasPagoCanje estadoLetrasPagoCanje);

    void edit(EstadoLetrasPagoCanje estadoLetrasPagoCanje);

    void remove(EstadoLetrasPagoCanje estadoLetrasPagoCanje);

    EstadoLetrasPagoCanje find(Object id);

    List<EstadoLetrasPagoCanje> findAll();

    List<EstadoLetrasPagoCanje> findRange(int[] range);

    int count();

}

redpajama_set_name: RedPajamaGithub


text:
CreateFileCommand::CreateFileCommand(SftpEventListener *listener,
                                     const int server_sock,
                                     LIBSSH2_SESSION *session,
                                     LIBSSH2_SFTP *sftp_session,
                                     const int request_id,
                                     const std::string &path)
  : AbstractCommand(session, sftp_session, server_sock, listener, request_id),
    path_(path)
{
  fprintf(stderr, "CreateFileCommand::CreateFileCommand\n");
}

CreateFileCommand::~CreateFileCommand()
{
  fprintf(stderr, "CreateFileCommand::~CreateFileCommand\n");
}

void* CreateFileCommand::Start(void *arg)
{
  CreateFileCommand *instance = static_cast<CreateFileCommand*>(arg);
  instance->Execute();
  return NULL;
}

void CreateFileCommand::Execute()
{
  fprintf(stderr, "CreateFileCommand::Execute\n");
  try {
    CreateFile(path_);
    GetListener()->OnCreateFileFinished(GetRequestID());
  } catch(CommunicationException e) {
    std::string msg;
    msg = e.toString();
    GetListener()->OnErrorOccurred(GetRequestID(), e.getResultCode(), msg);
  }
  fprintf(stderr, "CreateFileCommand::Execute End\n");
  delete this;
}

void CreateFileCommand::CreateFile(const std::string &path)
  throw(CommunicationException)
{
  fprintf(stderr, "CreateFileCommand::CreateFile path=%s\n", path.c_str());
  LIBSSH2_SFTP_HANDLE *sftp_handle = NULL;
  do {
    sftp_handle = libssh2_sftp_open(GetSftpSession(),
                                    path.c_str(),
                                    LIBSSH2_FXF_CREAT | LIBSSH2_FXF_TRUNC,
                                    LIBSSH2_SFTP_S_IRUSR | LIBSSH2_SFTP_S_IWUSR |
                                    LIBSSH2_SFTP_S_IRGRP |
                                    LIBSSH2_SFTP_S_IROTH);
    int last_error_no = libssh2_session_last_errno(GetSession());
    fprintf(stderr, "CreateFileCommand::CreateFile errno=%d\n", last_error_no);
    if (!sftp_handle) {
      if (last_error_no == LIBSSH2_ERROR_EAGAIN) {
        WaitSocket(GetServerSock(), GetSession());
      } else {
        THROW_COMMUNICATION_EXCEPTION("sftpThreadError_createFileFailed", last_error_no);
      }
    }
  } while (!sftp_handle);
  CloseSftpHandle(sftp_handle);
  fprintf(stderr, "CreateFileCommand::CreateFile End\n");
}