001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.linkdirectory.dynamic; 017 018import org.xml.sax.Attributes; 019import org.xml.sax.ContentHandler; 020import org.xml.sax.SAXException; 021 022import org.ametys.core.util.IgnoreRootHandler; 023 024/** 025 * Ignore root handler that remove the 'dynamic-information' root tag 026 */ 027public class DynamicInformationHandler extends IgnoreRootHandler 028{ 029 private static final String __DYNAMIC_INFO_ROOT_TAG = "dynamic-information"; 030 031 private ContentHandler _contentHandler; 032 033 /** 034 * Create a handler 035 * @param contentHandler The handler to wrap 036 */ 037 public DynamicInformationHandler(ContentHandler contentHandler) 038 { 039 super(contentHandler); 040 _contentHandler = contentHandler; 041 } 042 043 @Override 044 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException 045 { 046 if (!qName.equals(__DYNAMIC_INFO_ROOT_TAG)) 047 { 048 _contentHandler.startElement(uri, localName, qName, atts); 049 } 050 } 051 052 @Override 053 public void endElement(String uri, String localName, String qName) throws SAXException 054 { 055 if (!qName.equals(__DYNAMIC_INFO_ROOT_TAG)) 056 { 057 _contentHandler.endElement(uri, localName, qName); 058 } 059 } 060}