/********************************************************************** * Copyright (c) 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html  * * Contributors: * IBM - Initial API and implementation **********************************************************************/ package net.sourceforge.phpdt.monitor.core.internal; import java.io.IOException; import net.sourceforge.phpdt.monitor.core.IContentFilter; import net.sourceforge.phpdt.monitor.core.IContentFilterDelegate; import net.sourceforge.phpdt.monitor.core.IRequest; import org.eclipse.core.runtime.IConfigurationElement; /** * */ public class ContentFilter implements IContentFilter { protected IConfigurationElement element; protected IContentFilterDelegate delegate; protected ContentFilter(IConfigurationElement element) { this.element = element; } public String getId() { return element.getAttribute("id"); } public int getOrder() { try { return Integer.parseInt(element.getAttribute("order")); } catch (Exception e) { return 0; } } public String getName() { return element.getAttribute("name"); } public byte[] filter(IRequest request, boolean isRequest, byte[] b) throws IOException { if (delegate == null) { try { delegate = (IContentFilterDelegate) element.createExecutableExtension("class"); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Could not create content filter delegate: " + getId(), e); return new byte[0]; } } return delegate.filter(request, isRequest, b); } }