1 5 package xdoclet.modules.ejb.entity; 6 7 import java.text.MessageFormat ; 8 import java.util.Collection ; 9 import java.util.Iterator ; 10 11 import xjavadoc.*; 12 import xdoclet.DocletContext; 13 import xdoclet.DocletSupport; 14 15 import xdoclet.DocletTask; 16 import xdoclet.XDocletException; 17 import xdoclet.XDocletTagSupport; 18 import xdoclet.modules.ejb.EjbTagsHandler; 19 import xdoclet.modules.ejb.entity.EntityBmpSubTask; 20 21 import xdoclet.util.TypeConversionUtil; 22 23 29 public class BmpTagsHandler extends EntityTagsHandler 30 { 31 32 39 public static String getEntityBmpClassFor(XClass clazz) throws XDocletException 40 { 41 String fileName = clazz.getContainingPackage().getName(); 42 String entity_name = MessageFormat.format(getEntityBmpClassPattern(), new Object []{EjbTagsHandler.getShortEjbNameFor(clazz)}); 43 44 fileName = choosePackage(fileName, null, DocletTask.getSubTaskName(EntityBmpSubTask.class)); 46 if (fileName.length() > 0) { 47 fileName += "."; 48 } 49 50 fileName += entity_name; 51 52 return fileName; 53 } 54 55 56 64 public static boolean isEntityBmp(XClass clazz) throws XDocletException 65 { 66 if (isEntity(clazz) == false) { 67 return false; 68 } 69 70 XTag beanTag = clazz.getDoc().getTag("ejb:bean"); 71 72 if (beanTag == null) { 74 return false; 75 } 76 77 String value = beanTag.getAttributeValue("type"); 78 79 if (value == null) { 81 return false; 82 } 83 84 if (value.equals("BMP")) { 85 return true; 86 } 87 else { 88 return false; 89 } 90 } 91 92 93 99 public static boolean useSoftLocking(XClass clazz) 100 { 101 String soft_locking_str = clazz.getDoc().getTagAttributeValue("ejb:bean", "use-soft-locking", false); 102 boolean soft_locking = TypeConversionUtil.stringToBoolean(soft_locking_str, false); 103 104 return soft_locking; 105 } 106 107 108 113 protected static String getEntityBmpClassPattern() 114 { 115 EntityBmpSubTask entitybmp_subtask = ((EntityBmpSubTask) DocletContext.getInstance().getSubTaskBy(DocletTask.getSubTaskName(EntityBmpSubTask.class))); 116 117 if (entitybmp_subtask != null) { 118 return entitybmp_subtask.getEntityBmpClassPattern(); 119 } 120 else { 121 return EntityBmpSubTask.DEFAULT_ENTITYBMP_CLASS_PATTERN; 122 } 123 } 124 125 132 public String entityBmpClass() throws XDocletException 133 { 134 return getEntityBmpClassFor(XDocletTagSupport.getCurrentClass()); 135 } 136 137 138 145 public void ifEntityIsBmp(String template) throws XDocletException 146 { 147 if (isEntityBmp(XDocletTagSupport.getCurrentClass())) { 148 generate(template); 149 } 150 } 151 152 153 161 public void forAllBmpEntityBeans(String template) throws XDocletException 162 { 163 Collection classes = getXJavaDoc().getSourceClasses(); 164 165 for (Iterator i = classes.iterator(); i.hasNext(); ) { 166 XClass clazz = (XClass) i.next(); 167 168 XDocletTagSupport.setCurrentClass(clazz); 169 170 if (DocletSupport.isDocletGenerated(XDocletTagSupport.getCurrentClass())) { 171 continue; 172 } 173 174 if (!hasHavingClassTag(getCurrentClass())) { 175 continue; 176 } 177 178 if (isEntityBmp(XDocletTagSupport.getCurrentClass())) { 179 generate(template); 180 } 181 } 182 } 183 184 185 193 public void ifUseSoftLocking(String template) throws XDocletException 194 { 195 if (useSoftLocking(XDocletTagSupport.getCurrentClass())) { 196 generate(template); 197 } 198 } 199 } 200 | Popular Tags |