Author: bpoussin Date: 2010-12-08 16:31:51 +0100 (Wed, 08 Dec 2010) New Revision: 579 Url: http://nuiton.org/repositories/revision/wikitty/579 Log: try to fix conversion date, add some methods that have bad visibility in BeanUtil :( Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:23:46 UTC (rev 578) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-12-08 15:31:51 UTC (rev 579) @@ -1004,12 +1004,18 @@ /** * redefinition du DateConverter car par defaut il ne support pas la valeur - * null :( + * null :(. + * + * Ceci est un copier coller de DateConverter + AbstractConverter + * (et plus de copie/coller qu'il ne faut a cause de methode et de champs + * avec de mauvaise visibilite :() */ static private class WikittyDateConverter extends DateTimeConverter { /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(WikittyDateConverter.class); + private static final String PACKAGE = "org.apache.commons.beanutils.converters."; + /** * Construct a <b>java.util.Date</b> <i>Converter</i> that throws * a <code>ConversionException</code> if an error occurs. @@ -1065,7 +1071,7 @@ value = convertArray(value); // Fixed poussin 20101208 le bout de code original qui pose probleme - // pour la conversion null + // pour la conversion null. This is only modification // // Missing Value // if (value == null) { // return handleMissing(targetType); @@ -1131,6 +1137,39 @@ return type; } } + + /** + * Provide a String representation of a <code>java.lang.Class</code>. + * @param type The <code>java.lang.Class</code>. + * @return The String representation. + */ + String toString(Class type) { + String typeName = null; + if (type == null) { + typeName = "null"; + } else if (type.isArray()) { + Class elementType = type.getComponentType(); + int count = 1; + while (elementType.isArray()) { + elementType = elementType.getComponentType(); + count++; + } + typeName = elementType.getName(); + for (int i = 0; i < count; i++) { + typeName += "[]"; + } + } else { + typeName = type.getName(); + } + if (typeName.startsWith("java.lang.") + || typeName.startsWith("java.util.") + || typeName.startsWith("java.math.")) { + typeName = typeName.substring("java.lang.".length()); + } else if (typeName.startsWith(PACKAGE)) { + typeName = typeName.substring(PACKAGE.length()); + } + return typeName; + } } static public WikittyDateConverter dateConverter = new WikittyDateConverter();
participants (1)
-
bpoussin@users.nuiton.org