Author: tchemit Date: 2010-02-17 20:10:30 +0100 (Wed, 17 Feb 2010) New Revision: 1746 Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java Log: fix javadoc + clean contracts + improve AbstractBeanValidatorDetectorTest Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2010-02-17 14:49:35 UTC (rev 1745) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2010-02-17 19:10:30 UTC (rev 1746) @@ -30,20 +30,23 @@ /** * Init the ui just before been opened by the method - * {@link NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode)}. + * {@link NavigationTreeHandler#openUI(java.awt.Component, + * jaxx.runtime.swing.navigation.NavigationTreeNode)}. * * @param node the selected node associated to the ui - * @throws Exception - * @see NavigationTreeHandler#openUI(java.awt.Component, jaxx.runtime.swing.navigation.NavigationTreeNode) + * @throws Exception if any pb while opening the content's ui + * @see NavigationTreeHandler#openUI(java.awt.Component, + * jaxx.runtime.swing.navigation.NavigationTreeNode) */ void openUI(NavigationTreeNode node) throws Exception; /** - * Clean the ui after been closed by the method {@link NavigationTreeHandler#closeUI(java.awt.Component)}. + * Clean the ui after been closed by the method + * {@link NavigationTreeHandler#closeUI(java.awt.Component)}. * * @param node the selected node associated to the ui - * @throws Exception - * @see NavigationTreeHandler#closeUI(java.awt.Component) + * @throws Exception if any pb when closing the content'sui + * @see NavigationTreeHandler#closeUI(java.awt.Component) */ void closeUI(NavigationTreeNode node) throws Exception; } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-02-17 14:49:35 UTC (rev 1745) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-02-17 19:10:30 UTC (rev 1746) @@ -21,9 +21,7 @@ package jaxx.runtime.swing.navigation; import jaxx.runtime.JAXXContext; -import org.jdesktop.swingx.treetable.TreeTableNode; -import javax.swing.tree.TreeModel; import javax.swing.tree.TreeNode; import java.util.regex.Pattern; @@ -37,28 +35,31 @@ */ public interface NavigationModel { - public Object getRoot(); + Object getRoot(); - public TreeNode[] getPathToRoot(TreeNode aNode); + TreeNode[] getPathToRoot(TreeNode aNode); /** - * Search from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by dot. + * Search from the root node a node named by his fully path (concatenation + * of nodes {@link NavigationTreeNode#path} valued separated by dot. * <p/> * Example : * <p/> * <pre>$root.child1.leaf1</pre> * * @param path the fully path of the searched node. - * @return the node matching the fully context from the root node, or <code>null</code> if not find. + * @return the node matching the fully context from the root node, + * or <code>null</code> if not find. */ - public NavigationTreeNode findNode(String path); + NavigationTreeNode findNode(String path); /** - * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null. + * Apply first the regex pattern to obtain the searched node fi the given + * <code>regex</code> is not null. * <p/> - * Search then from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * Search then from the root node a node named by his fully path + * (concatenation of nodes {@link NavigationTreeNode#path} valued separated + * by {@link #getPathSeparator()}. * <p/> * <p/> * Example : @@ -67,15 +68,17 @@ * * @param path the fully path of the searched node. * @param regex a optional regex to apply to path before searching - * @return the node matching the fully context from the root node, or <code>null</code> if not found. + * @return the node matching the fully context from the root node, or + * <code>null</code> if not found. */ - public NavigationTreeNode findNode(String path, String regex); + NavigationTreeNode findNode(String path, String regex); /** * Apply first the regex pattern to obtain the searched node. * <p/> - * Search then from the root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * Search then from the root node a node named by his fully path + * (concatenation of nodes {@link NavigationTreeNode#path} valued separated + * by {@link #getPathSeparator()}. * <p/> * Example : * <p/> @@ -83,55 +86,65 @@ * * @param path the fully path of the searched node. * @param regex a optional regex to apply to path before searching - * @return the node matching the fully context from the root node, or <code>null</code> if not found. + * @return the node matching the fully context from the root node, or + * <code>null</code> if not found. */ - public NavigationTreeNode findNode(String path, Pattern regex); + NavigationTreeNode findNode(String path, Pattern regex); /** - * Search from a given root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * Search from a given root node a node named by his fully path + * (concatenation of nodes {@link NavigationTreeNode#path} valued separated + * by {@link #getPathSeparator()}. * * @param root root node to be used * @param path the fully path of the searched node. - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + * @return the node matching the fully context from the given root node, or + * <code>null</code> if not found. */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path); + NavigationTreeNode findNode(NavigationTreeNode root, String path); /** * Apply first the regex pattern to obtain the searched node. * <p/> - * Search then from a given root node a node named by his fully path (concatenation of nodes) - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * Search then from a given root node a node named by his fully path + * (concatenation of nodes) {@link NavigationTreeNode#path} valued + * separated by {@link #getPathSeparator()}. * * @param root root node to be used * @param path the fully path of the searched node. * @param regex a previous regex to apply to path : must have a matches - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + * @return the node matching the fully context from the given root node, + * or <code>null</code> if not found. */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex); + NavigationTreeNode findNode(NavigationTreeNode root, String path, + String regex); /** * Apply first the regex pattern to obtain the searched node. * <p/> - * Search then from a given root node a node named by his fully path (concatenation of nodes - * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}. + * Search then from a given root node a node named by his fully path + * (concatenation of nodes {@link NavigationTreeNode#path} valued separated + * by {@link #getPathSeparator()}. * * @param root root node to be used * @param path the fully path of the searched node. * @param regex a previous regex to apply to path : must have a matches - * @return the node matching the fully context from the given root node, or <code>null</code> if not found. + * @return the node matching the fully context from the given root node, + * or <code>null</code> if not found. */ - public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex); + NavigationTreeNode findNode(NavigationTreeNode root, String path, + Pattern regex); - public JAXXContext getContext(); + JAXXContext getContext(); /** - * Obtain the associated bean value from context corresponding to node from given navigation path. + * Obtain the associated bean value from context corresponding to node + * from given navigation path. * * @param navigationPath the current context path of the node * @return the value associated in context with the given navigation path */ - public Object getBean(String navigationPath); + Object getBean(String navigationPath); /** * Obtain the associated bean value from context corresponding to node @@ -139,13 +152,13 @@ * @param node the current node * @return the value associated in context with the given node. */ - public Object getBean(NavigationTreeNode node); + Object getBean(NavigationTreeNode node); - public void nodeChanged(TreeNode node); + void nodeChanged(TreeNode node); - public void nodeStructureChanged(TreeNode node); + void nodeStructureChanged(TreeNode node); - public void nodeChanged(TreeNode node, boolean deep); + void nodeChanged(TreeNode node, boolean deep); - public String getPathSeparator(); + String getPathSeparator(); } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java 2010-02-17 14:49:35 UTC (rev 1745) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java 2010-02-17 19:10:30 UTC (rev 1746) @@ -21,75 +21,80 @@ package jaxx.runtime.swing.navigation; import jaxx.runtime.JAXXAction; -import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXObject; import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.decorator.Decorator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import java.util.Enumeration; - /** - * Interface to create a builder, this object is design to build a {@link NavigationModel}. + * Interface to create a builder, this object is design to build a + * {@link NavigationModel}. * * @author sletellier * @since 2.0.0 */ public interface NavigationModelBuilder { - public NavigationModel getModel(); + NavigationModel getModel(); - public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName); + NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, + String contextName); - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - JAXXContextEntryDef<?> entryDef, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + String libelle, + JAXXContextEntryDef<?> entryDef, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - JAXXContextEntryDef<?> entryDef, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + String libelle, + JAXXContextEntryDef<?> entryDef, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + String libelle, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - JAXXContextEntryDef<?> entryDef, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + Decorator<?> decorator, + JAXXContextEntryDef<?> entryDef, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - JAXXContextEntryDef<?> entryDef, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + Decorator<?> decorator, + JAXXContextEntryDef<?> entryDef, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, - String entryPath, - String contextName, - Class<? extends JAXXObject> uiClass, - Class<? extends JAXXAction> actionClass); + NavigationTreeNode build(NavigationTreeNode parentNode, + Decorator<?> decorator, + String entryPath, + String contextName, + Class<? extends JAXXObject> uiClass, + Class<? extends JAXXAction> actionClass); - public NavigationTreeNode removeChildNode(NavigationTreeNode node); + NavigationTreeNode removeChildNode(NavigationTreeNode node); - public void addI18nNodeRenderer(NavigationTreeNode node, String libelle); + void addI18nNodeRenderer(NavigationTreeNode node, + String libelle); - public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator); + void addDecoratorNodeRenderer(NavigationTreeNode node, + Decorator<?> decorator); - public void addNodeJaxxClasses( + void addNodeJaxxClasses( NavigationTreeNode node, Class<? extends JAXXObject> uIClass, Class<? extends JAXXAction> uIHandlerClass); - public void printModel(NavigationTreeNode node); + void printModel(NavigationTreeNode node); } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2010-02-17 14:49:35 UTC (rev 1745) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2010-02-17 19:10:30 UTC (rev 1746) @@ -65,7 +65,7 @@ } /** - * @see {NavigationModel#getRoot()} + * @see NavigationModel#getRoot() */ @Override public NavigationTreeNode getRoot() { @@ -73,42 +73,42 @@ } /** - * @see {NavigationModel#findNode(String)} + * @see NavigationModel#findNode(String) */ public NavigationTreeNode findNode(String path) { return findNode(getRoot(), path, (Pattern) null); } /** - * @see {NavigationModel#findNode(String, String)} + * @see NavigationModel#findNode(String, String) */ public NavigationTreeNode findNode(String path, String regex) { return findNode(getRoot(), path, regex); } /** - * @see {NavigationModel#findNode(String, Pattern)} + * @see NavigationModel#findNode(String, Pattern) */ public NavigationTreeNode findNode(String path, Pattern regex) { return findNode(getRoot(), path, regex); } /** - * @see {NavigationModel#findNode(NavigationTreeNode, String)} + * @see NavigationModel#findNode(NavigationTreeNode, String) */ public NavigationTreeNode findNode(NavigationTreeNode root, String path) { return findNode(root, path, (Pattern) null); } /** - * @see {NavigationModel#findNode(NavigationTreeNode, String, String)} + * @see NavigationModel#findNode(NavigationTreeNode, String, String) */ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) { return findNode(root, path, regex == null ? null : Pattern.compile(regex)); } /** - * @see {NavigationModel#findNode(NavigationTreeNode, String, Pattern)} + * @see NavigationModel#findNode(NavigationTreeNode, String, Pattern) */ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) { if (regex != null) { @@ -138,14 +138,14 @@ } /** - * @see {NavigationModel#getContext()} + * @see NavigationModel#getContext() */ public JAXXContext getContext() { return context; } /** - * @see {NavigationModel#getBean(String)} + * @see NavigationModel#getBean(String) */ public Object getBean(String navigationPath) { Object result; @@ -155,7 +155,7 @@ } /** - * @see {NavigationModel#getBean(NavigationTreeNode)} + * @see NavigationModel#getBean(NavigationTreeNode) */ public Object getBean(NavigationTreeNode node) { if (node == null) { @@ -167,7 +167,7 @@ } /** - * @see {NavigationModel#nodeChanged(TreeNode)} + * @see NavigationModel#nodeChanged(TreeNode) */ @Override public void nodeChanged(TreeNode node) { @@ -178,7 +178,7 @@ } /** - * @see {NavigationModel#nodeStructureChanged(TreeNode)} + * @see NavigationModel#nodeStructureChanged(TreeNode) */ @Override public void nodeStructureChanged(TreeNode node) { @@ -192,7 +192,7 @@ } /** - * @see {NavigationModel#nodeChanged(TreeNode, boolean)} + * @see NavigationModel#nodeChanged(TreeNode, boolean) */ public void nodeChanged(TreeNode node, boolean deep) { @@ -222,7 +222,7 @@ } /** - * @see {NavigationModel#getPathSeparator()} + * @see NavigationModel#getPathSeparator() */ public String getPathSeparator() { return pathSeparator; Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java =================================================================== --- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java 2010-02-17 14:49:35 UTC (rev 1745) +++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/AbstractBeanValidatorDetectorTest.java 2010-02-17 19:10:30 UTC (rev 1746) @@ -23,8 +23,10 @@ import java.io.File; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.SortedSet; import java.util.regex.Pattern; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; @@ -34,35 +36,41 @@ /** * An abstract test to detects validators for a given list of objets types and - * + * <p/> * a given sourceroot directory where to find validations definitions. - * + * <p/> * You just have to implements to {@link #assertDetect(SortedSet)} which contains * the set of validators detected. - * + * <p/> * See {@link BeanValidatorDetectorTest} for an example. - * + * <p/> * Note : An implementation of this test should be produced in evry projects which * defines some validation definitions just to test they are syntax valid. - * + * * @author chemit * @since 1.6.0 */ public abstract class AbstractBeanValidatorDetectorTest { - /** to use log facility, just put in your code: log.info(\"...\"); */ - private static final Log log = LogFactory.getLog(AbstractBeanValidatorDetectorTest.class); + /** Logger */ + private static final Log log = + LogFactory.getLog(AbstractBeanValidatorDetectorTest.class); protected static File basedir; protected BeanValidatorDetector instance; protected Class<?>[] classes; protected Class<?> validatorClass; protected File sourceRoot; - protected AbstractBeanValidatorDetectorTest(File sourceRoot, Class<?>... classes) { + protected AbstractBeanValidatorDetectorTest( + File sourceRoot, + Class<?>... classes) { this(BeanValidator.class, sourceRoot, classes); } - protected AbstractBeanValidatorDetectorTest(Class<?> validatorClass, File sourceRoot, Class<?>... classes) { + protected AbstractBeanValidatorDetectorTest( + Class<?> validatorClass, + File sourceRoot, + Class<?>... classes) { this.sourceRoot = sourceRoot; this.classes = classes; this.validatorClass = validatorClass; @@ -72,7 +80,9 @@ log.info("classes " + Arrays.toString(classes)); } - protected AbstractBeanValidatorDetectorTest(File sourceRoot, Collection<Class<?>> classes) { + protected AbstractBeanValidatorDetectorTest( + File sourceRoot, + Collection<Class<?>> classes) { this(sourceRoot, classes.toArray(new Class<?>[classes.size()])); } @@ -105,23 +115,67 @@ assertDetect(result); } - protected abstract void assertDetect(SortedSet<BeanValidator<?>> validators); + protected abstract void assertDetect( + SortedSet<BeanValidator<?>> validators); - protected SortedSet<BeanValidator<?>> detect(File sourceRoot, Class<?>[] classes, Pattern contextPattern) { - SortedSet<BeanValidator<?>> result = instance.detect(validatorClass, sourceRoot, contextPattern, classes); + protected SortedSet<BeanValidator<?>> detect( + File sourceRoot, + Class<?>[] classes, + Pattern contextPattern) { + + SortedSet<BeanValidator<?>> result = instance.detect( + validatorClass, + sourceRoot, + contextPattern, + classes); return result; } - protected void assertValidator(Class<?> expectedBeanClass, String expectedContextName, BeanValidator<?> validator) { + protected static void assertValidator( + Class<?> expectedBeanClass, + String expectedContextName, + BeanValidator<?> validator) { assertEquals(expectedBeanClass, validator.getBeanClass()); assertEquals(expectedContextName, validator.getContextName()); } - protected String printValidators(String prefix, SortedSet<BeanValidator<?>> result) { - StringBuilder buffer = new StringBuilder(); - buffer.append(prefix).append(result.size()).append("\n"); + protected static void assertValidatorSetWithSameContextName( + SortedSet<BeanValidator<?>> validators, + String contextName, + Class<?>... expectedClasses) { + + assertEquals(expectedClasses.length, validators.size()); + Iterator<BeanValidator<?>> itrV = validators.iterator(); + + for (Class<?> expectedClass : expectedClasses) { + assertValidator(expectedClass, contextName, itrV.next()); + } + } + + protected static void assertValidatorSetWithMultiContextName( + SortedSet<BeanValidator<?>> validators, + Object... expecteds) { + + assertEquals(expecteds.length % 2, 0); + assertEquals(expecteds.length / 2, validators.size()); + Iterator<BeanValidator<?>> itrV = validators.iterator(); + + for (int i = 0; i < expecteds.length / 2; i++) { + String contextName = (String) expecteds[2 * i]; + Class<?> expectedClass = (Class<?>) expecteds[2 * i + 1]; + assertValidator(expectedClass, contextName, itrV.next()); + } + + } + + protected static String printValidators( + String prefix, + SortedSet<BeanValidator<?>> result) { + StringBuilder buffer; + buffer = new StringBuilder(result.size() * (prefix.length() + 50)); + buffer.append(prefix).append(result.size()).append('\n'); for (BeanValidator<?> v : result) { - buffer.append(prefix).append(v).append("\n"); + buffer.append(prefix).append(v).append('\n'); } return buffer.toString(); }
participants (1)
-
tchemit@users.nuiton.org