org.kie.api.builder.Message.getLine()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中org.kie.api.builder.Message.getLine()方法的一些代码示例,展示了Message.getLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getLine()方法的具体详情如下:
包路径:org.kie.api.builder.Message
类名称:Message
方法名:getLine

Message.getLine介绍

[英]Returns the line number in the resource of the issue that caused the creation of this Message
[中]返回导致创建此消息的问题的资源中的行号

代码示例

代码示例来源:origin: wyh-spring-ecosystem-student/spring-boot-student

/**
 * 加载KieContainer容器
 */
public static KieContainer loadKieContainer() throws RuntimeException {
  //通过kmodule.xml 找到规则文件,这个文件默认放在resources/META-INF文件夹
  log.info("准备创建 KieContainer");
  if (kieContainer == null) {
    log.info("首次创建:KieContainer");
    // 设置drools的日期格式
    System.setProperty("drools.dateformat", "yyyy-MM-dd HH:mm:ss");
    //线程安全
    synchronized (DroolsUtil.class) {
      if (kieContainer == null) {
        // 创建Container
        kieContainer = kieServices.getKieClasspathContainer();
        // 检查规则文件是否有错
        Results results = kieContainer.verify();
        if (results.hasMessages(Message.Level.ERROR)) {
          StringBuffer sb = new StringBuffer();
          for (Message mes : results.getMessages()) {
            sb.append("解析错误的规则:").append(mes.getPath()).append(" 错误位置:").append(mes.getLine()).append(";");
          }
          throw new RuntimeException(sb.toString());
        }
      }
    }
  }
  log.info("KieContainer创建完毕");
  return kieContainer;
}

代码示例来源:origin: deepu105/drools-demo

private static String prettyBuildMessage(Message msg) {
  return "Message: {"
    + "id="+ msg.getId()
    + ", level=" + msg.getLevel()
    + ", path=" + msg.getPath()
    + ", line=" + msg.getLine()
    + ", column=" + msg.getColumn()
    + ", text=\"" + msg.getText() + "\""
    + "}";
}

代码示例来源:origin: gratiartis/qzr

private static String prettyBuildMessage(Message msg) {
  return "Message: {"
    + "id="+ msg.getId()
    + ", level=" + msg.getLevel()
    + ", path=" + msg.getPath()
    + ", line=" + msg.getLine()
    + ", column=" + msg.getColumn()
    + ", text=\"" + msg.getText() + "\""
    + "}";
}

代码示例来源:origin: deepu105/drools-demo

private static String prettyBuildMessage(Message msg) {
  return "Message: {"
    + "id="+ msg.getId()
    + ", level=" + msg.getLevel()
    + ", path=" + msg.getPath()
    + ", line=" + msg.getLine()
    + ", column=" + msg.getColumn()
    + ", text=\"" + msg.getText() + "\""
    + "}";
}

代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder

private BuildMessage convertMessage( final Message message ) {
  final BuildMessage m = new BuildMessage();
  switch ( message.getLevel() ) {
    case ERROR:
      m.setLevel( BuildMessage.Level.ERROR );
      break;
    case WARNING:
      m.setLevel( BuildMessage.Level.WARNING );
      break;
    case INFO:
      m.setLevel( BuildMessage.Level.INFO );
      break;
  }
  m.setId( message.getId() );
  m.setArtifactID( artifactId );
  m.setLine( message.getLine() );
  if ( message.getPath() != null && !message.getPath().isEmpty() ) {
    m.setPath( handles.get( RESOURCE_PATH + "/" + message.getPath() ) );
  }
  m.setColumn( message.getColumn() );
  m.setText( message.getText() );
  return m;
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend

static BuildMessage convertMessage(final Message message,
                  Handles handles) {
  final BuildMessage m = new BuildMessage();
  switch (message.getLevel()) {
    case ERROR:
      m.setLevel(Level.ERROR);
      break;
    case WARNING:
      m.setLevel(Level.WARNING);
      break;
    case INFO:
      m.setLevel(Level.INFO);
      break;
  }
  m.setId(message.getId());
  m.setLine(message.getLine());
  m.setPath(convertPath(message.getPath(),
             handles));
  m.setColumn(message.getColumn());
  m.setText(convertMessageText(message));
  return m;
}

相关文章