Examples of InterpretException


Examples of com.ibm.jscript.InterpretException

    String msg = "";
    if ("com.ibm.xsp.exception.EvaluationExceptionEx".equals(error.getClass().getName())) {
      // EvaluationExceptionEx, so SSJS error is on a component property.
      // Hit by ErrorOnLoad.xsp
      EvaluationExceptionEx ee = (EvaluationExceptionEx) error;
      InterpretException ie = (InterpretException) ee.getCause();
      msg = "Error on " + ee.getErrorComponentId() + " " + ee.getErrorPropertyId() + " property/event, line "
          + Integer.toString(ie.getErrorLine()) + ":\n\n" + ie.getLocalizedMessage() + "\n\n" + ie.getExpressionText();
      XspOpenLogUtil.getXspOpenLogItem().logErrorEx(ee, msg, null, null);

    } else if ("javax.faces.FacesException".equals(error.getClass().getName())) {
      // FacesException, so error is on event or method in EL
      FacesException fe = (FacesException) error;
      InterpretException ie = null;
      EvaluationExceptionEx ee = null;
      msg = "Error on ";
      try {
        // javax.faces.el.MethodNotFoundException hit by ErrorOnMethod.xsp
        if (!"javax.faces.el.MethodNotFoundException".equals(fe.getCause().getClass().getName())) {
          if ("com.ibm.xsp.exception.EvaluationExceptionEx".equals(fe.getCause().getClass().getName())) {
            // Hit by ErrorOnClick.xsp
            ee = (EvaluationExceptionEx) fe.getCause();
          } else if ("javax.faces.el.PropertyNotFoundException".equals(fe.getCause().getClass().getName())) {
            // Property not found exception, so error is on a component property
            msg = "PropertyNotFoundException Error, cannot locate component:\n\n";
          } else if ("com.ibm.xsp.exception.EvaluationExceptionEx".equals(fe.getCause().getCause().getClass().getName())) {
            // Hit by using e.g. currentDocument.isNewDoc()
            // i.e. using a Variable that relates to a valid Java object but a method that doesn't exist
            ee = (EvaluationExceptionEx) fe.getCause().getCause();
          }
          if (null != ee) {
            msg = msg + ee.getErrorComponentId() + " " + ee.getErrorPropertyId() + " property/event:\n\n";
            if ("com.ibm.jscript.InterpretException".equals(ee.getCause().getClass().getName())) {
              ie = (InterpretException) ee.getCause();
            }
          }
        }
      } catch (Throwable t) {
        msg = "Unexpected error class: " + fe.getCause().getClass().getName() + "\n Message recorded is: ";
      }
      if (null != ie) {
        msg = msg + Integer.toString(ie.getErrorLine()) + ":\n\n" + ie.getLocalizedMessage() + "\n\n" + ie.getExpressionText();
      } else {
        msg = msg + fe.getCause().getLocalizedMessage();
      }
      XspOpenLogUtil.getXspOpenLogItem().logErrorEx(fe.getCause(), msg, null, null);
    } else if ("com.ibm.xsp.FacesExceptionEx".equals(error.getClass().getName())) {
      // FacesException, so error is on event - doesn't get hit in examples. Can this still get hit??
      FacesExceptionEx fe = (FacesExceptionEx) error;
      try {
        if ("lotus.domino.NotesException".equals(fe.getCause().getClass().getName())) {
          // sometimes the cause is a NotesException
          NotesException ne = (NotesException) fe.getCause();

          msg = msg + "NotesException - " + Integer.toString(ne.id) + " " + ne.text;
        } else if ("java.io.IOException".equals(error.getClass().getName())) {
          IOException e = (IOException) error;

          msg = "Java IO:" + error.toString();
          XspOpenLogUtil.getXspOpenLogItem().logErrorEx(e.getCause(), msg, null, null);
        } else {
          EvaluationExceptionEx ee = (EvaluationExceptionEx) fe.getCause();
          InterpretException ie = (InterpretException) ee.getCause();

          msg = "Error on " + ee.getErrorComponentId() + " " + ee.getErrorPropertyId() + " property/event:\n\n"
              + Integer.toString(ie.getErrorLine()) + ":\n\n" + ie.getLocalizedMessage() + "\n\n" + ie.getExpressionText();
        }
      } catch (Throwable t) {
        msg = "Unexpected error class: " + fe.getCause().getClass().getName() + "\n Message recorded is: "
            + fe.getCause().getLocalizedMessage();
        ;
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

public class EqualFilter implements Filter{

  @Override
  public Object filter(Object object, JangodInterpreter interpreter, String... arg) throws InterpretException {
    if ( arg.length != 1 ) {
      throw new InterpretException("filter equal expects 1 arg >>> " + arg.length);
    }
    Object argObj ;
    boolean isNull = false;
    if ( arg[0].startsWith(Constants.STR_SINGLE_QUOTE) || arg[0].startsWith(Constants.STR_DOUBLE_QUOTE) ) {
      argObj = arg[0].substring(1, arg[0].length()-1);
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  @Override
  public Object filter(Object object, JangodInterpreter interpreter, String... arg)
      throws InterpretException {
    if ( arg.length != 1) {
      throw new InterpretException("filter add expects 1 arg >>> " + arg.length);
    }
    Object toAdd = interpreter.resolveObject(arg[0]);
    Number num;
    if ( toAdd instanceof String ) {
      try {
        num = new BigDecimal(toAdd.toString());
      } catch (Exception e) {
        throw new InterpretException("filter add arg can't cast to number >>> " + toAdd);
      }
    } else if ( toAdd instanceof Number ) {
      num = (Number) toAdd;
    } else {
      return object;
    }
    if ( object instanceof Integer ) {
      return 0L + num.intValue() + (Integer)object;
    }
    if ( object instanceof Float ) {
      return 0D + num.floatValue() + (Float)object;
    }
    if ( object instanceof Long ) {
      return num.longValue() + (Long)object;
    }
    if ( object instanceof Short ) {
      return 0 + num.shortValue() + (Short)object;
    }
    if ( object instanceof Double ) {
      return num.doubleValue() + (Double)object;
    }
    if ( object instanceof BigDecimal ) {
      return ((BigDecimal)object).add(BigDecimal.valueOf(num.doubleValue()));
    }
    if ( object instanceof BigInteger ) {
      return ((BigInteger)object).add(BigInteger.valueOf(num.longValue()));
    }
    if ( object instanceof Byte ) {
      return num.byteValue() + (Byte)object;
    }
    if ( object instanceof String ) {
      try {
        String sv = (String) object;
        if ( sv.contains(".") ) {
          return num.doubleValue() + Double.valueOf(sv);
        } else {
          return num.longValue() + Long.valueOf(sv);
        }
      } catch (Exception e) {
        throw new InterpretException(object + " can't be dealed with add filter");
      }
    }
    return object;
  }
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  @Override
  public String interpreter(NodeList carries, String helpers, JangodInterpreter interpreter)
      throws InterpretException {
    if ( helpers.length() == 0 ) {
      throw new InterpretException("Tag 'ifchanged' expects 1 helper >>> 0");
    }
    boolean isChanged = true;
    String var = helpers;
    Object older = interpreter.fetchRuntimeScope(LASTKEY + var);
    Object test = interpreter.retraceVariable(var);
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

      sdf.setTimeZone(interpreter.getConfiguration().getTimezone());
    } else if ( arg.length == 2 ) {
      sdf = new SimpleDateFormat(interpreter.resolveString(arg[0]));
      sdf.setTimeZone(TimeZone.getTimeZone(interpreter.resolveString(arg[1])));
    } else {
      throw new InterpretException("filter date expects 1 or 2 args >>> " + arg.length);
    }
    try {
      return sdf.format(object);
    } catch (Exception e) {
      JangodLogger.log(Level.SEVERE, "filter date can't format a datetime >>> " + object, e.getCause());
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  @Override
  public String interpreter(NodeList carries, String helpers, JangodInterpreter interpreter)
      throws InterpretException {
    String[] helper = new HelperStringTokenizer(helpers).allTokens();
    if( helper.length != 1) {
      throw new InterpretException("Tag 'extends' expects 1 helper >>> " + helper.length);
    }
    String templateFile = interpreter.resolveString(helper[0]);
    try {
      String fullName = ResourceManager.getFullName(templateFile,
          interpreter.getWorkspace(), interpreter.getConfiguration().getWorkspace());
      Node node = interpreter.getContext().getApplication().getParseResult(
          fullName, interpreter.getConfiguration().getEncoding() );
     
     
      ListOrderedMap blockList = new ListOrderedMap();
      interpreter.assignRuntimeScope(JangodInterpreter.BLOCK_LIST, blockList, 1);
      JangodInterpreter parent = interpreter.clone();
      interpreter.assignRuntimeScope(JangodInterpreter.CHILD_FLAG, true, 1);
      parent.assignRuntimeScope(JangodInterpreter.PARENT_FLAG, true, 1);
      String semi = parent.render(node);
      interpreter.assignRuntimeScope(JangodInterpreter.SEMI_RENDER, semi, 1);
      return Constants.STR_BLANK;
    } catch (IOException e) {
      throw new InterpretException(e.getMessage());
    }
  }
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

    if ( object == null ) {
      return false;
    }
    if ( object instanceof Number ) {
      if ( arg.length != 1 ) {
        throw new InterpretException("filter divisible expects 1 arg >>> " + arg.length);
      }
      long factor = Long.valueOf(interpreter.resolveString(arg[0]));
      long value = ((Number)object).longValue();
      if ( value % factor == 0 ) {
        return true;
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  @Override
  public String interpreter(NodeList carries, String helpers, JangodInterpreter interpreter) throws InterpretException {
    String[] helper = new HelperStringTokenizer(helpers).allTokens();
    if ( helper.length < 2 || helper.length > 3 ) {
      throw new InterpretException("Tag 'set' expects 2 or 3 helper >>> " + helper.length);
    }
    String scope = SCOPE_TOP;
    if ( helper.length == 3 ) {
      scope = helper[2].toLowerCase();
    }
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  public Object filter(Object object, JangodInterpreter interpreter, String... arg) throws InterpretException {
    if ( ObjectTruthValue.evaluate(object) ) {
      return object;
    } else {
      if ( arg.length != 1) {
        throw new InterpretException("filter default expects 1 arg >>> " + arg.length);
      }
      return interpreter.resolveObject(arg[0]);
    }
  }
View Full Code Here

Examples of net.asfun.jangod.interpret.InterpretException

  @Override
  public String interpreter(NodeList carries, String helpers, JangodInterpreter interpreter)
      throws InterpretException {
    String[] helper = new HelperStringTokenizer(helpers).allTokens();
    if( helper.length != 1) {
      throw new InterpretException("Tag 'block' expects 1 helper >>> " + helper.length);
    }
    String blockName = interpreter.resolveString(helper[0]);
    //check block name is unique
    List<String> blockNames = (List<String>) interpreter.fetchRuntimeScope(BLOCKNAMES ,1);
    if ( blockNames == null ) {
      blockNames = new ArrayList<String>();
    }
    if ( blockNames.contains(blockName) ) {
      throw new InterpretException("Can't redefine the block with name >>> " + blockName);
    } else {
      blockNames.add(blockName);
      interpreter.assignRuntimeScope(BLOCKNAMES, blockNames, 1);
    }
    Object isChild = interpreter.fetchRuntimeScope(JangodInterpreter.CHILD_FLAG, 1);
    if ( isChild != null ) {
      ListOrderedMap blockList = (ListOrderedMap) interpreter.fetchRuntimeScope(JangodInterpreter.BLOCK_LIST, 1);
      //check block was defined in parent
      if ( ! blockList.containsKey(blockName) ) {
        throw new InterpretException("Dosen't define block in extends parent with name >>> " + blockName);
      }
      //cover parent block content with child's.
      blockList.put(blockName, getBlockContent(carries, interpreter));
      return "";
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.