1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal;
13 import java.io.IOException;
15 import net.sourceforge.phpdt.monitor.core.IContentFilter;
16 import net.sourceforge.phpdt.monitor.core.IContentFilterDelegate;
17 import net.sourceforge.phpdt.monitor.core.IRequest;
19 import org.eclipse.core.runtime.IConfigurationElement;
23 public class ContentFilter implements IContentFilter {
24 protected IConfigurationElement element;
25 protected IContentFilterDelegate delegate;
27 protected ContentFilter(IConfigurationElement element) {
28 this.element = element;
31 public String getId() {
32 return element.getAttribute("id");
35 public int getOrder() {
37 return Integer.parseInt(element.getAttribute("order"));
38 } catch (Exception e) {
43 public String getName() {
44 return element.getAttribute("name");
47 public byte[] filter(IRequest request, boolean isRequest, byte[] b) throws IOException {
48 if (delegate == null) {
50 delegate = (IContentFilterDelegate) element.createExecutableExtension("class");
51 } catch (Exception e) {
52 Trace.trace(Trace.SEVERE, "Could not create content filter delegate: " + getId(), e);
56 return delegate.filter(request, isRequest, b);