KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > annotation > impl > HandlerProcessingResultImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment.annotation.impl;
24
25 import java.util.Map JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.lang.annotation.Annotation JavaDoc;
28
29 import com.sun.enterprise.deployment.annotation.ResultType;
30 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult;
31 import com.sun.enterprise.deployment.annotation.AnnotationHandler;
32
33 /**
34  *
35  * @author dochez
36  */

37 public class HandlerProcessingResultImpl implements HandlerProcessingResult {
38     
39     Map JavaDoc<Class JavaDoc<? extends Annotation JavaDoc>,ResultType> results;
40     ResultType overallResult = ResultType.UNPROCESSED;
41     
42     /**
43      * Creates a new instance of HandlerProcessingResultImpl
44      */

45     public HandlerProcessingResultImpl(Map JavaDoc<Class JavaDoc<? extends Annotation JavaDoc>, ResultType> results) {
46         this.results = results;
47     }
48     
49     public HandlerProcessingResultImpl() {
50         results = new HashMap JavaDoc<Class JavaDoc<? extends Annotation JavaDoc>, ResultType>();
51     }
52     
53     public static HandlerProcessingResultImpl getDefaultResult(Class JavaDoc<? extends Annotation JavaDoc> annotationType, ResultType result) {
54         
55         HandlerProcessingResultImpl impl = new HandlerProcessingResultImpl();
56         impl.results.put(annotationType, result);
57         impl.overallResult = result;
58         return impl;
59     }
60     
61     public Map JavaDoc<Class JavaDoc<? extends Annotation JavaDoc>,ResultType> processedAnnotations() {
62         return results;
63     }
64     
65     public void addResult(Class JavaDoc<? extends Annotation JavaDoc> annotationType, ResultType result) {
66         if (result.compareTo(overallResult)>0) {
67             overallResult = result;
68         }
69         results.put(annotationType, result);
70     }
71     
72     public void addAll(HandlerProcessingResult result) {
73          if (result.getOverallResult().compareTo(overallResult)>0) {
74             overallResult = result.getOverallResult();
75         }
76         results.putAll(result.processedAnnotations());
77     }
78     
79     public ResultType getOverallResult(){
80         return overallResult;
81     }
82   
83 }
84
Popular Tags