KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > persistence > action > GenerationOptions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.persistence.action;
21
22 /**
23  * This class represents code generation options for invoking
24  * <code>javax.persistence.EntityManager</code> .
25  *
26  * @author Erno Mononen
27  */

28 public final class GenerationOptions {
29     
30     public enum Operation {
31         PERSIST("em.persist({0});"),
32         MERGE("em.merge({0});"),
33         REMOVE("em.merge({0});\n" + "em.remove({0});"),
34         FIND("return ({2}) em.find({2}.class, {0});"),
35         FIND_ALL("return em.createQuery(\"select object(o) from {2} as o\").getResultList();");
36     
37         private String JavaDoc body;
38         
39         private Operation(String JavaDoc body){
40             this.body = body;
41         }
42         
43         public String JavaDoc getBody(){
44             return body;
45         }
46     }
47     
48     private Operation operation;
49     private String JavaDoc methodName;
50     private String JavaDoc returnType;
51     private String JavaDoc parameterName;
52     private String JavaDoc parameterType;
53     private String JavaDoc queryAttribute;
54     
55     /** Creates a new instance of GenerationOptions */
56     public GenerationOptions() {
57     }
58     
59     public String JavaDoc getMethodName() {
60         return methodName;
61     }
62     
63     public Operation getOperation() {
64         return operation;
65     }
66
67     public String JavaDoc getParameterName() {
68         return parameterName;
69     }
70
71     public String JavaDoc getParameterType() {
72         return parameterType;
73     }
74
75     public void setParameterName(String JavaDoc parameterName) {
76         this.parameterName = parameterName;
77     }
78
79     public void setParameterType(String JavaDoc parameterType) {
80         this.parameterType = parameterType;
81     }
82
83     public String JavaDoc getQueryAttribute() {
84         return queryAttribute;
85     }
86     
87     public String JavaDoc getReturnType() {
88         return returnType;
89     }
90     
91     public void setMethodName(String JavaDoc methodName) {
92         this.methodName = methodName;
93     }
94     
95     public void setOperation(Operation operation) {
96         this.operation = operation;
97     }
98
99     
100     public void setQueryAttribute(String JavaDoc queryAttribute) {
101         this.queryAttribute = queryAttribute;
102     }
103     
104     public void setReturnType(String JavaDoc returnType) {
105         this.returnType = returnType;
106     }
107  
108 }
109
Popular Tags