001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Original Code is "CMPAttributeGenerator.java". Description: 010"Generates EJB code related to RIM class attributes, for an entity bean 011 with container managed persistence" 012 013The Initial Developer of the Original Code is University Health Network. Copyright (C) 0142001. All Rights Reserved. 015 016Contributor(s): ______________________________________. 017 018Alternatively, the contents of this file may be used under the terms of the 019GNU General Public License (the "GPL"), in which case the provisions of the GPL are 020applicable instead of those above. If you wish to allow use of your version of this 021file only under the terms of the GPL and not to allow others to use your version 022of this file under the MPL, indicate your decision by deleting the provisions above 023and replace them with the notice and other provisions required by the GPL License. 024If you do not delete the provisions above, a recipient may use your version of 025this file under either the MPL or the GPL. 026 027*/ 028 029package ca.uhn.hl7v3.sourcegen; 030 031/** 032 * Generates EJB code related to RIM class attributes, for an entity bean 033 * with container managed persistence. 034 * @author Bryan Tripp 035 * @deprecated 036 */ 037public class CMPAttributeGenerator { 038 039 /** Creates a new instance of AttributeGenerator */ 040 public CMPAttributeGenerator() { 041 } 042 043 /** 044 * Returns source code for the method signatures that represent the given 045 * attribute in the EJB remote interface. 046 */ 047 public String makeRemoteCode(AttributeDefinition att) { 048 StringBuffer code = new StringBuffer(); 049 code.append(SourceGenerator.makeJavaDocComment(att.getDescription(), 4)); 050 code.append(" "); 051 code.append(SourceGenerator.makeSetterSignature(att)); 052 code.append(" throws RemoteException; \r\n"); 053 code.append(" "); 054 code.append(SourceGenerator.makeGetterSignature(att)); 055 code.append(" throws RemoteException; \r\n"); 056 return code.toString(); 057 } 058 059 /** 060 * Returns source code for the methods that represent the given attribute 061 * in a CMP Entity EJB implementation. 062 */ 063 public String makeBeanCode(AttributeDefinition att) { 064 StringBuffer code = new StringBuffer(); 065 code.append(SourceGenerator.makeJavaDocComment(att.getDescription(), 4)); 066 067 code.append(" "); 068 code.append(SourceGenerator.makeSetterSignature(att)); 069 code.append(" { \r\n"); 070 code.append(" this."); 071 code.append(att.getName()); 072 code.append(" = "); 073 code.append(att.getName()); 074 code.append("; \r\n"); 075 code.append(" } \r\n"); 076 077 code.append(" "); 078 code.append(SourceGenerator.makeGetterSignature(att)); 079 code.append(" { \r\n"); 080 code.append(" return "); 081 code.append(att.getName()); 082 code.append("; \r\n"); 083 code.append(" } \r\n\r\n"); 084 085 return code.toString(); 086 } 087 088 /** Returns public attribute declaration associated with this attribute in CMP Entity Bean. */ 089 public String makeBeanAttribute(AttributeDefinition att) { 090 StringBuffer code = new StringBuffer(); 091 code.append(" public "); 092 code.append(att.getDataType()); 093 code.append(" "); 094 code.append(att.getName()); 095 code.append("; \r\n"); 096 return code.toString(); 097 } 098}