Skip to main content
summaryrefslogtreecommitdiffstats
blob: 59394f252c6edd4e10e358325e345d9a514e1a2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2007, 2008 SAP AG and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.web.operations;

import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler;

public class FilterMappingItem implements IFilterMappingItem {
    
    private int mappingType;
    private int dispatchers;
    private String mapping;
    
    public FilterMappingItem(int type, String mapping) {
        mappingType = type;
        this.mapping = mapping;
    }

    public FilterMappingItem(int type, String mapping, int dispatchers) {
        this(type, mapping);
        this.dispatchers = dispatchers;
    }

    public int getMappingType() {
        return mappingType;
    }
    
    public boolean isUrlPatternType() {
    	return mappingType == IFilterMappingItem.URL_PATTERN;
    }
    
    public boolean isServletNameType() {
    	return mappingType == IFilterMappingItem.SERVLET_NAME;
    }

    public int getDispatchers() {
        return dispatchers;
    }

    public String getDispatchersAsString() {
        String result = ""; //$NON-NLS-1$
        if ((dispatchers & REQUEST) > 0) {
            result += WebAppEditResourceHandler.getString("DISPATCHER_R") + " ";  //$NON-NLS-1$ //$NON-NLS-2$
        }
        if ((dispatchers & FORWARD) > 0) {
            result += WebAppEditResourceHandler.getString("DISPATCHER_F") + " ";  //$NON-NLS-1$ //$NON-NLS-2$
        }
        if ((dispatchers & INCLUDE) > 0) {
            result += WebAppEditResourceHandler.getString("DISPATCHER_I") + " ";  //$NON-NLS-1$ //$NON-NLS-2$
        }
        if ((dispatchers & ERROR) > 0) {
            result += WebAppEditResourceHandler.getString("DISPATCHER_E") + " ";  //$NON-NLS-1$ //$NON-NLS-2$
        }
        return result.trim();
    }

    public String getName() {
        return mapping;
    }

}

Back to the top