Package net.sf.laja.exception

Examples of net.sf.laja.exception.InterpretationException


    }
  }

  private Object evaluateExceptionAndListIndex(Object attribute) {
    if (attribute instanceof Exception) {
      throw new InterpretationException(source, indexInSource, (Exception) attribute);
    }
    if (attributeRef != null && attributeRef.hasListIndex()) {
      attribute = attributeRef.evaluateArrayOrList(attribute);
    }
    return attribute;
View Full Code Here


    return null;
  }
 
  protected Object generateMacro() {
    if (nextAttributeRefs.hasAttributes()) {
      throw new InterpretationException(source, indexInSource, "Accessing attributes or methods on macros not supported. Use #set or #function");
    }
    Macro macro = attributeRef.getMacro(getContext());

    if (macro == null) {
      throw new InterpretationException(source, indexInSource, "Could not find macro '" + attributeRef.getMethodName() + "'");
    }
   
    if (attributeRef.hasMethodArguments()) {
      macro.populateDataArguments(attributeRef.getMethodArguments().getArguments());
    }
View Full Code Here

  protected Object evaluateFunction() {
    Macro macro = attributeRef.getMacro(getContext());

    if (macro == null) {
      throw new InterpretationException(source, indexInSource, "Could not find macro '" + attributeRef.getMethodName() + "'");
    }
   
    if (attributeRef.hasMethodArguments()) {
      macro.populateDataArguments(attributeRef.getMethodArguments().getArguments());
    }

    if (macro.getBlock() == null) {
       throw new InterpretationException(source, indexInSource, "Missing return statement for function '" + macro.getName() + "'");
    }
    Object attribute = macro.getBlock().generate();
   
    if (!macro.getBlock().hasReturnBeenExecuted()) {
      throw new LajaException("No value was returned from macro '" + macro.getName() + "'");
View Full Code Here

  public static Boolean toBoolean(Object value, Source source, int indexInSource) {
    if (value instanceof Boolean) {
      return ((Boolean)value);
    } else {
      if (value == null) {
        throw new InterpretationException(source, indexInSource, "Can not evaluate null to a boolean value");
      }
      String string = value.toString();
      try {
        return new Boolean(string);
      } catch (NumberFormatException e) {
        throw new InterpretationException(source, indexInSource, "Boolean value (true/false) was expected, found:  " + string);
      }
    }
  }
View Full Code Here

      String writeToFile = filename.evaluate();
      System.out.print("  Writing to file \"" + getPath(writeToFile) + "\"");
      out = new PrintWriter(new BufferedWriter(new FileWriter(writeToFile)));
    } catch (IOException e) {
      System.out.println();
      throw new InterpretationException(source, indexInSource, e);
    }
  }
View Full Code Here

    } else if (ref.getClass().isArray()) {
      iterator = new ArrayListAdapter(ref).iterator();
    } else if (ref instanceof Map) {
      iterator = new MapListAdapter((Map)ref).iterator();
    } else {
      throw new InterpretationException(source, indexInSource, "Can not iterate over a " + ref.getClass().getCanonicalName());
    }
    return iterator;
  }
View Full Code Here

  public void setMessage(IStringExp imessage) {
    message = (StringExp)imessage;
  }

  public Object generate() {
    throw new InterpretationException(source, indexInSource, message.evaluate());
  }
View Full Code Here

    Object returnedValue = reference.evaluate();
   
    if (targetNamespace != null) {
      if (!namespaces.namespaceExists(targetNamespace)) {
        throw new InterpretationException(source, indexInSource, "Could not find namespace '" + targetNamespace + "'");
      }
      if (returnedValue instanceof Map) {
        Map returnedMap = (Map)returnedValue;
        Context targetContext = namespaces.getNamespaceContext(targetNamespace);
       
        for (Object key : returnedMap.keySet()) {
          targetContext.set(key.toString(), returnedMap.get(key));
        }
      } else {
        throw new InterpretationException(source, indexInSource, "Returned value must implement the interface 'java.util.Map'");
      }
    } else if (targetVariable != null) {
      context.set(targetVariable, returnedValue);
    } else {
      throw new IllegalStateException("We shold nevere get here!");
View Full Code Here

TOP

Related Classes of net.sf.laja.exception.InterpretationException

Copyright © 2018 www.massapicom. 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.