Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17170/core/src/xdoclet/tagshandler
Modified Files: MethodTagsHandler.java Log Message: fixed ifDoesntThrowException for methods without throws clause Index: MethodTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler/MethodTagsHandler.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** MethodTagsHandler.java 22 Feb 2005 23:57:28 -0000 1.33 --- MethodTagsHandler.java 9 Apr 2005 15:16:56 -0000 1.34 *************** *** 876,917 **** public void ifThrowsException(String template, Properties attributes) throws XDocletException { ! String checkExceptions = attributes.getProperty("exceptions"); ! String memberName = null; ! Collection exceptions = null; ! ! XExecutableMember executableMember = null; ! ! executableMember = getCurrentMethod(); ! memberName = attributes.getProperty("method"); ! ! if (executableMember == null && memberName == null) { ! exceptions = new ArrayList(); ! } ! ! if (memberName == null) { ! exceptions = executableMember.getThrownExceptions(); ! } ! else { ! executableMember = getXExecutableMemberForMemberName(memberName, true, FOR_METHOD); ! ! // no member with the specified name found in class ! if (executableMember != null) { ! exceptions = executableMember.getThrownExceptions(); ! } ! else { ! exceptions = new ArrayList(); ! } ! } ! ! String type = null; ! ! for (Iterator i = exceptions.iterator(); i.hasNext(); ) { ! type = ((XClass) i.next()).getQualifiedName(); ! ! if (checkExceptions != null) { ! if (checkExceptions.indexOf(type) != -1) { ! generate(template); ! } ! } } } --- 876,881 ---- public void ifThrowsException(String template, Properties attributes) throws XDocletException { ! if (throwsException(attributes)) { ! generate(template); } } *************** *** 933,936 **** --- 897,933 ---- public void ifDoesntThrowException(String template, Properties attributes) throws XDocletException { + if (!throwsException(attributes)) { + generate(template); + } + } + + private boolean isAbstract(Properties attributes) throws XDocletException + { + String methodName = attributes.getProperty("method"); + + if (methodName == null) { + return getCurrentMethod().isAbstract(); + } + else { + XMethod method = (XMethod) getXExecutableMemberForMemberName(methodName, true, FOR_METHOD); + + // no method with the specified name found in class + if (method == null) { + throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.METHOD_NOT_FOUND, new String[]{methodName})); + } + + return method.isAbstract(); + } + } + + /** + * Returns wheather the current method throws the exceptions specified in the <code>exceptions</code> attribute. + * + * @param attributes the attributes + * @return <code>true</code> if the current method throws the listed exceptions + * @exception XDocletException if a error occures + */ + private boolean throwsException(Properties attributes) throws XDocletException + { String checkExceptions = attributes.getProperty("exceptions"); String memberName = null; *************** *** 967,994 **** if (checkExceptions != null) { ! if (checkExceptions.indexOf(type) == -1) { ! generate(template); } } } ! } ! ! private boolean isAbstract(Properties attributes) throws XDocletException ! { ! String methodName = attributes.getProperty("method"); ! ! if (methodName == null) { ! return getCurrentMethod().isAbstract(); ! } ! else { ! XMethod method = (XMethod) getXExecutableMemberForMemberName(methodName, true, FOR_METHOD); ! ! // no method with the specified name found in class ! if (method == null) { ! throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.METHOD_NOT_FOUND, new String[]{methodName})); ! } ! ! return method.isAbstract(); ! } } --- 964,973 ---- if (checkExceptions != null) { ! if (checkExceptions.indexOf(type) != -1) { ! return true; } } } ! return false; } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel