Package net.sf.laja.context

Examples of net.sf.laja.context.MapContext


    context.addMacro(this);
    return null;
  }

  public void populateArguments(List<Object> arguments) {
    MapContext populatedArguments = new MapContext(name, namespaces, templateTextWriter);
   
    Iterator<Object> argumentsIterator = arguments.iterator();
   
    for (String parameter : parameters) {
      if (!argumentsIterator.hasNext()) {
        throw new InterpretationException(source, indexInSource, "Missing argument in parameter list for macro '" + name + "'");
      }
      populatedArguments.set(parameter, argumentsIterator.next());
    }
    if (argumentsIterator.hasNext()) {
      throw new InterpretationException(source, indexInSource, "Too many arguments in parameter list for macro '" + name + "'");
    }
    localContext.setLocalVariables(populatedArguments);
View Full Code Here


    }
    localContext.setLocalVariables(populatedArguments);
  }
 
  public void populateDataArguments(List<Data> arguments) {
    MapContext populatedArguments = new MapContext(name, namespaces, templateTextWriter);
   
    Iterator<Data> argumentsIterator = arguments.iterator();

    for (String parameter : parameters) {
      if (!argumentsIterator.hasNext()) {
        throw new InterpretationException(source, indexInSource, "Missing argument in parameter list for macro '" + name + "'");
      }
      Data argument = argumentsIterator.next();
      if (argument.isLazy()) {
        populatedArguments.set(parameter, argument);
      } else {
        populatedArguments.set(parameter, argument.evaluate());
      }
    }
    if (argumentsIterator.hasNext()) {
      throw new InterpretationException(source, indexInSource, "Too many arguments in parameter list for macro '" + name + "'");
    }
View Full Code Here

    try {
      if (primitive != null) {
        attribute = primitive.evaluate();
      } else if (isNamespaceRef()) {
        String namespaceName = namespaceRef.getNamespaceName();
        MapContext namespaceContext = namespaces.getNamespaceContext(namespaceName);
        if (namespaceContext == null) {
          throw new InterpretationException(source, indexInSource, "Could not find namespace '" + namespaceName + "'");
        }
        attribute = namespaceContext.getMap();
      } else if (namespaceRef == null) {
        attribute = getResultFromCurrentOrDefaultNamespace();
      } else {
        attribute = getResultFromSpecifiedNamespace();
      }
View Full Code Here

  }
 
  public void setAttribute(String attributeName, Context parentContext) {
    Map<String,Object> map = new LinkedHashMap<String,Object>();
    parentContext.set(attributeName, map);
    Context mapSetter = new MapContext(attributeName, namespaces, templateTextWriter, map);
    for (MapMember member : members) {
      member.set(mapSetter);
    }
  }
View Full Code Here

  private Map<String,MapContext> namespaces;

  public Namespaces(TemplateTextWriter templateTextWriter) {
    this.templateTextWriter = templateTextWriter;
    namespaces = new HashMap<String,MapContext>();
    MapContext defaultContext = new MapContext(DEFAULT_NAMESPACE, this, templateTextWriter);
    namespaces.put(DEFAULT_NAMESPACE, defaultContext);
  }
View Full Code Here

    return getNamespaceContext(name);
  }
 
 
  private MapContext createNamespace(String name) {
    MapContext context = new MapContext(name, this, templateTextWriter);
    namespaces.put(name, context);

    return context;
  }
View Full Code Here

TOP

Related Classes of net.sf.laja.context.MapContext

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.