source code formatting.
[utils] / security / src / main / java / org / wamblee / security / authorization / DefaultOperationRegistry.java
index 472b2dacfe80d5b05c2fbc5f5f9bbc229af6091d..ad34465d139a4be3e59f61cece10b76d445d32e2 100644 (file)
 /*
  * Copyright 2005 the original author or authors.
- * 
+ *
  * Licensed 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.wamblee.security.authorization;
 
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.TreeMap;
 
+
 /**
- * Operation registry implementation. 
- * This implementation ignores the distinction between different types of resources
- * and simply assumes that every operation is applicable to every type of resource. 
+ * Operation registry implementation.  This implementation ignores the
+ * distinction between different types of resources and simply assumes that
+ * every operation is applicable to every type of resource.
  *
  * @author Erik Brakkee
  */
 public class DefaultOperationRegistry implements OperationRegistry {
+    /**
+     * DOCUMENT ME!
+     */
+    private Map<String, Operation> operations;
 
-    private Map<String,Operation> operations; 
-    
-    public DefaultOperationRegistry(Operation[] aOperations) { 
+/**
+     * Creates a new DefaultOperationRegistry object.
+     *
+     * @param aOperations DOCUMENT ME!
+     */
+    public DefaultOperationRegistry(Operation[] aOperations) {
         operations = new TreeMap<String, Operation>();
-        for (Operation operation: aOperations) { 
+
+        for (Operation operation : aOperations) {
             operations.put(operation.getName(), operation);
         }
     }
-    
+
     /* (non-Javadoc)
      * @see org.wamblee.security.authorization.OperationRegistry#getOperations(java.lang.Class)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aResourceClass DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Operation[] getOperations(Class aResourceClass) {
-        return operations.values().toArray(new Operation[0]); 
+        return operations.values().toArray(new Operation[0]);
     }
 
     /* (non-Javadoc)
      * @see org.wamblee.security.authorization.OperationRegistry#encode(org.wamblee.security.authorization.Operation[])
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aOperations DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public String encode(Operation[] aOperations) {
-        StringBuffer buffer = new StringBuffer(); 
-        for (Operation operation: aOperations) {
-            if ( buffer.length() > 0 ) { 
+        StringBuffer buffer = new StringBuffer();
+
+        for (Operation operation : aOperations) {
+            if (buffer.length() > 0) {
                 buffer.append(',');
             }
+
             buffer.append(operation.getName());
         }
+
         return buffer.toString();
     }
 
     /* (non-Javadoc)
      * @see org.wamblee.security.authorization.OperationRegistry#decode(java.lang.Class, java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aResourceClass DOCUMENT ME!
+     * @param aOperationsString DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Operation[] decode(Class aResourceClass, String aOperationsString) {
-        return decode(aOperationsString); 
+        return decode(aOperationsString);
     }
-    
+
     /* (non-Javadoc)
      * @see org.wamblee.security.authorization.OperationRegistry#decode(java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aOperationsString DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     *
+     * @throws IllegalArgumentException DOCUMENT ME!
+     */
     public Operation[] decode(String aOperationsString) {
-        if ( aOperationsString.length() == 0 ) { 
-            return new Operation[0]; 
+        if (aOperationsString.length() == 0) {
+            return new Operation[0];
         }
-        String[] names = aOperationsString.split(",");
-        ArrayList<Operation> result = new ArrayList<Operation>(); 
-        for (String name: names) { 
+
+        String[]             names  = aOperationsString.split(",");
+        ArrayList<Operation> result = new ArrayList<Operation>();
+
+        for (String name : names) {
             Operation operation = operations.get(name);
-            if ( operation == null ) { 
-                throw new IllegalArgumentException("Unknown operation '" + name + "'");
+
+            if (operation == null) {
+                throw new IllegalArgumentException("Unknown operation '" + name
+                    + "'");
             }
+
             result.add(operation);
         }
-        return result.toArray(new Operation[0]); 
-    }
 
+        return result.toArray(new Operation[0]);
+    }
 }