2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.servlet;
21 import java.io.IOException;
22 import java.util.Arrays;
24 import org.eclipse.jetty.util.annotation.ManagedAttribute;
25 import org.eclipse.jetty.util.annotation.ManagedObject;
27 @ManagedObject("Servlet Mapping")
28 public class ServletMapping
30 private String[] _pathSpecs;
31 private String _servletName;
32 private boolean _default;
35 /* ------------------------------------------------------------ */
36 public ServletMapping()
40 /* ------------------------------------------------------------ */
42 * @return Returns the pathSpecs.
44 @ManagedAttribute(value="url patterns", readonly=true)
45 public String[] getPathSpecs()
50 /* ------------------------------------------------------------ */
52 * @return Returns the servletName.
54 @ManagedAttribute(value="servlet name", readonly=true)
55 public String getServletName()
60 /* ------------------------------------------------------------ */
62 * @param pathSpecs The pathSpecs to set.
64 public void setPathSpecs(String[] pathSpecs)
66 _pathSpecs = pathSpecs;
69 /* ------------------------------------------------------------ */
71 * @param pathSpec The pathSpec to set.
73 public void setPathSpec(String pathSpec)
75 _pathSpecs = new String[]{pathSpec};
78 /* ------------------------------------------------------------ */
80 * @param servletName The servletName to set.
82 public void setServletName(String servletName)
84 _servletName = servletName;
88 /* ------------------------------------------------------------ */
92 @ManagedAttribute(value="default", readonly=true)
93 public boolean isDefault()
99 /* ------------------------------------------------------------ */
103 public void setDefault(boolean fromDefault)
105 _default = fromDefault;
108 /* ------------------------------------------------------------ */
109 public String toString()
111 return (_pathSpecs==null?"[]":Arrays.asList(_pathSpecs).toString())+"=>"+_servletName;
114 /* ------------------------------------------------------------ */
115 public void dump(Appendable out, String indent) throws IOException
117 out.append(String.valueOf(this)).append("\n");