/* * Copyright 2004 Gunn Software Ltd. http://www.gunnsoft.com.au/ * * Licensed 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 net.sf.tapestrypublisher; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import org.wanto.sxp.SimpleParseListener; /** * @author Paul Stanton * SXP parse listener implementation */ public class ConfigParseListener extends SimpleParseListener { private List sites = new ArrayList(); private Site curSite; private List curPages; private List curPathTranslations; private List curResources; public void startElement(String name, Hashtable attr) { if (name.equals("site")) { curSite = new Site(); curSite.setUrl((String) attr.get("url")); curSite.setDest((String) attr.get("dest")); curSite.setPages(curPages = new ArrayList()); curSite.setPathTranslations(curPathTranslations = new ArrayList()); curSite.setResources(curResources = new ArrayList()); sites.add(curSite); } else if (name.equals("page")) { Page page = new Page(); curPages.add(page); page.setName((String) attr.get("name")); page.setDest((String) attr.get("dest")); } else if (name.equals("resource")) { Resource res = new Resource(); curResources.add(res); res.setSource((String) attr.get("source")); res.setDest((String) attr.get("dest")); if (attr.get("excludes") != null) res.setExcludes(((String) attr.get("excludes")).split(",")); } else if (name.equals("path")) { PathTranslation path = new PathTranslation(); curPathTranslations.add(path); path.setRelative((String) attr.get("relative")); path.setVirtual((String) attr.get("virtual")); } } public List getSites() { return sites; } }