Example usage for java.util.regex PatternSyntaxException getClass

List of usage examples for java.util.regex PatternSyntaxException getClass

Introduction

In this page you can find the example usage for java.util.regex PatternSyntaxException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.clustercontrol.monitor.run.factory.RunMonitorStringValueType.java

/**
 * ????//  w  ww  . java 2 s  .co  m
 * <p>
 * ???????????
 * ???????????????????
 * 
 * @see com.clustercontrol.monitor.run.ejb.entity.MonitorStringValueInfoBean#getOrder_no()
 * @see com.clustercontrol.monitor.run.bean.MonitorStringValueInfo
 */
@Override
public int getCheckResult(boolean ret) {

    // -1 = ?-2 = ?????
    int result = -2;

    // ??
    if (!ret) {
        result = -1;
        return result;
    }

    // ???
    Pattern pattern = null;
    Matcher matcher = null;

    int orderNo = 0;
    // ??
    for (MonitorJudgementInfo info : m_judgementInfoList.values()) {

        ++orderNo;
        if (m_log.isDebugEnabled()) {
            m_log.debug("getCheckResult() value = " + m_value + ", monitorId = " + info.getMonitorId()
                    + ", orderNo = " + orderNo + ", pattern = " + info.getPattern());
        }

        // ?????
        if (info != null && info.getValidFlg()) {
            try {
                String patternText = info.getPattern();

                // ?????
                if (info.getCaseSensitivityFlg()) {
                    pattern = Pattern.compile(patternText, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
                }
                // ???
                else {
                    pattern = Pattern.compile(patternText, Pattern.DOTALL);
                }
                if (m_value == null) {
                    m_log.debug("getCheckResult(): monitorId=" + info.getMonitorId() + ", facilityId="
                            + m_facilityId + ", value=null");
                    result = -1;
                    return result;
                }
                matcher = pattern.matcher(m_value);

                // ????
                if (matcher.matches()) {
                    result = orderNo;

                    m_log.debug("getCheckResult() true : description=" + info.getDescription() + ", value="
                            + m_value);
                    m_log.debug("getCheckResult() true : message=" + info.getMessage());

                    break;
                }
            } catch (PatternSyntaxException e) {
                m_log.info("getCheckResult(): PatternSyntax is not valid." + " description="
                        + info.getDescription() + ", patternSyntax=" + info.getPattern() + ", value=" + m_value
                        + " : " + e.getClass().getSimpleName() + ", " + e.getMessage());
                result = -1;
            } catch (Exception e) {
                m_log.warn("getCheckResult(): PatternSyntax is not valid." + " description="
                        + info.getDescription() + ", patternSyntax=" + info.getPattern() + ", value=" + m_value
                        + " : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
                result = -1;
            }
        }
    }
    return result;
}

From source file:com.clustercontrol.process.factory.RunMonitorProcess.java

/**
 * ?????????<BR>/*  w  ww .ja va2 s .com*/
 * ?????? preCollect ?????
 * 
 * @param facilityId ID
 * @return ???????true
 */
@Override
public boolean collect(String facilityId) {

    if (m_log.isDebugEnabled())
        m_log.debug("collect() : start." + " facilityId = " + m_facilityId + ", monitorId = " + m_monitorId
                + ", monitorType = " + m_monitorTypeId);

    // ?,???
    int count = 0;

    // 
    if (m_now != null) {
        m_nodeDate = m_now.getTime();
    }
    m_value = 0;

    // 
    m_messageOrg = MessageConstant.COMMAND.getMessage() + " : " + m_command + ", "
            + MessageConstant.PARAM.getMessage() + " : " + m_param;

    // ???
    Pattern pCommand = null;
    Pattern pParam = null;
    try {
        // ?????
        if (m_process.getCaseSensitivityFlg()) {
            pCommand = Pattern.compile(m_command, Pattern.CASE_INSENSITIVE);
            pParam = Pattern.compile(m_param, Pattern.CASE_INSENSITIVE);
        }
        // ???
        else {
            pCommand = Pattern.compile(m_command);
            pParam = Pattern.compile(m_param);
        }
    } catch (PatternSyntaxException e) {
        m_log.info("collect() command, parameter PatternSyntax error : " + e.getClass().getSimpleName() + ", "
                + e.getMessage());
        m_message = MessageConstant.MESSAGE_PLEASE_SET_VALUE_WITH_REGEX.getMessage();
        return false;
    }

    @SuppressWarnings("unchecked")
    List<ProcessInfo> procList = (List<ProcessInfo>) preCollectData;

    if (procList == null) {
        // TODO nagatsumas ???OK
        // ??????????????
        return false;
    } else {
        // ??????????
        for (ProcessInfo procInfo : procList) {
            if (pCommand.matcher(procInfo.command).matches()) {
                if (pParam.matcher(procInfo.param).matches()) {
                    count++;
                    // ??
                    m_nodeDate = procInfo.time;
                    // ????
                    if (ProcessProperties.getProperties().isDetailedDisplay()) {
                        m_messageOrg = m_messageOrg + "\n";

                        if (procInfo.pid != null) {
                            // PID???????SNMP????
                            m_messageOrg = m_messageOrg + procInfo.pid + " : ";
                        }

                        m_messageOrg = m_messageOrg + procInfo.command + " " + procInfo.param;
                    }
                }
            }
        }
    }
    // 
    m_value = count;
    m_message = MessageConstant.PROCESS_NUMBER.getMessage() + " : "
            + NumberFormat.getNumberInstance().format(m_value);

    if (m_log.isDebugEnabled())
        m_log.debug("collect() : end." + " facilityId = " + m_facilityId + ", monitorId = " + m_monitorId
                + ", monitorType = " + m_monitorTypeId + ", count = " + count);

    return true;

    //      // ???????
    //      m_message = MessageConstant.MESSAGE_TIME_OUT.getMessage();
    //      return false;
}