001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.markup.head.filter; 018 019import org.apache.wicket.markup.head.HeaderItem; 020import org.apache.wicket.markup.head.IWrappedHeaderItem; 021import org.apache.wicket.markup.head.filter.FilteringHeaderResponse.IHeaderResponseFilter; 022 023/** 024 * A default implementation of IHeaderResponseFilter that returns true for everything. It is defined 025 * as abstract because you are not supposed to use it directly, but use it as a base and override 026 * any methods that you need to return something other than true from (whether that's always false 027 * or conditional logic). 028 * 029 * @author Jeremy Thomerson 030 */ 031public abstract class AbstractHeaderResponseFilter implements IHeaderResponseFilter 032{ 033 034 private final String name; 035 036 /** 037 * Create a response filter. 038 * 039 * @param name 040 */ 041 public AbstractHeaderResponseFilter(String name) 042 { 043 this.name = name; 044 } 045 046 @Override 047 public String getName() 048 { 049 return name; 050 } 051 052 @Override 053 public boolean accepts(HeaderItem item) 054 { 055 while (item instanceof IWrappedHeaderItem) 056 { 057 item = ((IWrappedHeaderItem)item).getWrapped(); 058 } 059 return acceptsWrapped(item); 060 } 061 062 protected boolean acceptsWrapped(HeaderItem item) 063 { 064 return true; 065 } 066}