View Javadoc
1   package org.apache.turbine.services.urlmapper.model;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.LinkedHashMap;
23  import java.util.Map;
24  import java.util.Set;
25  import java.util.regex.Pattern;
26  
27  import javax.xml.bind.annotation.XmlAccessType;
28  import javax.xml.bind.annotation.XmlAccessorType;
29  import javax.xml.bind.annotation.XmlElement;
30  import javax.xml.bind.annotation.XmlType;
31  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
32  
33  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
34  import com.fasterxml.jackson.annotation.JsonProperty;
35  
36  /**
37   * The url map model class
38   *
39   * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
40   */
41  @XmlType(name="map")
42  @XmlAccessorType(XmlAccessType.NONE)
43  @JsonIgnoreProperties(ignoreUnknown = true)
44  public class URLMapEntry
45  {
46      private Pattern urlPattern;
47      private Map<String, String> implicit = new LinkedHashMap<>();
48      private Map<String, String> ignore = new LinkedHashMap<>();
49      private Map<String, String> override = new LinkedHashMap<>();
50  
51      private Map<String, Integer> groupNamesMap;
52      private Set<String> relevantKeys = null;
53  
54      /**
55       * @return the urlPattern
56       */
57      @XmlElement(name="pattern")
58      @XmlJavaTypeAdapter(XmlPatternAdapter.class)
59      @JsonProperty("pattern")
60      public Pattern getUrlPattern()
61      {
62          return urlPattern;
63      }
64  
65      /**
66       * @param urlPattern the urlPattern to set
67       */
68      protected void setUrlPattern(Pattern urlPattern)
69      {
70          this.urlPattern = urlPattern;
71      }
72  
73      /**
74       * @return the implicit parameters
75       */
76      @XmlElement(name="implicit-parameters")
77      @XmlJavaTypeAdapter(XmlParameterAdapter.class)
78      @JsonProperty("implicit-parameters")
79      public Map<String, String> getImplicitParameters()
80      {
81          return implicit;
82      }
83  
84      /**
85       * @param implicit the implicit parameters to set
86       */
87      protected void setImplicitParameters(Map<String, String> implicit)
88      {
89          this.implicit = implicit;
90      }
91  
92      /**
93       * @return the ignored parameters
94       */
95      @XmlElement(name="ignore-parameters")
96      @XmlJavaTypeAdapter(XmlParameterAdapter.class)
97      @JsonProperty("ignore-parameters")
98      public Map<String, String> getIgnoreParameters()
99      {
100         return ignore;
101     }
102 
103     /**
104      * @param ignore the ignored parameters to set
105      */
106     protected void setIgnoreParameters(Map<String, String> ignore)
107     {
108         this.ignore = ignore;
109     }
110 
111     /**
112      * @return the override parameters
113      */
114     @XmlElement(name="override-parameters")
115     @XmlJavaTypeAdapter(XmlParameterAdapter.class)
116     @JsonProperty("override-parameters")
117     public Map<String, String> getOverrideParameters()
118     {
119         return override;
120     }
121 
122     /**
123      * @param override the override parameters to set
124      */
125     protected void setOverrideParameters(Map<String, String> override)
126     {
127         this.override = override;
128     }
129 
130     /**
131      * Get the map of group names to group indices for the stored Pattern
132      *
133      * @return the groupNamesMap
134      */
135     public Map<String, Integer> getGroupNamesMap()
136     {
137         return groupNamesMap;
138     }
139 
140     /**
141      * Set the map of group names to group indices for the stored Pattern
142      *
143      * @param groupNamesMap the groupNamesMap to set
144      */
145     public void setGroupNamesMap(Map<String, Integer> groupNamesMap)
146     {
147         this.groupNamesMap = groupNamesMap;
148     }
149 
150     /**
151      * Get the set of relevant keys for comparison (cached for performance)
152      *
153      * @return the relevantKeys
154      */
155     public Set<String> getRelevantKeys()
156     {
157         return relevantKeys;
158     }
159 
160     /**
161      * Set the set of relevant keys for comparison (cached for performance)
162      *
163      * @param relevantKeys the relevantKeys to set
164      */
165     public void setRelevantKeys(Set<String> relevantKeys)
166     {
167         this.relevantKeys = relevantKeys;
168     }
169 
170     @Override
171     public String toString()
172     {
173     	return "URLMapEntry: [ pattern: " + urlPattern + ", implicit-parameters: " + implicit + ", override-parameters: " + override + ", ignore-parameters:" + ignore + " ]";
174     }
175 }