TILESSB-38
Fixed tiles-request-api Checkstyle of main code.
git-svn-id: https://svn.apache.org/repos/asf/tiles/sandbox/trunk/tiles-request@1064782 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
index aa0de04..442984b 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractClientRequest.java
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request;
import java.io.IOException;
@@ -6,10 +26,24 @@
import org.apache.tiles.request.scope.ContextResolver;
import org.apache.tiles.request.util.ApplicationAccess;
+/**
+ * Base class for "client" requests, i.e. requests that come unchanged by the
+ * container, such as ServletRequest and PortletRequest.
+ *
+ * @version $Rev$ $Date$
+ */
public abstract class AbstractClientRequest extends AbstractRequest {
+ /**
+ * The application context.
+ */
private ApplicationContext applicationContext;
+ /**
+ * Constructor.
+ *
+ * @param applicationContext The application context.
+ */
public AbstractClientRequest(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@@ -48,12 +82,29 @@
return resolver.getAvailableScopes(this);
}
+ /**
+ * Returns the application scope.
+ *
+ * @return The application scope.
+ */
public Map<String, Object> getApplicationScope() {
return applicationContext.getApplicationScope();
}
+ /**
+ * Forwards to a path.
+ *
+ * @param path The path to forward to.
+ * @throws IOException If something goes wrong when forwarding.
+ */
protected abstract void doForward(String path) throws IOException;
+ /**
+ * Includes the result of a path.
+ *
+ * @param path The path to forward to.
+ * @throws IOException If something goes wrong when forwarding.
+ */
protected abstract void doInclude(String path) throws IOException;
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractRequest.java b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractRequest.java
index af1d712..89fbcd7 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractRequest.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractRequest.java
@@ -1,18 +1,56 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request;
-public abstract class AbstractRequest implements Request{
+/**
+ * Base request.
+ *
+ * @version $Rev$ $Date: 2010-11-14 21:32:50 +0100 (dom, 14 nov 2010)$
+ */
+public abstract class AbstractRequest implements Request {
+
/**
* Name of the attribute used to store the force-include option.
+ *
* @since 2.0.6
*/
- public static final String FORCE_INCLUDE_ATTRIBUTE_NAME =
- "org.apache.tiles.servlet.context.ServletTilesRequestContext.FORCE_INCLUDE";
+ public static final String FORCE_INCLUDE_ATTRIBUTE_NAME = AbstractRequest.class
+ .getName() + ".FORCE_INCLUDE";
-
+ /**
+ * Sets the flag to force inclusion at next dispatch.
+ *
+ * @param forceInclude <code>true</code> means that, at the next dispatch, response
+ * will be included and never forwarded.
+ */
protected void setForceInclude(boolean forceInclude) {
getContext("request").put(FORCE_INCLUDE_ATTRIBUTE_NAME, forceInclude);
}
+ /**
+ * Checks if, when dispatching to a resource, the result must be included
+ * and not forwarded to.
+ *
+ * @return <code>true</code> if inclusion is forced.
+ */
protected boolean isForceInclude() {
Boolean forceInclude = (Boolean) getContext("request").get(
FORCE_INCLUDE_ATTRIBUTE_NAME);
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractViewRequest.java b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractViewRequest.java
index 72bda17..7a1afaf 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractViewRequest.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/AbstractViewRequest.java
@@ -1,11 +1,43 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request;
import java.io.IOException;
import org.apache.tiles.request.util.RequestWrapper;
+/**
+ * Base class for "view" requests, i.e. requests created into view technologies,
+ * such as JSP, Velocity and Freemarker. In particular, all calls to
+ * {@link #dispatch(String)} will cause an inclusion and never a forward.
+ *
+ * @version $Rev$ $Date$
+ */
public class AbstractViewRequest extends RequestWrapper {
+ /**
+ * Constructor.
+ *
+ * @param request The base request.
+ */
public AbstractViewRequest(Request request) {
super(request);
}
@@ -22,6 +54,12 @@
doInclude(path);
}
+ /**
+ * Includes the result. By default, uses the wrapped request for the inclusion.
+ *
+ * @param path The path whose result will be included.
+ * @throws IOException If something goes wrong.
+ */
protected void doInclude(String path) throws IOException {
getWrappedRequest().include(path);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java b/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
index aa446d9..dbfd2d5 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/Request.java
@@ -53,10 +53,29 @@
*/
Map<String, String[]> getHeaderValues();
+ /**
+ * Returns a context map, given the scope name.
+ *
+ * @param scope The name of the scope.
+ * @return The context.
+ */
Map<String, Object> getContext(String scope);
+ /**
+ * Returns the native scopes, i.e. scopes that are native to the
+ * implementation of the request itself (request, session and application
+ * for example).
+ *
+ * @return The native scopes.
+ */
String[] getNativeScopes();
+ /**
+ * Returns all available scopes, that are the ones returned by
+ * {@link #getNativeScopes()} plus derivative scopes (e.g. flash scope).
+ *
+ * @return All the available scopes.
+ */
String[] getAvailableScopes();
/**
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/RequestException.java b/tiles-request-api/src/main/java/org/apache/tiles/request/RequestException.java
index d88f2d6..430937e 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/RequestException.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/RequestException.java
@@ -1,18 +1,62 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request;
+/**
+ * Thrown when something related to a request fails.
+ *
+ * @version $Rev$ $Date$
+ */
public class RequestException extends RuntimeException {
+ /**
+ * Constructor.
+ */
public RequestException() {
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ */
public RequestException(String message) {
super(message);
}
+ /**
+ * Constructor.
+ *
+ * @param cause The cause.
+ */
public RequestException(Throwable cause) {
super(cause);
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ * @param cause The cause.
+ */
public RequestException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/AttributeExtractor.java b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/AttributeExtractor.java
index 4af3425..5c313ac 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/AttributeExtractor.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/AttributeExtractor.java
@@ -1,4 +1,29 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.attribute;
+/**
+ * Allows to get, put and remove Object-type attributes.
+ *
+ * @version $Rev$ $Date$
+ */
public interface AttributeExtractor extends HasRemovableKeys<Object>, HasAddableKeys<Object> {
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/EnumeratedValuesExtractor.java b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/EnumeratedValuesExtractor.java
index de98812..88ae480 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/EnumeratedValuesExtractor.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/EnumeratedValuesExtractor.java
@@ -1,8 +1,39 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.attribute;
import java.util.Enumeration;
+/**
+ * Allows to get values from multi-valued attributes.
+ *
+ * @version $Rev$ $Date$
+ */
public interface EnumeratedValuesExtractor extends HasAddableKeys<String> {
+ /**
+ * Returns the values stored at the given key.
+ *
+ * @param key The key of the attribute.
+ * @return The values of the attribute.
+ */
Enumeration<String> getValues(String key);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasAddableKeys.java b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasAddableKeys.java
index 628eec0..16dfcab 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasAddableKeys.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasAddableKeys.java
@@ -1,5 +1,38 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.attribute;
+/**
+ * Allows to get and set attributes.
+ *
+ * @version $Rev$ $Date$
+ * @param <V> The type of the value of the attribute.
+ */
public interface HasAddableKeys<V> extends HasKeys<V> {
+
+ /**
+ * Sets a value for the given key.
+ *
+ * @param key The key of the attribute.
+ * @param value The value of the attribute.
+ */
void setValue(String key, V value);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasKeys.java b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasKeys.java
index 75766e1..32ea92c 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasKeys.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasKeys.java
@@ -1,10 +1,47 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.attribute;
import java.util.Enumeration;
+/**
+ * Allows to get attributes.
+ *
+ * @version $Rev$ $Date$
+ * @param <V> The type of the value of the attribute.
+ */
public interface HasKeys<V> {
+ /**
+ * The enumeration of the keys of the stored attributes.
+ *
+ * @return The keys.
+ */
Enumeration<String> getKeys();
+ /**
+ * Returns the value of the attribute with the given key.
+ *
+ * @param key The key of the attribute.
+ * @return The value.
+ */
V getValue(String key);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasRemovableKeys.java b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasRemovableKeys.java
index 124777b..160737f 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasRemovableKeys.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/attribute/HasRemovableKeys.java
@@ -1,5 +1,37 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.attribute;
+/**
+ * Allows to get and remove attributes.
+ *
+ * @version $Rev$ $Date$
+ * @param <V> The type of the value of the attribute.
+ */
public interface HasRemovableKeys<V> extends HasKeys<V> {
- void removeValue(String name);
+
+ /**
+ * Removes an attribute.
+ *
+ * @param key The key of the attribute to remove.
+ */
+ void removeValue(String key);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
index 8ffc18c..c6813fa 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/AddableParameterMap.java
@@ -27,22 +27,21 @@
import org.apache.tiles.request.attribute.HasAddableKeys;
/**
- * <p>Private implementation of <code>Map</code> for servlet request
- * name-value.</p>
+ * Exposes an {@link HasAddableKeys} object as a put/get (no remove) map.
*
* @version $Rev$ $Date$
*/
-
public class AddableParameterMap extends ReadOnlyEnumerationMap<String> {
+ /**
+ * The request.
+ */
private HasAddableKeys<String> request;
/**
* Constructor.
*
* @param request The request object to use.
- * @param response The response object to use.
- * @since 2.2.0
*/
public AddableParameterMap(HasAddableKeys<String> request) {
super(request);
@@ -71,6 +70,9 @@
}
+ /**
+ * Entry set implementation for {@link AddableParameterMap}.
+ */
private class AddableParameterEntrySet extends ReadOnlyEnumerationMap<String>.ReadOnlyEnumerationMapEntrySet {
@Override
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/HeaderValuesMap.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/HeaderValuesMap.java
index 595bf60..3241d39 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/HeaderValuesMap.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/HeaderValuesMap.java
@@ -35,14 +35,15 @@
/**
- * <p>Private implementation of <code>Map</code> for servlet request
- * name-values[].</p>
+ * Exposes an {@link EnumeratedValuesExtractor} object as a read-only map.
*
* @version $Rev$ $Date$
*/
-
public class HeaderValuesMap implements Map<String, String[]> {
+ /**
+ * The request.
+ */
private EnumeratedValuesExtractor request;
/**
@@ -172,6 +173,12 @@
return new HeaderValuesCollection();
}
+ /**
+ * Extracts values enumeration of an attribute and returns the corresponding array of values.
+ *
+ * @param key The key of the attribute.
+ * @return The values of the attribute.
+ */
private String[] getHeaderValues(String key) {
List<String> list = new ArrayList<String>();
Enumeration<String> values = request.getValues(key);
@@ -196,6 +203,12 @@
return retValue;
}
+ /**
+ * Transforms a string array in a string set.
+ *
+ * @param valueArray The array to convert.
+ * @return The corresponding set.
+ */
private Set<String> array2set(String[] valueArray) {
Set<String> values = new HashSet<String>();
for (int i = 0; i < valueArray.length; i++) {
@@ -204,6 +217,15 @@
return values;
}
+ /**
+ * Checks if values of a header attribute are the same as the one passed in
+ * the set.
+ *
+ * @param name The name of the header.
+ * @param testSet The set of values it must contain.
+ * @return <code>true</code> if all the values, and only them, are present
+ * in the header values.
+ */
private boolean compareHeaders(String name, Set<String> testSet) {
Enumeration<String> values = request.getValues(name);
boolean matched = true;
@@ -215,6 +237,9 @@
return matched;
}
+ /**
+ * Entry set implementation for {@link HeaderValuesMap}.
+ */
private class HeadersEntrySet implements Set<Map.Entry<String, String[]>> {
@Override
@@ -292,6 +317,12 @@
return toList().toArray(a);
}
+ /**
+ * Checks whether the given entry is present in the headers.
+ *
+ * @param entry The entry to check.
+ * @return <code></code> if the key and the values of the entry are present.
+ */
private boolean containsEntry(Map.Entry<String, String[]> entry) {
Enumeration<String> entryValues = request.getValues(key(entry.getKey()));
String[] valueArray = entry.getValue();
@@ -304,8 +335,13 @@
return values.isEmpty();
}
+ /**
+ * Turns this entry set into a list.
+ *
+ * @return The collection, turned into a list.
+ */
private List<Map.Entry<String, String[]>> toList() {
- List<Map.Entry<String, String[]>> entries = new ArrayList<Map.Entry<String,String[]>>();
+ List<Map.Entry<String, String[]>> entries = new ArrayList<Map.Entry<String, String[]>>();
Enumeration<String> names = request.getKeys();
while (names.hasMoreElements()) {
entries.add(extractNextEntry(names));
@@ -313,14 +349,26 @@
return entries;
}
+ /**
+ * Returns the next entry, by getting the next element in the given enumeration.
+ *
+ * @param names The enumeration to get the next name from..
+ * @return The next map entry.
+ */
private MapEntry<String, String[]> extractNextEntry(
Enumeration<String> names) {
String name = names.nextElement();
return new MapEntryArrayValues<String, String>(name, getHeaderValues(name), false);
}
+ /**
+ * Iterates {@link HeadersEntrySet} elements.
+ */
private class HeadersEntrySetIterator implements Iterator<Map.Entry<String, String[]>> {
+ /**
+ * The enumeration to use.
+ */
private Enumeration<String> namesEnumeration = request.getKeys();
@Override
@@ -341,6 +389,10 @@
}
}
+ /**
+ * It is a collection of all values of the header. Each element is an array
+ * of values of a single header.
+ */
private class HeaderValuesCollection implements Collection<String[]> {
@Override
@@ -415,6 +467,11 @@
return toList().toArray(a);
}
+ /**
+ * Turns this collection into a list.
+ *
+ * @return The list.
+ */
private List<String[]> toList() {
List<String[]> entries = new ArrayList<String[]>();
Enumeration<String> names = request.getKeys();
@@ -439,8 +496,14 @@
return list1.toArray(new String[list1.size()]);
}
+ /**
+ * Iterates elements of {@link HeaderValuesCollection}.
+ */
private class HeaderValuesCollectionIterator implements Iterator<String[]> {
+ /**
+ * The enumeration of the name of header attributes.
+ */
private Enumeration<String> namesEnumeration = request.getKeys();
@Override
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/IteratorEnumeration.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/IteratorEnumeration.java
index 257f0b6..53cd324 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/IteratorEnumeration.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/IteratorEnumeration.java
@@ -74,7 +74,12 @@
public E nextElement() {
return iterator.next();
}
-
+
+ /**
+ * Returns the original iterator.
+ *
+ * @return The enumerated iterator.
+ */
public Iterator<E> getIterator() {
return iterator;
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/KeySet.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/KeySet.java
index 7493617..e305d12 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/KeySet.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/KeySet.java
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.collection;
import static org.apache.tiles.request.util.RequestUtil.*;
@@ -11,10 +31,23 @@
import org.apache.tiles.request.attribute.HasKeys;
+/**
+ * Exposes keys of a {@link HasKeys} object as a set.
+ *
+ * @version $Rev$ $Date$
+ */
public class KeySet implements Set<String> {
+ /**
+ * The request to read.
+ */
private HasKeys<?> request;
+ /**
+ * Constructor.
+ *
+ * @param request The request to read.
+ */
public KeySet(HasKeys<?> request) {
this.request = request;
}
@@ -58,7 +91,7 @@
@Override
public Iterator<String> iterator() {
- return new ServletHeaderKeySetIterator();
+ return new KeySetIterator();
}
@Override
@@ -91,6 +124,11 @@
return toList().toArray(a);
}
+ /**
+ * Turns this set into a list.
+ *
+ * @return The corresponding list.
+ */
private List<String> toList() {
List<String> entries = new ArrayList<String>();
Enumeration<String> names = request.getKeys();
@@ -100,8 +138,14 @@
return entries;
}
- private class ServletHeaderKeySetIterator implements Iterator<String> {
+ /**
+ * Iterates elements of {@link KeySet}.
+ */
+ private class KeySetIterator implements Iterator<String> {
+ /**
+ * The key names enumeration.
+ */
private Enumeration<String> namesEnumeration = request.getKeys();
@Override
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/MapEntryArrayValues.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/MapEntryArrayValues.java
index fd4ea8c..4184f81 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/MapEntryArrayValues.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/MapEntryArrayValues.java
@@ -25,8 +25,7 @@
/**
- * <p>Map.Entry implementation that can be constructed to either be read-only
- * or not.</p>
+ * Multi-valued map entry.
*
* @version $Rev$ $Date$
* @param <K> The key type.
@@ -35,6 +34,13 @@
public class MapEntryArrayValues<K, V> extends MapEntry<K, V[]> {
+ /**
+ * Constructor.
+ *
+ * @param key The key of the entry.
+ * @param value The array of values.
+ * @param modifiable If <code>true</code> the entry is modifiable.
+ */
public MapEntryArrayValues(K key, V[] value, boolean modifiable) {
super(key, value, modifiable);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ReadOnlyEnumerationMap.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ReadOnlyEnumerationMap.java
index 0a20089..eb26b1c 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ReadOnlyEnumerationMap.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ReadOnlyEnumerationMap.java
@@ -34,21 +34,22 @@
import org.apache.tiles.request.attribute.HasKeys;
/**
- * <p>Private implementation of <code>Map</code> for servlet request
- * name-value.</p>
+ * Wraps an {@link HasKeys} object into a read-only map.
*
* @version $Rev$ $Date$
+ * @param <V> The type of the values.
*/
-
public class ReadOnlyEnumerationMap<V> implements Map<String, V> {
+ /**
+ * The request.
+ */
protected HasKeys<V> request;
/**
* Constructor.
*
* @param request The request object to use.
- * @param response The response object to use.
* @since 2.2.0
*/
public ReadOnlyEnumerationMap(HasKeys<V> request) {
@@ -71,7 +72,7 @@
@SuppressWarnings("unchecked")
public boolean containsValue(Object value) {
V realValue = (V) value;
- for (Enumeration<String> keysIt = request.getKeys(); keysIt.hasMoreElements(); ) {
+ for (Enumeration<String> keysIt = request.getKeys(); keysIt.hasMoreElements();) {
if (realValue.equals(request.getValue(keysIt.nextElement()))) {
return true;
}
@@ -170,6 +171,9 @@
return retValue;
}
+ /**
+ * Entry set implementation for {@link ReadOnlyEnumerationMap}.
+ */
class ReadOnlyEnumerationMapEntrySet implements Set<Map.Entry<String, V>> {
@Override
@@ -247,13 +251,24 @@
return toList().toArray(a);
}
+ /**
+ * Checks whether the entry is present.
+ *
+ * @param entry The entry to check.
+ * @return <code>true</code> if the entry is present.
+ */
protected boolean containsEntry(Map.Entry<String, V> entry) {
V storedValue = request.getValue(key(entry.getKey()));
return storedValue != null && storedValue.equals(entry.getValue());
}
+ /**
+ * Turns this set into a list.
+ *
+ * @return The list.
+ */
private List<Map.Entry<String, V>> toList() {
- List<Map.Entry<String, V>> entries = new ArrayList<Map.Entry<String,V>>();
+ List<Map.Entry<String, V>> entries = new ArrayList<Map.Entry<String, V>>();
Enumeration<String> names = request.getKeys();
while (names.hasMoreElements()) {
entries.add(extractNextEntry(names));
@@ -261,6 +276,12 @@
return entries;
}
+ /**
+ * Returns the next entry, given the enumeration.
+ *
+ * @param names The enumeration to get the next key from.
+ * @return The next entry.
+ */
private MapEntry<String, V> extractNextEntry(
Enumeration<String> names) {
String name = names.nextElement();
@@ -268,8 +289,14 @@
false);
}
+ /**
+ * Iterates entries of {@link ReadOnlyEnumerationMap}.
+ */
private class ReadOnlyEnumerationMapEntrySetIterator implements Iterator<Map.Entry<String, V>> {
+ /**
+ * Enumerates keys.
+ */
private Enumeration<String> namesEnumeration = request.getKeys();
@Override
@@ -290,6 +317,9 @@
}
}
+ /**
+ * Values collection for {@link ReadOnlyEnumerationMap}.
+ */
private class ReadOnlyEnumerationMapValuesCollection implements Collection<V> {
@Override
@@ -317,7 +347,7 @@
public boolean containsAll(Collection<?> c) {
Collection<String> realCollection = (Collection<String>) c;
List<String> valueList = new ArrayList<String>(realCollection);
- for (Enumeration<String> keysEnum = request.getKeys(); keysEnum.hasMoreElements(); ) {
+ for (Enumeration<String> keysEnum = request.getKeys(); keysEnum.hasMoreElements();) {
valueList.remove(request.getValue(keysEnum.nextElement()));
if (valueList.isEmpty()) {
return true;
@@ -366,6 +396,11 @@
return toList().toArray(a);
}
+ /**
+ * Turns this collection into a list.
+ *
+ * @return The list.
+ */
private List<V> toList() {
List<V> entries = new ArrayList<V>();
Enumeration<String> names = request.getKeys();
@@ -375,9 +410,14 @@
return entries;
}
-
+ /**
+ * Iterates values of {@link ReadOnlyEnumerationMap}.
+ */
private class ReadOnlyEnumerationMapValuesCollectionIterator implements Iterator<V> {
+ /**
+ * Enumerates attribute keys.
+ */
private Enumeration<String> namesEnumeration = request.getKeys();
@Override
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/RemovableKeySet.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/RemovableKeySet.java
index 44b8ca8..e9197c6 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/RemovableKeySet.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/RemovableKeySet.java
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.collection;
import static org.apache.tiles.request.util.RequestUtil.*;
@@ -9,10 +29,23 @@
import org.apache.tiles.request.attribute.HasRemovableKeys;
+/**
+ * Wraps {@link HasRemovableKeys} keys as a set.
+ *
+ * @version $Rev$ $Date$
+ */
public class RemovableKeySet extends KeySet {
+ /**
+ * The request.
+ */
private HasRemovableKeys<?> request;
+ /**
+ * Constructor.
+ *
+ * @param request The request.
+ */
public RemovableKeySet(HasRemovableKeys<?> request) {
super(request);
this.request = request;
@@ -46,7 +79,7 @@
Collection<String> realCollection = (Collection<String>) c;
boolean retValue = false;
Set<String> keysToRemove = new LinkedHashSet<String>();
- for (Enumeration<String> keys = request.getKeys(); keys.hasMoreElements(); ) {
+ for (Enumeration<String> keys = request.getKeys(); keys.hasMoreElements();) {
String key = keys.nextElement();
if (!realCollection.contains(key)) {
retValue = true;
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ScopeMap.java b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ScopeMap.java
index 8a1897b..6a2cdf7 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ScopeMap.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/collection/ScopeMap.java
@@ -32,14 +32,16 @@
import org.apache.tiles.request.attribute.AttributeExtractor;
/**
- * <p>Private implementation of <code>Map</code> for servlet context
- * attributes.</p>
+ * Exposes a scope context as a <String, Object> map.
*
* @version $Rev$ $Date$
*/
public class ScopeMap extends ReadOnlyEnumerationMap<Object> {
+ /**
+ * The context to read.
+ */
private AttributeExtractor context;
/**
@@ -96,6 +98,9 @@
return (previous);
}
+ /**
+ * Entry set implementation for {@link ScopeMap}.
+ */
private class ScopeEntrySet extends ReadOnlyEnumerationMap<Object>.ReadOnlyEnumerationMapEntrySet {
@Override
@@ -155,7 +160,7 @@
Collection<Map.Entry<String, Object>> realCollection = (Collection<java.util.Map.Entry<String, Object>>) c;
boolean retValue = false;
Set<String> keysToRemove = new LinkedHashSet<String>();
- for (Enumeration<String> keys = context.getKeys(); keys.hasMoreElements(); ) {
+ for (Enumeration<String> keys = context.getKeys(); keys.hasMoreElements();) {
String key = keys.nextElement();
Object value = context.getValue(key);
Map.Entry<String, Object> entry = new MapEntry<String, Object>(key, value, false);
@@ -164,7 +169,7 @@
keysToRemove.add(key);
}
}
- for (String key: keysToRemove) {
+ for (String key : keysToRemove) {
context.removeValue(key);
}
return retValue;
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package-info.java b/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package-info.java
index 80dd92d..1ea2fcc 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package-info.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package-info.java
@@ -19,6 +19,6 @@
* under the License.
*/
/**
- * Reflection utilities to get attributes.
+ * Classes to manage reflection in a centralized way for Tiles.
*/
package org.apache.tiles.request.reflect;
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package.html b/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package.html
deleted file mode 100644
index dfb17d9..0000000
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/reflect/package.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
--->
-<html>
-<head>
- <title>Tiles reflection utilities</title>
-</head>
-<body>
-Classes to manage reflection in a centralized way for Tiles.
-</body>
-</html>
\ No newline at end of file
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/render/RenderException.java b/tiles-request-api/src/main/java/org/apache/tiles/request/render/RenderException.java
index 60fecda..37fcee7 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/render/RenderException.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/render/RenderException.java
@@ -1,20 +1,64 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.render;
import org.apache.tiles.request.RequestException;
+/**
+ * Thrown when rendering fails.
+ *
+ * @version $Rev$ $Date$
+ */
public class RenderException extends RequestException {
+ /**
+ * Constructor.
+ */
public RenderException() {
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ */
public RenderException(String message) {
super(message);
}
+ /**
+ * Constructor.
+ *
+ * @param cause The cause.
+ */
public RenderException(Throwable cause) {
super(cause);
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ * @param cause The cause.
+ */
public RenderException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/render/Renderer.java b/tiles-request-api/src/main/java/org/apache/tiles/request/render/Renderer.java
index fd2fafe..0109d98 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/render/Renderer.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/render/Renderer.java
@@ -38,7 +38,6 @@
* @param path The path to render.
* @param request The Tiles request context.
* @throws IOException If something goes wrong during rendition.
- * @throws RendererException If something goes wrong during rendition.
*/
void render(String path, Request request) throws IOException;
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ContextResolver.java b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ContextResolver.java
index b20cdb5..3005fe2 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ContextResolver.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ContextResolver.java
@@ -1,12 +1,50 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.scope;
import java.util.Map;
import org.apache.tiles.request.Request;
+/**
+ * Allows to retrieve scopes managed into a request.
+ *
+ * @version $Rev$ $Date$
+ */
public interface ContextResolver {
- public Map<String, Object> getContext(Request request, String scope);
+ /**
+ * Returns a scope map (context) given the request and the scope name.
+ *
+ * @param request The request.
+ * @param scope The name of the scope.
+ * @return The context, if present.
+ */
+ Map<String, Object> getContext(Request request, String scope);
- public String[] getAvailableScopes(Request request);
+ /**
+ * Returns the name of all available scopes.
+ *
+ * @param request The request.
+ * @return All the available scopes.
+ */
+ String[] getAvailableScopes(Request request);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/NoSuchScopeException.java b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/NoSuchScopeException.java
index 3aeeb1b..e6eaf07 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/NoSuchScopeException.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/NoSuchScopeException.java
@@ -1,20 +1,64 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.scope;
import org.apache.tiles.request.RequestException;
+/**
+ * Thrown when a scope cannot be found.
+ *
+ * @version $Rev$ $Date$
+ */
public class NoSuchScopeException extends RequestException {
+ /**
+ * Constructor.
+ */
public NoSuchScopeException() {
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ */
public NoSuchScopeException(String message) {
super(message);
}
+ /**
+ * Constructor.
+ *
+ * @param cause The cause.
+ */
public NoSuchScopeException(Throwable cause) {
super(cause);
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ * @param cause The cause.
+ */
public NoSuchScopeException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
index 1b6d369..cb7db68 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.scope;
import java.lang.reflect.InvocationTargetException;
@@ -10,9 +30,20 @@
import org.apache.tiles.request.Request;
import org.apache.tiles.request.util.RequestWrapper;
+/**
+ * Resolves scopes and contexts by using reflection.
+ * To expose a scope, add a <code>get<name_of_the_scope>Scope</code> without parameters
+ * that returns a <code>Map<String, Object></code>.
+ *
+ * @version $Rev$ $Date$
+ */
public class ReflectionContextResolver implements ContextResolver {
- private Map<Class<? extends Request>, Set<String>> class2scopes = new HashMap<Class<? extends Request>, Set<String>>();
+ /**
+ * Maps a request class to all available scopes.
+ */
+ private Map<Class<? extends Request>, Set<String>> class2scopes =
+ new HashMap<Class<? extends Request>, Set<String>>();
@SuppressWarnings("unchecked")
@Override
@@ -60,13 +91,20 @@
return scopes.toArray(retValue);
}
+ /**
+ * Returns the scopes for a single class. To be used in an iteration to get the scopes
+ * of all the hierarchy of the request.
+ *
+ * @param request The request to analyze.
+ * @return The scope set.
+ */
private Set<String> getSpecificScopeSet(Request request) {
Set<String> scopes = class2scopes.get(request.getClass());
if (scopes == null) {
scopes = new LinkedHashSet<String>();
String[] nativeScopes = request.getNativeScopes();
if (nativeScopes != null) {
- for (String scopeName: nativeScopes) {
+ for (String scopeName : nativeScopes) {
scopes.add(scopeName);
}
}
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/util/ApplicationAccess.java b/tiles-request-api/src/main/java/org/apache/tiles/request/util/ApplicationAccess.java
index f8de72e..777d108 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/util/ApplicationAccess.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/util/ApplicationAccess.java
@@ -1,30 +1,83 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.util;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.scope.ContextResolver;
+/**
+ * Entry point to get information about the application.
+ *
+ * @version $Rev$ $Date$
+ */
public final class ApplicationAccess {
+ /**
+ * The attribute name that will be used to store the application context itself.
+ */
public static final String APPLICATION_CONTEXT_ATTRIBUTE =
ApplicationContext.class.getName() + ".ATTRIBUTE";
+ /**
+ * The attribute name containing the context resolver.
+ */
public static final String CONTEXT_RESOLVER_ATTRIBUTE =
ContextResolver.class.getName() + ".ATTRIBUTE";
+ /**
+ * Constructor.
+ */
private ApplicationAccess() {
}
+ /**
+ * Registers an application context. It will be registered into itself as an
+ * attribute, using the {@link #APPLICATION_CONTEXT_ATTRIBUTE} name.
+ *
+ * @param applicationContext The application context to register.
+ */
public static void register(ApplicationContext applicationContext) {
applicationContext.getApplicationScope().put(
APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
}
+ /**
+ * Registers a context resolver. It will be registered into application context as an
+ * attribute, using the {@link #CONTEXT_RESOLVER_ATTRIBUTE} name.
+ *
+ * @param contextResolver The context resolver to register.
+ * @param applicationContext The application context to register.
+ */
public static void registerContextResolver(ContextResolver contextResolver,
ApplicationContext applicationContext) {
applicationContext.getApplicationScope().put(
CONTEXT_RESOLVER_ATTRIBUTE, contextResolver);
}
+ /**
+ * Returns the context resolver.
+ *
+ * @param applicationContext The application context.
+ * @return The context resolver.
+ */
public static ContextResolver getContextResolver(
ApplicationContext applicationContext) {
return (ContextResolver) applicationContext.getApplicationScope().get(
diff --git a/tiles-request-api/src/main/java/org/apache/tiles/request/util/RequestUtil.java b/tiles-request-api/src/main/java/org/apache/tiles/request/util/RequestUtil.java
index d5040cc..fab981d 100644
--- a/tiles-request-api/src/main/java/org/apache/tiles/request/util/RequestUtil.java
+++ b/tiles-request-api/src/main/java/org/apache/tiles/request/util/RequestUtil.java
@@ -1,9 +1,37 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.tiles.request.util;
import java.util.Enumeration;
-public class RequestUtil {
+/**
+ * Utilities for requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class RequestUtil {
+ /**
+ * Constructor.
+ */
private RequestUtil() {
}
@@ -25,6 +53,12 @@
}
}
+ /**
+ * Returns the number of elements in an enumeration, by iterating it.
+ *
+ * @param keys The enumeration.
+ * @return The number of elements.
+ */
public static int enumerationSize(Enumeration<?> keys) {
int n = 0;
while (keys.hasMoreElements()) {