Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
December 2012
- 3 participants
- 12 discussions
r2447 - in trunk: . nuiton-utils/src/main/java/org/nuiton/util nuiton-utils/src/test/java/org/nuiton/util nuiton-validator/src/main/java/org/nuiton/validator/xwork2
by tchemit@users.nuiton.org 13 Dec '12
by tchemit@users.nuiton.org 13 Dec '12
13 Dec '12
Author: tchemit
Date: 2012-12-13 14:25:06 +0100 (Thu, 13 Dec 2012)
New Revision: 2447
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2447
Log:
fixes #2477: Updates mavenpom to 3.4.6
fixes #2476: Remove some deprecated api
fixes #2455: Update to struts 2.3.7
Removed:
trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/PagerUtil.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/FileCompletionTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/PagerUtilTest.java
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java
trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2ValidatorUtil.java
trunk/pom.xml
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,62 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-/* *
-* ExceptionUtil.java
-*
-* Created: Thu Aug 29 2002
-*
-* @author <poussin(a)codelutin.com>
-* Copyright Code Lutin
-* @version $Revision$
-*
-* Mise a jour: $Date$
-* par : $Author$
-*/
-
-package org.nuiton.util;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-/** @deprecated since 2.5, will be removed and not replaced in version 2.6 */
-@Deprecated
-public class ExceptionUtil { // ExceptionUtil
-
- protected ExceptionUtil() {
-
- }
-
- /** @deprecated since 2.5, prefeur use {@link ExceptionUtils#getStackTrace(Throwable)} */
- @Deprecated
- public static String stackTrace(Throwable eee) {
- StringWriter result = new StringWriter();
- eee.printStackTrace(new PrintWriter(result));
- return result.toString();
- }
-
-} // ExceptionUtil
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,270 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.util;
-
-import org.nuiton.i18n.I18n;
-
-import java.io.Console;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.Locale;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * <p>
- * Class d'aide a la saisie de chemin de fichier
- * </p>
- * <p>
- * Integration :
- * </p>
- * <pre>
- * (le 1er argument definit si l'on peut creer un fichier (ex : pour enregistrer))
- * (le 2eme definit si la sorti est possible sans saisir un fichier)
- * FileCompletion fc = new FileCompletion(true,true);
- * if (fc.consoleAvailable())
- * System.out.print(fc.read());
- * </pre>
- * <p>
- * Utilisation :
- * </p>
- * <p>
- * ".." pour annuler ou pour revenir au repertoire précédent
- * </p>
- * <p>
- * Entrer pour afficher la liste des fichiers, ou pour compléter le chemin
- * </p>
- * <p>
- * Entrer pour afficher la liste des fichiers, ou pour compléter le chemin
- * </p>
- * Saisir "!s" a la fin du nom de fichier pour l'enregistrer (si l'option est active)
- * <p>
- * </p>
- * Saisir "!q" pour quitter et renvoyer null (si l'option est active)
- * <p>
- * Limitation :
- * </p>
- * <p>
- * FIXME: Si l'enregistrement est active, enregistrer un fichier finissant par "!s" est impossible
- * </p>
- * <p>
- * FIXME: Ouvrir un fichier finissant par ".." l'est égualement
- * </p>
- * <p>
- * FIXME: Si la sortie est ecive, un fichier "!q" ne peut pas etre utilise
- * </p>
- *
- * @author Letellier Sylvain
- * @deprecated since 2.6.12, is this very useful at the end ? don't thing so :(
- */
-@Deprecated
-public class FileCompletion {
- private boolean exit;
-
- private boolean creation;
-
- private boolean consoleAvailable;
-
- private Console console;
-
- /**
- * Constructeur
- *
- * @param creation TODO
- * @param exit TODO
- */
- public FileCompletion(boolean creation, boolean exit) {
- this.exit = exit;
- this.creation = creation;
-
- I18n.setDefaultLocale(Locale.getDefault());
-
- // TODO does this util class init i18n ?
-// if (Locale.getDefault().getLanguage().equals("fr")) {
-// I18n.init("fr", "FR");
-// }
-// else {
-// I18n.init("en", "US");
-// }
-
- console = System.console();
- consoleAvailable = (console != null);
- }
-
- /**
- * demande a l'utilisateur de saisir un chemin
- *
- * @return TODO
- * @throws IOException TODO
- */
- public String read() throws IOException {
- if (creation) {
- System.out.println(_("nuitonutil.fileCompletion.save"));
- }
- if (exit) {
- System.out.println(_("nuitonutil.fileCompletion.exit"));
- }
- System.out.println(_("nuitonutil.fileCompletion.cancel"));
- System.out.println(_("nuitonutil.fileCompletion.enter"));
- String line = System.getProperty("user.dir");
- File f;
- line = line + readLine("> " + line + File.separator);
- f = new File(line);
- String moreLastLine = line;
- boolean isDirectory = true;
- do {
- if (f.isDirectory() || !f.exists()) {
- String lastLine = line;
- if (!f.exists() && !f.isDirectory()) {
- File fTmp = f.getParentFile();
- String file = f.getName();
- if (file.matches("^.*\\!s$") && creation)
- return f.getCanonicalPath().substring(0,
- f.getCanonicalPath().length() - 2);
- if (file.matches("^.*\\!q$") && exit)
- return null;
- if (file.matches("^.*\\.\\.$"))
- line = fTmp.getCanonicalPath();
- else {
- Filter filtre = new Filter();
- filtre.setFilter(file);
- String[] listFichier = fTmp.list(filtre);
- if (listFichier.length == 1) {
- if (!(fTmp.getParentFile() == null)) {
- line = fTmp.getCanonicalPath() + File.separator
- + listFichier[0];
- } else {
- line = fTmp.getCanonicalPath() + listFichier[0];
- }
- } else if (listFichier.length > 1) {
- afficherListe(listFichier);
- } else {
- line = moreLastLine;
- }
-
- }
- } else if (f.exists() && f.isDirectory()
- && !(f.getParentFile() == null)) {
- Filter filtre = new Filter();
- filtre.setFilter(f.getName());
- String[] listFichier = f.getParentFile().list(filtre);
- if (listFichier.length <= 1
- || line.charAt(line.length() - 1) == File.separatorChar) {
-
- line = f.getCanonicalPath();
- isDirectory = true;
- } else if (listFichier.length > 1) {
- isDirectory = false;
- afficherListe(listFichier);
- }
-
- }
- moreLastLine = line;
- f = new File(line);
- if (f.isDirectory() && isDirectory
- && !(line.charAt(line.length() - 1) == File.separatorChar))
- line = line + File.separator;
- String read = readLine("> " + line);
- line = line + read;
- f = new File(line);
- if (read.equals("") || read.equals(File.separator))
- afficherListe(f.list());
-
- if (line.matches(".* " + File.separator + ".*")
- || line.matches(".*" + File.separator + " .*"))
- line = lastLine;
- f = new File(line);
- }
- } while (!f.exists() || f.isDirectory());
- return line;
- }
-
- /** Filtre les fichiers a afficher */
- class Filter implements FilenameFilter {
- private String filtre;
-
- /**
- * @param dir TODO
- * @param name TODO
- * @return boolean
- */
- public boolean accept(File dir, String name) {
- return name.startsWith(filtre);
- }
-
- /**
- * le parametre est le debut des noms de fichiers a afficher
- *
- * @param s TODO
- */
- public void setFilter(String s) {
- filtre = s;
- }
- }
-
- /**
- * @param path TODO
- * @return String
- */
- private String readLine(String path) {
- String lineNonNull = null;
- while (lineNonNull == null)
- lineNonNull = console.readLine(path);
- return lineNonNull;
- }
-
- /** @return boolean */
- public boolean consoleAvailable() {
- return consoleAvailable;
- }
-
- /** @param listefichiers TODO */
- private void afficherListe(String[] listefichiers) {
- if (listefichiers != null) {
- int i = 0;
- int nomMax = 0;
- for (String l : listefichiers)
- nomMax = Math.max(nomMax, l.length());
- // System.out.println();
- for (String l : listefichiers) {
- String space = "";
- int nbSpace = (nomMax + 1) - l.length();
- for (int j = 0; j < nbSpace; j++) {
- space += " ";
- }
- if (i++ < 2)
- System.out.print(l + space);
- else {
- i = 0;
- System.out.println(l);
- }
- }
- System.out.println();
- }
- }
-}
-
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -762,48 +762,5 @@
|| clazz == Double.class;
}
- /**
- * Retourne la classe du type primitf associé avec la classe de de l'objet
- * passé en parametre. Par exemple si la classe passée en paramètre est
- * Integer alors le resultat sera la classe de int.
- *
- * @param clazz la classe dont on souhaite le type primitf
- * @return le type primitif associé a la classe en paramètre, ou null s'il
- * n'y a pas de type primitif associé.
- * @see com.google.common.primitives.Primitives
- * @deprecated since 2.6 there is other libraty which does it
- */
- @Deprecated
- public static Class<?> getPrimitiveClass(Class<?> clazz) {
- if (clazz == Boolean.class) {
- return Boolean.TYPE;
- }
- if (clazz == Byte.class) {
- return Byte.TYPE;
- }
- if (clazz == Character.class) {
- return Character.TYPE;
- }
- if (clazz == Short.class) {
- return Short.TYPE;
- }
- if (clazz == Integer.class) {
- return Integer.TYPE;
- }
- if (clazz == Long.class) {
- return Long.TYPE;
- }
- if (clazz == Float.class) {
- return Float.TYPE;
- }
- if (clazz == Double.class) {
- return Double.TYPE;
- }
- if (clazz == Void.class) {
- return Void.TYPE;
- }
- return null;
- }
-
} // ObjectUtil
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/PagerUtil.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/PagerUtil.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/PagerUtil.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,210 +0,0 @@
-/*
- * #%L
- * Nuiton Utils :: Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.util;
-
-import org.apache.commons.lang3.tuple.Pair;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Common methods to deal with a pager.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- * @deprecated since 2.6.2, prefer use now {@link PagerBeanUtil}
- */
-public class PagerUtil {
-
- /**
- * Given a total count of elements and a page size, compute the number of
- * pages available.
- *
- * @param totalCount total count of elements in the pager
- * @param pageSize size of a page
- * @return the number of available pages
- */
- public static int getTotalPage(int totalCount, int pageSize) {
- int result = (int) Math.ceil((double) totalCount / (double) pageSize);
- return result;
- }
-
- /**
- * Compute the pager bound given his datas:
- * <ul>
- * <li>{@code totalCount}: count of all elements of the pager</li>
- * <li>{@code pageSize}: number of elements in a page</li>
- * <li>{@code page}: the requested page number starting at {@code 1}</li>
- * </ul>
- *
- * @param totalCount total count of elements in the pager
- * @param page pager page number (starting at {@code 1})
- * @param pageSize number of elements in a page
- * @return the bound of start and end index of the requested elements of the pager
- */
- public static Pair<Integer, Integer> getPageBound(int totalCount,
- int page,
- int pageSize) {
-
- page = Math.max(page, 1);
- pageSize = Math.max(pageSize, 1);
-
- int start = (page - 1) * pageSize;
- int end = page * pageSize; // End in subList is exclusive
-
- end = Math.min(end, totalCount); //To be sure that end will not be out of bound in subList
-
- Pair<Integer, Integer> result = Pair.of(start, end);
- return result;
- }
-
- /**
- * Get the elements of the lists using the pager datas:
- * <p/>
- * <ul>
- * <li>{@code elements}:all elements of the pager</li>
- * <li>{@code pageSize}: number of elements in a page</li>
- * <li>{@code page}: the requested page number starting at {@code 1}</li>
- * </ul>
- *
- * @param elements all pager elements
- * @param page pager page number (starting at {@code 1})
- * @param pageSize number of elements in a page
- * @param <E> n'importe quel type
- * @return la liste une fois filtrée
- */
- public static <E> List<E> getPage(List<E> elements, int page, int pageSize) {
-
- Pair<Integer, Integer> bound = getPageBound(elements.size(), page, pageSize);
-
- int start = bound.getLeft();
- int end = bound.getRight();
-
- List<E> subList = elements.subList(start, end);
- List<E> result = new ArrayList<E>(subList);
-
- return result;
- }
-
- /**
- * Given a pagerBean, compute his {@link PagerBean#recordStartIndex},
- * {@link PagerBean#recordEndIndex} and {@link PagerBean#pagesNumber}.
- *
- * @param bean the pagerBean to fill
- * @since 2.4.3
- */
- public static void computeRecordIndexesAndPagesNumber(PagerBean bean) {
- int records = bean.getRecords();
- int pageSize = bean.getPageSize();
-
- Pair<Integer, Integer> pageBound =
- getPageBound(records, bean.getPageIndex(), pageSize);
- bean.setRecordStartIndex(pageBound.getLeft());
- bean.setRecordEndIndex(pageBound.getRight());
- bean.setPagesNumber(getTotalPage(records, pageSize));
- }
-
- public static PagerBean newPagerBean() {
- return new PagerBean();
- }
-
- /**
- * Pager bean containing all internal states of a pager.
- *
- * @since 2.4.3
- */
- public static class PagerBean implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /** Number of records (says numbers of rows displayable. */
- protected int records;
-
- /** Index of the first record in this page. */
- protected int recordStartIndex;
-
- /** Index of the last record in this page. */
- protected int recordEndIndex;
-
- /** Index of the page. */
- protected int pageIndex;
-
- /** Page size, says number of records in a page. */
- protected int pageSize;
-
- /** Number of pages. */
- protected int pagesNumber;
-
- public int getRecords() {
- return records;
- }
-
- public int getRecordStartIndex() {
- return recordStartIndex;
- }
-
- public int getRecordEndIndex() {
- return recordEndIndex;
- }
-
- public int getPageIndex() {
- return pageIndex;
- }
-
- public int getPageSize() {
- return pageSize;
- }
-
- public int getPagesNumber() {
- return pagesNumber;
- }
-
- public void setRecords(int records) {
- this.records = records;
- }
-
- public void setRecordStartIndex(int recordStartIndex) {
- this.recordStartIndex = recordStartIndex;
- }
-
- public void setRecordEndIndex(int recordEndIndex) {
- this.recordEndIndex = recordEndIndex;
- }
-
- public void setPageIndex(int pageIndex) {
- this.pageIndex = pageIndex;
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
-
- public void setPagesNumber(int pagesNumber) {
- this.pagesNumber = pagesNumber;
- }
-
- }
-}
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -541,34 +541,6 @@
}
/**
- * Verifie si la classe est de type primitif.
- *
- * @param clazz nom de la classe a tester
- * @return vrai si le classe est de type primitif faux sinon
- * @deprecated since 2.2, use now the method {@link ObjectUtil#isPrimitive(Class)}
- */
- @Deprecated
- public static boolean isPrimitive(Class clazz) {
- return ObjectUtil.isPrimitive(clazz);
- }
-
- /**
- * Retourne la classe du type primitf associé avec la classe de de l'objet
- * passé en parametre. Par exemple si la classe passée en paramètre est
- * Integer alors le resultat sera la classe de int.
- *
- * @param clazz la classe dont on souhaite le type primitf
- * @return le type primitif associé a la classe en paramètre, ou null s'il
- * n'y a pas de type primitif associé.
- * @deprecated since 2.2, use now the method {@link ObjectUtil#getPrimitiveClass(Class)}
- */
- @Deprecated
- public static Class getPrimitiveClass(Class clazz) {
- return ObjectUtil.getPrimitiveClass(clazz);
- }
-
-
- /**
* Test if an url contains the given directory with no recurse seeking.
*
* @param url the url to seek
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,122 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-/* *
- * TransformedList.java
- *
- * Created: 2 août 2005 02:12:42 CEST
- *
- * @author Benjamin POUSSIN <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Last update: $Date$
- * by : */
-package org.nuiton.util;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * TODO Wthat is it for ?
- *
- * @param <E>
- */
-public class TransformedList<E> extends AbstractList<E> implements Serializable { // TransformedList
-
- private static final long serialVersionUID = 2354881761407900789L;
-
- protected Transformer<E, ? super Object> transformer;
-
- protected List<Object> inner;
-
- public TransformedList(Transformer<E, ? super Object> transformer) {
- if (transformer == null) {
- throw new IllegalArgumentException("Transformer must not be null");
- }
-
- this.transformer = transformer;
- inner = new ArrayList<Object>();
- }
-
- public TransformedList(Transformer<E, ? super Object> transformer,
- Collection<? extends E> c) {
- this(transformer);
- addAll(c);
- }
-
- @Override
- public int size() {
- return inner.size();
- }
-
- @Override
- public E get(int index) {
- Object f = inner.get(index);
- E result = transformer.untransform(f);
- return result;
- }
-
- @Override
- public E set(int index, E element) {
- Object f = transformer.transform(element);
- f = inner.set(index, f);
- E result = transformer.untransform(f);
- return result;
- }
-
- @Override
- public void add(int index, E element) {
- Object f = transformer.transform(element);
- inner.add(index, f);
- }
-
- @Override
- public E remove(int index) {
- Object f = inner.remove(index);
- E result = transformer.untransform(f);
- return result;
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- out.writeObject(transformer);
- out.writeObject(inner);
- }
-
- @SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream in) throws IOException,
- ClassNotFoundException {
- in.defaultReadObject();
- transformer = (Transformer<E, Object>) in.readObject();
- inner = (List<Object>) in.readObject();
- }
-} // TransformedList
-
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,55 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-
-/* *
- * Transformer.java
- *
- * Created: 2 août 2005 02:55:41 CEST
- *
- * @author Benjamin POUSSIN <poussin(a)codelutin.com>
- * @version $Revision$
- *
- * Last update: $Date$
- * by : */
-package org.nuiton.util;
-
-import java.io.Serializable;
-
-/**
- * Permet de transformer un objet en un autre et inversement
- *
- * @param <E> le type de l'objet a transformer
- * @param <F> le type de l'objet transforme
- * @deprecated since 2.6.12 (there some other library which does it guava function, commons-collection function)
- */
-@Deprecated
-public interface Transformer<E, F> extends Serializable { // Transformer
-
- F transform(E e);
-
- E untransform(F f);
-} // Transformer
-
Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/FileCompletionTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/FileCompletionTest.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/FileCompletionTest.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,66 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.util;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * FileCompletionTest.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : */
-@Ignore
-public class FileCompletionTest {
-
- /**
- * FIXME test is keyboard interactive.
- *
- * @throws Exception
- */
- @Test
- public void testMe() throws Exception {
- FileCompletion fc = new FileCompletion(true, true);
- if (fc.consoleAvailable()) {
- new Thread(new Runnable() {
-
- public void run() {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // do not care...
- } finally {
- System.console().readLine("!q");
- }
- }
- }).start();
- System.out.println(fc.read());
- }
- }
-}
Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/PagerUtilTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/PagerUtilTest.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/PagerUtilTest.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -1,63 +0,0 @@
-/*
- * #%L
- * Nuiton Utils :: Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.util;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests the {@link PagerUtil}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class PagerUtilTest {
-
- @Test
- public void getPageBound() throws Exception {
-
- Pair<Integer, Integer> actualBound;
-
- // page size is greater than total count, only returns that is available
- actualBound = PagerUtil.getPageBound(10, 1, 11);
- Assert.assertEquals(Pair.of(0, 10), actualBound);
-
- }
-
- @Test
- public void getTotalPage() throws Exception {
- int totalPage;
-
- totalPage = PagerUtil.getTotalPage(9, 10);
- Assert.assertEquals(1, totalPage);
-
- totalPage = PagerUtil.getTotalPage(10, 10);
- Assert.assertEquals(1, totalPage);
-
- totalPage = PagerUtil.getTotalPage(11, 10);
- Assert.assertEquals(2, totalPage);
- }
-}
Modified: trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2ValidatorUtil.java
===================================================================
--- trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2ValidatorUtil.java 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/nuiton-validator/src/main/java/org/nuiton/validator/xwork2/XWork2ValidatorUtil.java 2012-12-13 13:25:06 UTC (rev 2447)
@@ -26,6 +26,7 @@
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.FileManager;
+import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.inject.Container;
@@ -129,13 +130,13 @@
//FIXME-tchemit 2012-07-17 work-around to fix http://nuiton.org/issues/2191
//FIXME-tchemit 2012-07-17 will remove this when using xworks-core which fixes https://issues.apache.org/jira/browse/WW-3850
- if (validatorManager instanceof DefaultActionValidatorManager) {
+// if (validatorManager instanceof DefaultActionValidatorManager) {
+//
+// FileManagerFactory fileManagerFactory = container.getInstance(FileManagerFactory.class);
+// fileManagerFactory.setReloadingConfigs(String.valueOf(Boolean.FALSE));
+// ((DefaultActionValidatorManager) validatorManager).setFileManagerFactory(fileManagerFactory);
+// }
- FileManager fileManager = container.getInstance(FileManager.class);
- fileManager.setReloadingConfigs(false);
- ((DefaultActionValidatorManager) validatorManager).setFileManager(fileManager);
- }
-
return validatorManager;
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-12-01 10:06:18 UTC (rev 2446)
+++ trunk/pom.xml 2012-12-13 13:25:06 UTC (rev 2447)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.4.4</version>
+ <version>3.4.6</version>
</parent>
<artifactId>nuiton-utils-parent</artifactId>
@@ -131,7 +131,7 @@
<nuitonI18nVersion>2.5</nuitonI18nVersion>
<aspectjVersion>1.7.1</aspectjVersion>
- <xworkVersion>2.3.4.1</xworkVersion>
+ <xworkVersion>2.3.7</xworkVersion>
<doxiaVersion>1.3</doxiaVersion>
<!-- i18n configuration -->
@@ -257,7 +257,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.0.8</version>
+ <version>3.0.10</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
1
0
r2446 - in trunk/nuiton-utils/src: main/java/org/nuiton/util test/java/org/nuiton/util
by jcouteau@users.nuiton.org 01 Dec '12
by jcouteau@users.nuiton.org 01 Dec '12
01 Dec '12
Author: jcouteau
Date: 2012-12-01 11:06:18 +0100 (Sat, 01 Dec 2012)
New Revision: 2446
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2446
Log:
fixes #2462 : DateUtil.getYesterday returns wrong day
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/DateUtilTest.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java 2012-11-16 17:00:15 UTC (rev 2445)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java 2012-12-01 10:06:18 UTC (rev 2446)
@@ -407,6 +407,12 @@
*/
public static Date getYesterday(Date date) {
Calendar cal = getDefaultCalendar(date);
+ if (cal.get(Calendar.MONTH)==Calendar.JANUARY && cal.get(Calendar.DAY_OF_MONTH)==1){
+ cal.roll(Calendar.YEAR,false);
+ }
+ if (cal.get(Calendar.DAY_OF_MONTH)==1) {
+ cal.roll(Calendar.MONTH,false);
+ }
cal.roll(Calendar.DAY_OF_MONTH, false);
return cal.getTime();
}
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/DateUtilTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/DateUtilTest.java 2012-11-16 17:00:15 UTC (rev 2445)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/DateUtilTest.java 2012-12-01 10:06:18 UTC (rev 2446)
@@ -316,4 +316,31 @@
actualWeek = DateUtil.truncateToDayOfWeek(aDate);
Assert.assertEquals(expectedWeek, actualWeek);
}
+
+ @Test
+ public void testGetYesterday() {
+
+ //Test normal yesterday
+ Date aDate = DateUtil.createDate(3,4,5);
+ Date expectedADate = DateUtil.createDate(2,4,5);
+
+ //Test month change
+ Date bDate = DateUtil.createDate(1,12,12);
+ Date expectedBDate = DateUtil.createDate(30,11,12);
+
+ //Test year change
+ Date cDate = DateUtil.createDate(1,1,12);
+ Date expectedCDate = DateUtil.createDate(31,12,11);
+
+ //Test possible wrong change
+ Date dDate = DateUtil.createDate(3,1,12);
+ Date expectedDDate = DateUtil.createDate(2,1,12);
+
+
+ Assert.assertEquals(expectedADate, DateUtil.getYesterday(aDate));
+ Assert.assertEquals(expectedBDate, DateUtil.getYesterday(bDate));
+ Assert.assertEquals(expectedCDate, DateUtil.getYesterday(cDate));
+ Assert.assertEquals(expectedDDate, DateUtil.getYesterday(dDate));
+
+ }
}
1
0