1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2015 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. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.servlet; 20 21 import java.io.IOException; 22 import java.util.Arrays; 23 24 import org.eclipse.jetty.util.annotation.ManagedAttribute; 25 import org.eclipse.jetty.util.annotation.ManagedObject; 26 27 @ManagedObject("Servlet Mapping") 28 public class ServletMapping 29 { 30 private String[] _pathSpecs; 31 private String _servletName; 32 private boolean _default; 33 34 35 /* ------------------------------------------------------------ */ 36 public ServletMapping() 37 { 38 } 39 40 /* ------------------------------------------------------------ */ 41 /** 42 * @return Returns the pathSpecs. 43 */ 44 @ManagedAttribute(value="url patterns", readonly=true) 45 public String[] getPathSpecs() 46 { 47 return _pathSpecs; 48 } 49 50 /* ------------------------------------------------------------ */ 51 /** 52 * @return Returns the servletName. 53 */ 54 @ManagedAttribute(value="servlet name", readonly=true) 55 public String getServletName() 56 { 57 return _servletName; 58 } 59 60 /* ------------------------------------------------------------ */ 61 /** 62 * @param pathSpecs The pathSpecs to set. 63 */ 64 public void setPathSpecs(String[] pathSpecs) 65 { 66 _pathSpecs = pathSpecs; 67 } 68 69 /* ------------------------------------------------------------ */ 70 /** 71 * @param pathSpec The pathSpec to set. 72 */ 73 public void setPathSpec(String pathSpec) 74 { 75 _pathSpecs = new String[]{pathSpec}; 76 } 77 78 /* ------------------------------------------------------------ */ 79 /** 80 * @param servletName The servletName to set. 81 */ 82 public void setServletName(String servletName) 83 { 84 _servletName = servletName; 85 } 86 87 88 /* ------------------------------------------------------------ */ 89 @ManagedAttribute(value="default", readonly=true) 90 public boolean isDefault() 91 { 92 return _default; 93 } 94 95 96 /* ------------------------------------------------------------ */ 97 public void setDefault(boolean fromDefault) 98 { 99 _default = fromDefault; 100 } 101 102 /* ------------------------------------------------------------ */ 103 public String toString() 104 { 105 return (_pathSpecs==null?"[]":Arrays.asList(_pathSpecs).toString())+"=>"+_servletName; 106 } 107 108 /* ------------------------------------------------------------ */ 109 public void dump(Appendable out, String indent) throws IOException 110 { 111 out.append(String.valueOf(this)).append("\n"); 112 } 113 }