Example usage for org.apache.commons.scxml.env LogUtils getTTPath

List of usage examples for org.apache.commons.scxml.env LogUtils getTTPath

Introduction

In this page you can find the example usage for org.apache.commons.scxml.env LogUtils getTTPath.

Prototype

public static String getTTPath(final TransitionTarget tt) 

Source Link

Document

Write out this TransitionTarget location in a XPath style format.

Usage

From source file:com.headstrong.fusion.statemachine.StateMachineErrorReporter.java

/**
 * @see ErrorReporter#onError(String, String, Object)
 *//*  ww  w .  j a  va2  s  .c  om*/
public void onError(final String errorCode, final String errDetail, final Object errCtx) {
    // Note: the if-then-else below is based on the actual usage
    // (codebase search), it has to be kept up-to-date as the code changes
    String errCode = errorCode.intern();
    StringBuffer msg = new StringBuffer();
    msg.append(errCode).append(" (");
    msg.append(errDetail).append("): ");
    if (errCode == ErrorConstants.NO_INITIAL) {
        if (errCtx instanceof SCXML) {
            // determineInitialStates
            msg.append("<SCXML>");
        } else if (errCtx instanceof State) {
            // determineInitialStates
            // determineTargetStates
            msg.append("State ").append(LogUtils.getTTPath((State) errCtx));
        }
    } else if (errCode == ErrorConstants.UNKNOWN_ACTION) {
        // executeActionList
        msg.append("Action: ").append(errCtx.getClass().getName());
    } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) {
        // isLegalConfig
        if (errCtx instanceof Map.Entry) {
            TransitionTarget tt = (TransitionTarget) (((Map.Entry) errCtx).getKey());
            Set vals = (Set) (((Map.Entry) errCtx).getValue());
            msg.append(LogUtils.getTTPath(tt)).append(" : [");
            for (Iterator i = vals.iterator(); i.hasNext();) {
                TransitionTarget tx = (TransitionTarget) i.next();
                msg.append(LogUtils.getTTPath(tx));
                if (i.hasNext()) {
                    msg.append(", ");
                }
            }
            msg.append(']');
        } else if (errCtx instanceof Set) {
            Set vals = (Set) errCtx;
            msg.append("<SCXML> : [");
            for (Iterator i = vals.iterator(); i.hasNext();) {
                TransitionTarget tx = (TransitionTarget) i.next();
                msg.append(LogUtils.getTTPath(tx));
                if (i.hasNext()) {
                    msg.append(", ");
                }
            }
            msg.append(']');
        }
    }
    if (logger.isWarnEnabled()) {
        logger.warn(msg.toString());
    }
}

From source file:de.dfki.iui.mmds.dialogue.SiamErrorReporter.java

/**
 * @see ErrorReporter#onError(String, String, Object)
 *///ww w.  j  av a2s  . c  o m
@Override
@SuppressWarnings("unchecked")
public void onError(final String errorCode, final String errDetail, final Object errCtx) {
    // Note: the if-then-else below is based on the actual usage
    // (codebase search), it has to be kept up-to-date as the code changes
    String errCode = errorCode.intern();
    StringBuffer msg = new StringBuffer();
    msg.append(errCode).append(" (");
    msg.append(errDetail).append("): ");
    if (errCode == ErrorConstants.NO_INITIAL) {
        if (errCtx instanceof SCXML) {
            // determineInitialStates
            msg.append("<SCXML>");
        } else if (errCtx instanceof State) {
            // determineInitialStates
            // determineTargetStates
            msg.append("State " + LogUtils.getTTPath((State) errCtx));
        }
    } else if (errCode == ErrorConstants.UNKNOWN_ACTION) {
        // executeActionList
        msg.append("Action: " + errCtx.getClass().getName());
    } else if (errCode == ErrorConstants.ILLEGAL_CONFIG)
        // isLegalConfig
        if (errCtx instanceof Map.Entry) { // unchecked cast below
            Map.Entry<TransitionTarget, Set<TransitionTarget>> badConfigMap = (Map.Entry<TransitionTarget, Set<TransitionTarget>>) errCtx;
            TransitionTarget tt = badConfigMap.getKey();
            Set<TransitionTarget> vals = badConfigMap.getValue();
            msg.append(LogUtils.getTTPath(tt) + " : [");
            for (Iterator<TransitionTarget> i = vals.iterator(); i.hasNext();) {
                TransitionTarget tx = i.next();
                msg.append(LogUtils.getTTPath(tx));
                if (i.hasNext()) {
                    msg.append(", ");
                }
            }
            msg.append(']');
        } else if (errCtx instanceof Set) { // unchecked cast below
            Set<TransitionTarget> vals = (Set<TransitionTarget>) errCtx;
            msg.append("<SCXML> : [");
            for (Iterator<TransitionTarget> i = vals.iterator(); i.hasNext();) {
                TransitionTarget tx = i.next();
                msg.append(LogUtils.getTTPath(tx));
                if (i.hasNext()) {
                    msg.append(", ");
                }
            }
            msg.append(']');
        }
    if (log.isWarnEnabled()) {
        log.warn(msg.toString());
    }
}