KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > dynamic > FilterHandler


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.dynamic;
12
13 import org.eclipse.core.expressions.IEvaluationContext;
14 import org.eclipse.help.UAContentFilter;
15 import org.eclipse.help.internal.UAElement;
16
17 /*
18  * The handler responsible for filtering elements. Filters can either be
19  * an attribute of the element to filter, or any number of child filter
20  * elements.
21  */

22 public class FilterHandler extends ProcessorHandler {
23
24     private IEvaluationContext context;
25     
26     public FilterHandler(IEvaluationContext context) {
27         this.context = context;
28     }
29
30     public short handle(UAElement element, String JavaDoc id) {
31         if (UAContentFilter.isFiltered(element, context)) {
32             UAElement parent = element.getParentElement();
33             if (parent != null) {
34                 parent.removeChild(element);
35             }
36             return HANDLED_SKIP;
37         }
38         return UNHANDLED;
39     }
40 }
41
Popular Tags