blob: 6759893b24dfd7fe682c4e7e00ff99b6acb3c80d [file] [log] [blame]
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.sling.scripting.sightly.impl.compiler.frontend;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.sling.scripting.sightly.impl.compiler.PushStream;
import org.apache.sling.scripting.sightly.impl.filter.Filter;
import org.apache.sling.scripting.sightly.impl.html.dom.DocumentParser;
import org.apache.sling.scripting.sightly.impl.html.dom.MarkupHandler;
import org.apache.sling.scripting.sightly.impl.plugin.Plugin;
/**
* DOM-based compiler implementation
*/
public class SimpleFrontend {
private final Map<String, Plugin> plugins;
private final List<Filter> filters;
private final Set<String> knownExpressionOptions;
public SimpleFrontend(List<Plugin> plugins, List<Filter> filters, Set<String> knownExpressionOptions) {
this.plugins = new HashMap<>();
this.filters = filters;
this.knownExpressionOptions = knownExpressionOptions;
for (Plugin plugin : plugins) {
this.plugins.put(plugin.name(), plugin);
}
}
public void compile(PushStream stream, String source) {
MarkupHandler markupHandler = new MarkupHandler(stream, plugins, filters, knownExpressionOptions);
DocumentParser.parse(source, markupHandler);
}
}