All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wings.template.TemplateParseContext Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2000,2005 wingS development team.
 *
 * This file is part of wingS (http://wingsframework.org).
 *
 * wingS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * Please see COPYING for the complete licence.
 */
package org.wings.template;

import org.wings.SComponent;
import org.wings.STemplateLayout;
import org.wings.io.Device;
import org.wings.io.DeviceOutputStream;
import org.wings.template.parser.ParseContext;

import java.io.OutputStream;
import java.util.*;

/**
 * @author Henner Zeller
 */
public class TemplateParseContext implements ParseContext {
    private final OutputStream myOut;
    private final Device sink;
    protected final STemplateLayout layout;
    private final Set containedComponents = new HashSet<>();
    private final Map> componentProperties = new HashMap<>();

    public TemplateParseContext(final Device sink, STemplateLayout layout) {
        this.sink = sink;
        this.layout = layout;
        myOut = new DeviceOutputStream(sink);
    }

    @Override
    public OutputStream getOutputStream() {
        return myOut;
    }

    @Override
    public void startTag(int number) {
    }

    @Override
    public void doneTag(int number) {
    }

    @Override
    public void addContainedComponent(String component) {
        containedComponents.add(component);
    }

    @Override
    public Set getContainedComponents() {
        return containedComponents;
    }

    /*
     * important for the template: the components write to this sink
     */
    public Device getDevice() {
        return sink;
    }

    public SComponent getComponent(String name) {
        return layout.getComponent(name);
    }

    @Override
    public void setProperties(String name, Map properties) {
        componentProperties.put(name, properties);
    }

    @Override
    public Map> getComponentProperties() {
        return componentProperties;
    }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy