int idx = coerce(property);
if (idx < 0 || idx >= Array.getLength(base)) {
return null;
- } else {
- return Array.get(base, idx);
}
- }
+ return Array.get(base, idx);
+ }
return null;
}
}
protected final static class BeanProperty {
- private final Class type;
+ private final Class<?> type;
- private final Class owner;
+ private final Class<?> owner;
private final PropertyDescriptor descriptor;
if (m == null || Modifier.isPublic(type.getModifiers())) {
return m;
}
- Class[] inf = type.getInterfaces();
+ Class<?>[] inf = type.getInterfaces();
Method mp = null;
for (int i = 0; i < inf.length; i++) {
try {
return mp;
}
} catch (NoSuchMethodException e) {
+ // Ignore
}
}
- Class sup = type.getSuperclass();
+ Class<?> sup = type.getSuperclass();
if (sup != null) {
try {
mp = sup.getMethod(m.getName(), m.getParameterTypes());
return mp;
}
} catch (NoSuchMethodException e) {
+ // Ignore
}
}
return null;
private final boolean readOnly;
- private final static Class UNMODIFIABLE = Collections.unmodifiableList(
- new ArrayList()).getClass();
+ private final static Class<? extends List> UNMODIFIABLE =
+ Collections.unmodifiableList(new ArrayList<Object>()).getClass();
public ListELResolver() {
this.readOnly = false;
if (base instanceof List) {
context.setPropertyResolved(true);
- List list = (List) base;
+ List<Object> list = (List<Object>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
return null;
if (base instanceof List) {
context.setPropertyResolved(true);
- List list = (List) base;
+ List<Object> list = (List<Object>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
return null;
if (base instanceof List) {
context.setPropertyResolved(true);
- List list = (List) base;
+ List<Object> list = (List<Object>) base;
if (this.readOnly) {
throw new PropertyNotWritableException(message(context,
if (base instanceof List) {
context.setPropertyResolved(true);
- List list = (List) base;
+ List<Object> list = (List<Object>) base;
int idx = coerce(property);
if (idx < 0 || idx >= list.size()) {
throw new PropertyNotFoundException(
* is done by one of the <code>init</code> methods.
*
*/
-
- public GenericServlet() { }
+ public GenericServlet() {
+ // NOOP
+ }
*/
public void destroy() {
+ // NOOP by default
}
*/
public void init() throws ServletException {
-
+ // NOOP by default
}
* Does nothing, because this is an abstract class.
*
*/
-
- protected ServletInputStream() { }
+ protected ServletInputStream() {
+ // NOOP
+ }
* Does nothing, because this is an abstract class.
*
*/
-
- protected ServletOutputStream() { }
+ protected ServletOutputStream() {
+ // NOOP
+ }
/**
*/
public interface SingleThreadModel {
+ // No methods
}
* @author Various
* @version $Version$
*/
-public abstract class HttpServlet extends GenericServlet
- implements java.io.Serializable {
+public abstract class HttpServlet extends GenericServlet {
private static final String METHOD_DELETE = "DELETE";
private static final String METHOD_HEAD = "HEAD";
/**
* Does nothing, because this is an abstract class.
*/
- public HttpServlet() { }
+ public HttpServlet() {
+ // NOOP
+ }
/**
private int contentLength = 0;
// file private
- NoBodyOutputStream() {}
+ NoBodyOutputStream() {
+ // NOOP
+ }
// file private
int getContentLength() {
import java.io.IOException;
/**
- * @deprecated As of Java(tm) Servlet API 2.3.
- * These methods were only useful
- * with the default encoding and have been moved
- * to the request interfaces.
+ * @deprecated As of Java(tm) Servlet API 2.3.
+ * These methods were only useful
+ * with the default encoding and have been moved
+ * to the request interfaces.
*
*/
public class HttpUtils {
private static final String LSTRING_FILE =
- "javax.servlet.http.LocalStrings";
+ "javax.servlet.http.LocalStrings";
private static ResourceBundle lStrings =
- ResourceBundle.getBundle(LSTRING_FILE);
+ ResourceBundle.getBundle(LSTRING_FILE);
-
/**
* Constructs an empty <code>HttpUtils</code> object.
*
*/
+ public HttpUtils() {
+ // NOOP
+ }
- public HttpUtils() {}
-
-
-
-
/**
*
* sent in hexadecimal notation (like <i>%xx</i>) are
* converted to ASCII characters.
*
- * @param s a string containing the query to be parsed
+ * @param s a string containing the query to be parsed
*
- * @return a <code>HashTable</code> object built
- * from the parsed key-value pairs
+ * @return a <code>HashTable</code> object built
+ * from the parsed key-value pairs
*
- * @exception IllegalArgumentException if the query string
- * is invalid
+ * @exception IllegalArgumentException if the query string
+ * is invalid
*
*/
-
static public Hashtable<String,String[]> parseQueryString(String s) {
- String valArray[] = null;
-
- if (s == null) {
- throw new IllegalArgumentException();
- }
- Hashtable<String,String[]> ht = new Hashtable<String,String[]>();
- StringBuffer sb = new StringBuffer();
- StringTokenizer st = new StringTokenizer(s, "&");
- while (st.hasMoreTokens()) {
- String pair = st.nextToken();
- int pos = pair.indexOf('=');
- if (pos == -1) {
- // XXX
- // should give more detail about the illegal argument
- throw new IllegalArgumentException();
- }
- String key = parseName(pair.substring(0, pos), sb);
- String val = parseName(pair.substring(pos+1, pair.length()), sb);
- if (ht.containsKey(key)) {
- String oldVals[] = ht.get(key);
- valArray = new String[oldVals.length + 1];
- for (int i = 0; i < oldVals.length; i++)
- valArray[i] = oldVals[i];
- valArray[oldVals.length] = val;
- } else {
- valArray = new String[1];
- valArray[0] = val;
- }
- ht.put(key, valArray);
- }
- return ht;
+ String valArray[] = null;
+
+ if (s == null) {
+ throw new IllegalArgumentException();
+ }
+ Hashtable<String,String[]> ht = new Hashtable<String,String[]>();
+ StringBuffer sb = new StringBuffer();
+ StringTokenizer st = new StringTokenizer(s, "&");
+ while (st.hasMoreTokens()) {
+ String pair = st.nextToken();
+ int pos = pair.indexOf('=');
+ if (pos == -1) {
+ // XXX
+ // should give more detail about the illegal argument
+ throw new IllegalArgumentException();
+ }
+ String key = parseName(pair.substring(0, pos), sb);
+ String val = parseName(pair.substring(pos+1, pair.length()), sb);
+ if (ht.containsKey(key)) {
+ String oldVals[] = ht.get(key);
+ valArray = new String[oldVals.length + 1];
+ for (int i = 0; i < oldVals.length; i++)
+ valArray[i] = oldVals[i];
+ valArray[oldVals.length] = val;
+ } else {
+ valArray = new String[1];
+ valArray[0] = val;
+ }
+ ht.put(key, valArray);
+ }
+ return ht;
}
-
-
/**
*
* Parses data from an HTML form that the client sends to
*
*
*
- * @param len an integer specifying the length,
- * in characters, of the
- * <code>ServletInputStream</code>
- * object that is also passed to this
- * method
+ * @param len an integer specifying the length,
+ * in characters, of the
+ * <code>ServletInputStream</code>
+ * object that is also passed to this
+ * method
*
- * @param in the <code>ServletInputStream</code>
- * object that contains the data sent
- * from the client
+ * @param in the <code>ServletInputStream</code>
+ * object that contains the data sent
+ * from the client
*
- * @return a <code>HashTable</code> object built
- * from the parsed key-value pairs
+ * @return a <code>HashTable</code> object built
+ * from the parsed key-value pairs
*
*
- * @exception IllegalArgumentException if the data
- * sent by the POST method is invalid
+ * @exception IllegalArgumentException if the data
+ * sent by the POST method is invalid
*
*/
-
-
static public Hashtable<String,String[]> parsePostData(int len,
- ServletInputStream in)
- {
- // XXX
- // should a length of 0 be an IllegalArgumentException
-
- // cheap hack to return an empty hash
- if (len <=0)
- return new Hashtable<String,String[]>();
-
+ ServletInputStream in) {
+ // XXX
+ // should a length of 0 be an IllegalArgumentException
+
+ // cheap hack to return an empty hash
+ if (len <=0)
+ return new Hashtable<String,String[]>();
- if (in == null) {
- throw new IllegalArgumentException();
- }
-
- //
- // Make sure we read the entire POSTed body.
- //
+ if (in == null) {
+ throw new IllegalArgumentException();
+ }
+
+ // Make sure we read the entire POSTed body.
byte[] postedBytes = new byte [len];
try {
int offset = 0;
- do {
- int inputLen = in.read (postedBytes, offset, len - offset);
- if (inputLen <= 0) {
- String msg = lStrings.getString("err.io.short_read");
- throw new IllegalArgumentException (msg);
- }
- offset += inputLen;
- } while ((len - offset) > 0);
-
- } catch (IOException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
+ do {
+ int inputLen = in.read (postedBytes, offset, len - offset);
+ if (inputLen <= 0) {
+ String msg = lStrings.getString("err.io.short_read");
+ throw new IllegalArgumentException (msg);
+ }
+ offset += inputLen;
+ } while ((len - offset) > 0);
+
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
// XXX we shouldn't assume that the only kind of POST body
// is FORM data encoded using ASCII or ISO Latin/1 ... or
// that the body should always be treated as FORM data.
- //
-
try {
String postedBody = new String(postedBytes, 0, len, "8859_1");
return parseQueryString(postedBody);
}
-
-
/*
* Parse a name in the query string.
*/
-
static private String parseName(String s, StringBuffer sb) {
- sb.setLength(0);
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- switch (c) {
- case '+':
- sb.append(' ');
- break;
- case '%':
- try {
- sb.append((char) Integer.parseInt(s.substring(i+1, i+3),
- 16));
- i += 2;
- } catch (NumberFormatException e) {
- // XXX
- // need to be more specific about illegal arg
- throw new IllegalArgumentException();
- } catch (StringIndexOutOfBoundsException e) {
- String rest = s.substring(i);
- sb.append(rest);
- if (rest.length()==2)
- i++;
- }
-
- break;
- default:
- sb.append(c);
- break;
- }
- }
- return sb.toString();
+ sb.setLength(0);
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ switch (c) {
+ case '+':
+ sb.append(' ');
+ break;
+ case '%':
+ try {
+ sb.append((char) Integer.parseInt(s.substring(i+1, i+3),
+ 16));
+ i += 2;
+ } catch (NumberFormatException e) {
+ // XXX
+ // need to be more specific about illegal arg
+ throw new IllegalArgumentException();
+ } catch (StringIndexOutOfBoundsException e) {
+ String rest = s.substring(i);
+ sb.append(rest);
+ if (rest.length()==2)
+ i++;
+ }
+
+ break;
+ default:
+ sb.append(c);
+ break;
+ }
+ }
+ return sb.toString();
}
-
-
/**
*
* Reconstructs the URL the client used to make the request,
* <p>This method is useful for creating redirect messages
* and for reporting errors.
*
- * @param req a <code>HttpServletRequest</code> object
- * containing the client's request
+ * @param req a <code>HttpServletRequest</code> object
+ * containing the client's request
*
- * @return a <code>StringBuffer</code> object containing
- * the reconstructed URL
+ * @return a <code>StringBuffer</code> object containing
+ * the reconstructed URL
*
*/
-
public static StringBuffer getRequestURL (HttpServletRequest req) {
- StringBuffer url = new StringBuffer ();
- String scheme = req.getScheme ();
- int port = req.getServerPort ();
- String urlPath = req.getRequestURI();
-
- //String servletPath = req.getServletPath ();
- //String pathInfo = req.getPathInfo ();
+ StringBuffer url = new StringBuffer ();
+ String scheme = req.getScheme ();
+ int port = req.getServerPort ();
+ String urlPath = req.getRequestURI();
+
+ url.append (scheme); // http, https
+ url.append ("://");
+ url.append (req.getServerName ());
+ if ((scheme.equals ("http") && port != 80)
+ || (scheme.equals ("https") && port != 443)) {
+ url.append (':');
+ url.append (req.getServerPort ());
+ }
- url.append (scheme); // http, https
- url.append ("://");
- url.append (req.getServerName ());
- if ((scheme.equals ("http") && port != 80)
- || (scheme.equals ("https") && port != 443)) {
- url.append (':');
- url.append (req.getServerPort ());
- }
- //if (servletPath != null)
- // url.append (servletPath);
- //if (pathInfo != null)
- // url.append (pathInfo);
- url.append(urlPath);
- return url;
+ url.append(urlPath);
+ return url;
}
}
* typically implicit.)
*/
public JspContext() {
+ // NOOP by default
}
/**
* typically implicit.)
*/
public JspEngineInfo() {
+ // NOOP by default
}
/**
* Construct a JspException.
*/
public JspException() {
+ // NOOP
}
* typically implicit.)
*/
public JspFactory() {
+ // NOOP by default
}
/**
* typically implicit.)
*/
public PageContext() {
+ // NOOP by default
}
/**
*/
public void doInitBody() throws JspException {
+ // NOOP by default
}
* @since 2.0
*/
public interface JspTag {
+ // No methods even through there are some common methods
}
* typically implicit.)
*/
public PageData() {
+ // NOOP by default
}
/**
*
* @since 2.0
*/
-public class SimpleTagSupport
- implements SimpleTag
-{
+public class SimpleTagSupport implements SimpleTag {
/** Reference to the enclosing tag. */
private JspTag parentTag;
* typically implicit.)
*/
public SimpleTagSupport() {
+ // NOOP by default
}
/**
* an error writing to the output stream
* @see SimpleTag#doTag()
*/
- public void doTag()
- throws JspException, IOException
- {
+ public void doTag() throws JspException, IOException {
+ // NOOP by default
}
/**
* or is an instance of the class specified
*/
public static final JspTag findAncestorWithClass(
- JspTag from, Class<?> klass)
+ JspTag from, Class<?> klass)
{
- boolean isInterface = false;
+ boolean isInterface = false;
- if (from == null || klass == null
- || (!JspTag.class.isAssignableFrom(klass)
- && !(isInterface = klass.isInterface()))) {
- return null;
- }
+ if (from == null || klass == null
+ || (!JspTag.class.isAssignableFrom(klass)
+ && !(isInterface = klass.isInterface()))) {
+ return null;
+ }
- for (;;) {
- JspTag parent = null;
- if( from instanceof SimpleTag ) {
- parent = ((SimpleTag)from).getParent();
- }
- else if( from instanceof Tag ) {
- parent = ((Tag)from).getParent();
- }
- if (parent == null) {
- return null;
- }
+ for (;;) {
+ JspTag parent = null;
+ if( from instanceof SimpleTag ) {
+ parent = ((SimpleTag)from).getParent();
+ }
+ else if( from instanceof Tag ) {
+ parent = ((Tag)from).getParent();
+ }
+ if (parent == null) {
+ return null;
+ }
- if (parent instanceof TagAdapter) {
- parent = ((TagAdapter) parent).getAdaptee();
- }
+ if (parent instanceof TagAdapter) {
+ parent = ((TagAdapter) parent).getAdaptee();
+ }
- if ((isInterface && klass.isInstance(parent))
- || klass.isAssignableFrom(parent.getClass())) {
- return parent;
- }
+ if ((isInterface && klass.isInstance(parent))
+ || klass.isAssignableFrom(parent.getClass())) {
+ return parent;
+ }
- from = parent;
- }
+ from = parent;
+ }
}
}
* The current version of the specification only provides one formal
* way of indicating the observable type of a tag handler: its
* tag handler implementation class, described in the tag-class
- * subelement of the tag element. This is extended in an
+ * sub-element of the tag element. This is extended in an
* informal manner by allowing the tag library author to
- * indicate in the description subelement an observable type.
- * The type should be a subtype of the tag handler implementation
+ * indicate in the description sub-element an observable type.
+ * The type should be a sub-type of the tag handler implementation
* class or void.
- * This addititional constraint can be exploited by a
+ * This additional constraint can be exploited by a
* specialized container that knows about that specific tag library,
* as in the case of the JSP standard tag library.
*
* @param atts the static attribute and values. May be null.
*/
public TagData(Object[] atts[]) {
- if (atts == null) {
- attributes = new Hashtable<String, Object>();
- } else {
- attributes = new Hashtable<String, Object>(atts.length);
- }
-
- if (atts != null) {
- for (int i = 0; i < atts.length; i++) {
- attributes.put((String) atts[i][0], atts[i][1]);
- }
- }
+ if (atts == null) {
+ attributes = new Hashtable<String, Object>();
+ } else {
+ attributes = new Hashtable<String, Object>(atts.length);
+ }
+
+ if (atts != null) {
+ for (int i = 0; i < atts.length; i++) {
+ attributes.put((String) atts[i][0], atts[i][1]);
+ }
+ }
}
/**
*/
public String getId() {
- return getAttributeString(TagAttributeInfo.ID);
+ return getAttributeString(TagAttributeInfo.ID);
}
/**
*/
public Object getAttribute(String attName) {
- return attributes.get(attName);
+ return attributes.get(attName);
}
/**
* @param value the value.
*/
public void setAttribute(String attName,
- Object value) {
- attributes.put(attName, value);
+ Object value) {
+ attributes.put(attName, value);
}
/**
*/
public String getAttributeString(String attName) {
- Object o = attributes.get(attName);
- if (o == null) {
- return null;
- } else {
- return (String) o;
- }
+ Object o = attributes.get(attName);
+ if (o == null) {
+ return null;
+ }
+ return (String) o;
}
/**
// private data
- private Hashtable<String, Object> attributes; // the tagname/value map
+ private Hashtable<String, Object> attributes; // the tagname/value map
}
* typically implicit.)
*/
public TagExtraInfo() {
+ // NOOP by default
}
/**
* if no scripting variables are to be defined.
*/
public VariableInfo[] getVariableInfo(TagData data) {
- return ZERO_VARIABLE_INFO;
+ return ZERO_VARIABLE_INFO;
}
/**
*/
public boolean isValid(TagData data) {
- return true;
+ return true;
}
/**
* @since 2.0
*/
public ValidationMessage[] validate( TagData data ) {
- ValidationMessage[] result = null;
+ ValidationMessage[] result = null;
- if( !isValid( data ) ) {
- result = new ValidationMessage[] {
- new ValidationMessage( data.getId(), "isValid() == false" ) };
- }
+ if( !isValid( data ) ) {
+ result = new ValidationMessage[] {
+ new ValidationMessage( data.getId(), "isValid() == false" ) };
+ }
- return result;
+ return result;
}
/**
* @param tagInfo The TagInfo this instance is extending
*/
public final void setTagInfo(TagInfo tagInfo) {
- this.tagInfo = tagInfo;
+ this.tagInfo = tagInfo;
}
/**
* @return the taginfo instance this instance is extending
*/
public final TagInfo getTagInfo() {
- return tagInfo;
+ return tagInfo;
}
// private data
* typically implicit.)
*/
public TagLibraryValidator() {
+ // NOOP by default
}
/**
* @param map A Map describing the init parameters
*/
public void setInitParameters(Map<String, Object> map) {
- initParameters = map;
+ initParameters = map;
}
* @return The init parameters as an immutable map.
*/
public Map<String, Object> getInitParameters() {
- return initParameters;
+ return initParameters;
}
/**
* of ValidationMessages otherwise.
*/
public ValidationMessage[] validate(String prefix, String uri,
- PageData page)
- {
- return null;
+ PageData page) {
+ return null;
}
/**
* Release any data kept by this instance for validation purposes.
*/
public void release() {
- initParameters = null;
+ initParameters = null;
}
// Private data
* <p> Many tag handlers will extend TagSupport and only redefine a
* few methods.
*/
-
public class TagSupport implements IterationTag, Serializable {
/**
* @return the nearest ancestor that implements the interface
* or is an instance of the class specified
*/
-
public static final Tag findAncestorWithClass(Tag from, Class<?> klass) {
- boolean isInterface = false;
-
- if (from == null ||
- klass == null ||
- (!Tag.class.isAssignableFrom(klass) &&
- !(isInterface = klass.isInterface()))) {
- return null;
- }
-
- for (;;) {
- Tag tag = from.getParent();
-
- if (tag == null) {
- return null;
- }
-
- if ((isInterface && klass.isInstance(tag)) ||
- klass.isAssignableFrom(tag.getClass()))
- return tag;
- else
- from = tag;
- }
+ boolean isInterface = false;
+
+ if (from == null ||
+ klass == null ||
+ (!Tag.class.isAssignableFrom(klass) &&
+ !(isInterface = klass.isInterface()))) {
+ return null;
+ }
+
+ for (;;) {
+ Tag tag = from.getParent();
+
+ if (tag == null) {
+ return null;
+ }
+
+ if ((isInterface && klass.isInstance(tag)) ||
+ klass.isAssignableFrom(tag.getClass())) {
+ return tag;
+ }
+ from = tag;
+ }
}
/**
* This constructor is called by the code generated by the JSP
* translator.
*/
-
- public TagSupport() { }
+ public TagSupport() {
+ // NOOP by default
+ }
/**
* Default processing of the start tag, returning SKIP_BODY.
*
* @see Tag#doStartTag()
*/
-
public int doStartTag() throws JspException {
return SKIP_BODY;
}
*
* @see Tag#doEndTag()
*/
-
public int doEndTag() throws JspException {
- return EVAL_PAGE;
+ return EVAL_PAGE;
}
*
* @see IterationTag#doAfterBody()
*/
-
public int doAfterBody() throws JspException {
- return SKIP_BODY;
+ return SKIP_BODY;
}
// Actions related to body evaluation
*
* @see Tag#release()
*/
-
public void release() {
- parent = null;
- id = null;
- if( values != null ) {
- values.clear();
- }
- values = null;
+ parent = null;
+ id = null;
+ if( values != null ) {
+ values.clear();
+ }
+ values = null;
}
/**
* @param t The parent Tag.
* @see Tag#setParent(Tag)
*/
-
public void setParent(Tag t) {
- parent = t;
+ parent = t;
}
/**
*
* @return the parent tag instance or null
*/
-
public Tag getParent() {
- return parent;
+ return parent;
}
/**
*
* @param id The String for the id.
*/
-
public void setId(String id) {
- this.id = id;
+ this.id = id;
}
/**
*
* @return the value of the id attribute, or null
*/
-
public String getId() {
- return id;
+ return id;
}
/**
* @param pageContext The PageContext.
* @see Tag#setPageContext
*/
-
public void setPageContext(PageContext pageContext) {
- this.pageContext = pageContext;
+ this.pageContext = pageContext;
}
/**
* @param k The key String.
* @param o The value to associate.
*/
-
public void setValue(String k, Object o) {
- if (values == null) {
- values = new Hashtable<String, Object>();
- }
- values.put(k, o);
+ if (values == null) {
+ values = new Hashtable<String, Object>();
+ }
+ values.put(k, o);
}
/**
* @param k The string key.
* @return The value associated with the key, or null.
*/
-
public Object getValue(String k) {
- if (values == null) {
- return null;
- } else {
- return values.get(k);
- }
+ if (values == null) {
+ return null;
+ }
+ return values.get(k);
}
/**
*
* @param k The string key.
*/
-
public void removeValue(String k) {
- if (values != null) {
- values.remove(k);
- }
+ if (values != null) {
+ values.remove(k);
+ }
}
/**
* @return An enumeration of all the keys for the values set,
* or null or an empty Enumeration if no values have been set.
*/
-
public Enumeration<String> getValues() {
- if (values == null) {
- return null;
- }
- return values.keys();
+ if (values == null) {
+ return null;
+ }
+ return values.keys();
}
// private fields
/**
* The value of the id attribute of this tag; or null.
*/
- protected String id;
+ protected String id;
// protected fields