1 19 20 package org.netbeans.modules.web.wizards; 21 22 23 28 class FilterMappingData { 29 30 private String name = null; 31 private Type type = null; 32 private String pattern = null; 33 private Dispatcher[] dispatch = new Dispatcher[0]; 34 35 FilterMappingData() {} 36 37 FilterMappingData(String name) { 38 this.name = name; 39 this.type = FilterMappingData.Type.URL; 40 this.pattern = "/*"; } 42 43 FilterMappingData(String name, Type type, String pattern, Dispatcher[] d) { 44 this.name = name; 45 this.type = type; 46 this.pattern = pattern; 47 this.dispatch = d; 48 } 49 50 public Object clone() { 51 return new FilterMappingData(name, type, pattern, dispatch); 52 } 53 54 58 String getName() { 59 return name; 60 } 61 62 66 void setName(String newName) { 67 this.name = newName; 68 } 69 70 74 Type getType() { 75 return type; 76 } 77 78 82 void setType(Type newType) { 83 this.type = newType; 84 } 85 86 90 String getPattern() { 91 return pattern; 92 } 93 94 98 void setPattern(String newPattern) { 99 this.pattern = newPattern; 100 } 101 102 106 Dispatcher[] getDispatcher() { 107 return dispatch; 108 } 109 110 114 void setDispatcher(Dispatcher[] d) { 115 this.dispatch = d; 116 } 117 118 public String toString() { 119 StringBuffer buf = 120 new StringBuffer ("FilterMapping for filter: "); buf.append(name); 122 buf.append("\nMapping type: "); 123 buf.append(type.toString()); 124 buf.append(" for pattern: "); 125 buf.append(pattern); 126 buf.append("\nDispatch conditions: "); 127 if(dispatch.length == 0) 128 buf.append("REQUEST (not set)\n\n"); 129 else { 130 for(int i=0; i<dispatch.length; ++i) { 131 buf.append(dispatch[i].toString()); 132 buf.append(", "); 133 } 134 buf.append("\n\n"); 135 } 136 return buf.toString(); 137 } 138 139 static class Type { 140 private String name; 141 private Type(String name) { this.name = name; } 142 public String toString() { return name; } 143 public static final Type URL = new Type("URL pattern"); 144 public static final Type SERVLET = new Type("Servlet"); 145 } 146 147 static class Dispatcher { 148 private String name; 149 private Dispatcher(String name) { this.name = name; } 150 public String toString() { return name; } 151 public static final Dispatcher BLANK = new Dispatcher(""); 152 public static final Dispatcher REQUEST = new Dispatcher("REQUEST"); 153 public static final Dispatcher INCLUDE = new Dispatcher("INCLUDE"); 154 public static final Dispatcher FORWARD = new Dispatcher("FORWARD"); 155 public static final Dispatcher ERROR = new Dispatcher("ERROR"); 156 public static final Dispatcher findDispatcher(String s) { 157 if(s.equals(REQUEST.toString())) return REQUEST; 158 else if(s.equals(INCLUDE.toString())) return INCLUDE; 159 else if(s.equals(FORWARD.toString())) return FORWARD; 160 else if(s.equals(ERROR.toString())) return ERROR; 161 else return BLANK; 162 } 163 public static final Dispatcher[] getAll() { 164 Dispatcher[] d = new Dispatcher[4]; 165 d[0] = REQUEST; 166 d[1] = FORWARD; 167 d[2] = INCLUDE; 168 d[3] = ERROR; 169 return d; 170 } 171 } 172 } | Popular Tags |