Performed code review and Javadoc review.

This commit is contained in:
Christian P. MOMON 2017-05-04 23:36:04 +02:00
parent 7dc362f671
commit cf5ddaf81c
18 changed files with 703 additions and 250 deletions

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2008-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2008-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -29,30 +29,39 @@ public class DataFile
public static int DEFAULT_SIZE = 0; public static int DEFAULT_SIZE = 0;
// //
protected int id; private int id;
protected int contentId; private int contentId;
protected String name; private String name;
protected long size; private long size;
protected byte[] data; private byte[] data;
protected String creationDate; private String creationDate;
protected String creationUser; private String creationUser;
/** /**
* * Instantiates a new data file.
*/ */
public DataFile() public DataFile()
{ {
this.id = NOID; this.id = NOID;
this.contentId = NOID; this.contentId = NOID;
this.name = null; this.name = null;
this.size = this.DEFAULT_SIZE; this.size = DEFAULT_SIZE;
this.data = null; this.data = null;
this.creationDate = null; this.creationDate = null;
this.creationUser = null; this.creationUser = null;
} }
/** /**
* * Instantiates a new data file.
*
* @param contentId
* the content id
* @param name
* the name
* @param size
* the size
* @param data
* the data
*/ */
public DataFile(final int contentId, final String name, final long size, final byte[] data) public DataFile(final int contentId, final String name, final long size, final byte[] data)
{ {
@ -66,7 +75,14 @@ public class DataFile
} }
/** /**
* * Instantiates a new data file.
*
* @param name
* the name
* @param size
* the size
* @param data
* the data
*/ */
public DataFile(final String name, final long size, final byte[] data) public DataFile(final String name, final long size, final byte[] data)
{ {
@ -80,7 +96,9 @@ public class DataFile
} }
/** /**
* Content id.
* *
* @return the int
*/ */
public int contentId() public int contentId()
{ {
@ -93,7 +111,9 @@ public class DataFile
} }
/** /**
* * Creation date.
*
* @return the string
*/ */
public String creationDate() public String creationDate()
{ {
@ -106,7 +126,9 @@ public class DataFile
} }
/** /**
* Creation user.
* *
* @return the string
*/ */
public String creationUser() public String creationUser()
{ {
@ -119,7 +141,9 @@ public class DataFile
} }
/** /**
* Data.
* *
* @return the byte[]
*/ */
public byte[] data() public byte[] data()
{ {
@ -132,7 +156,9 @@ public class DataFile
} }
/** /**
* Id.
* *
* @return the int
*/ */
public int id() public int id()
{ {
@ -145,7 +171,9 @@ public class DataFile
} }
/** /**
* Name.
* *
* @return the string
*/ */
public String name() public String name()
{ {
@ -158,7 +186,10 @@ public class DataFile
} }
/** /**
* Sets the content id.
* *
* @param contentId
* the new content id
*/ */
public void setContentId(final int contentId) public void setContentId(final int contentId)
{ {
@ -166,7 +197,10 @@ public class DataFile
} }
/** /**
* Sets the creation date.
* *
* @param creationDate
* the new creation date
*/ */
public void setCreationDate(final String creationDate) public void setCreationDate(final String creationDate)
{ {
@ -181,7 +215,10 @@ public class DataFile
} }
/** /**
* Sets the creation user.
* *
* @param creationUser
* the new creation user
*/ */
public void setCreationUser(final String creationUser) public void setCreationUser(final String creationUser)
{ {
@ -196,7 +233,10 @@ public class DataFile
} }
/** /**
* Sets the data.
* *
* @param data
* the new data
*/ */
public void setData(final byte[] data) public void setData(final byte[] data)
{ {
@ -204,7 +244,10 @@ public class DataFile
} }
/** /**
* Sets the id.
* *
* @param id
* the new id
*/ */
public void setId(final int id) public void setId(final int id)
{ {
@ -212,7 +255,10 @@ public class DataFile
} }
/** /**
* Sets the name.
* *
* @param name
* the new name
*/ */
public void setName(final String name) public void setName(final String name)
{ {
@ -227,7 +273,10 @@ public class DataFile
} }
/** /**
* Sets the size.
* *
* @param size
* the new size
*/ */
public void setSize(final long size) public void setSize(final long size)
{ {
@ -242,7 +291,9 @@ public class DataFile
} }
/** /**
* Size.
* *
* @return the long
*/ */
public long size() public long size()
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2008-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2008-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -23,15 +23,14 @@ import java.util.ArrayList;
/** /**
* This class is a collection of DataFile objects whit some specific methods. * This class is a collection of DataFile objects whit some specific methods.
* *
* @author Christian Pierre MOMON * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class DataFiles extends ArrayList<DataFile> public class DataFiles extends ArrayList<DataFile>
{ {
private static final long serialVersionUID = -4584622422555785456L; private static final long serialVersionUID = -4584622422555785456L;
/** /**
* * Instantiates a new data files.
*
*/ */
public DataFiles() public DataFiles()
{ {
@ -39,8 +38,10 @@ public class DataFiles extends ArrayList<DataFile>
} }
/** /**
* Instantiates a new data files.
* *
* @param source * @param source
* the source
*/ */
public DataFiles(final DataFiles source) public DataFiles(final DataFiles source)
{ {
@ -48,7 +49,11 @@ public class DataFiles extends ArrayList<DataFile>
} }
/** /**
* Gets the by content id.
* *
* @param id
* the id
* @return the by content id
*/ */
public DataFiles getByContentId(final int id) public DataFiles getByContentId(final int id)
{ {
@ -69,7 +74,11 @@ public class DataFiles extends ArrayList<DataFile>
} }
/** /**
* Gets the by id.
* *
* @param id
* the id
* @return the by id
*/ */
public DataFile getById(final int id) public DataFile getById(final int id)
{ {
@ -105,7 +114,11 @@ public class DataFiles extends ArrayList<DataFile>
} }
/** /**
* Gets the by index.
* *
* @param index
* the index
* @return the by index
*/ */
public DataFile getByIndex(final int index) public DataFile getByIndex(final int index)
{ {
@ -118,7 +131,11 @@ public class DataFiles extends ArrayList<DataFile>
} }
/** /**
* Gets the by name.
* *
* @param name
* the name
* @return the by name
*/ */
public DataFile getByName(final String name) public DataFile getByName(final String name)
{ {
@ -160,8 +177,8 @@ public class DataFiles extends ArrayList<DataFile>
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.util.AbstractCollection#toString()
*/ */
@Override @Override
public String toString() public String toString()

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -45,7 +45,11 @@ public class DateHelper
private static final String AMERICAN_DATE_PATTERN = "^([01]{0,1}\\d)/([0123]{0,1}\\d)/(\\d\\d\\d\\d)$"; private static final String AMERICAN_DATE_PATTERN = "^([01]{0,1}\\d)/([0123]{0,1}\\d)/(\\d\\d\\d\\d)$";
/** /**
* * American format.
*
* @param time
* the time
* @return the string
*/ */
public static String americanFormat(final Calendar time) public static String americanFormat(final Calendar time)
{ {
@ -65,7 +69,11 @@ public class DateHelper
} }
/** /**
* * European format.
*
* @param time
* the time
* @return the string
*/ */
public static String europeanFormat(final Calendar time) public static String europeanFormat(final Calendar time)
{ {
@ -85,7 +93,11 @@ public class DateHelper
} }
/** /**
* * Checks if is american format.
*
* @param date
* the date
* @return true, if is american format
*/ */
public static boolean isAmericanFormat(final String date) public static boolean isAmericanFormat(final String date)
{ {
@ -105,7 +117,11 @@ public class DateHelper
} }
/** /**
* * Checks if is european format.
*
* @param date
* the date
* @return true, if is european format
*/ */
public static boolean isEuropeanFormat(final String date) public static boolean isEuropeanFormat(final String date)
{ {
@ -125,7 +141,11 @@ public class DateHelper
} }
/** /**
* * Checks if is ISO format.
*
* @param date
* the date
* @return true, if is ISO format
*/ */
public static boolean isISOFormat(final String date) public static boolean isISOFormat(final String date)
{ {
@ -145,7 +165,11 @@ public class DateHelper
} }
/** /**
* * ISO format.
*
* @param time
* the time
* @return the string
*/ */
public static String ISOFormat(final Calendar time) public static String ISOFormat(final Calendar time)
{ {
@ -165,7 +189,11 @@ public class DateHelper
} }
/** /**
* * Checks if is raw format.
*
* @param date
* the date
* @return true, if is raw format
*/ */
public static boolean isRawFormat(final String date) public static boolean isRawFormat(final String date)
{ {
@ -185,7 +213,11 @@ public class DateHelper
} }
/** /**
* * Checks if is valid date.
*
* @param date
* the date
* @return true, if is valid date
*/ */
public static boolean isValidDate(final String date) public static boolean isValidDate(final String date)
{ {
@ -205,7 +237,11 @@ public class DateHelper
} }
/** /**
* * Parses the american date.
*
* @param date
* the date
* @return the calendar
*/ */
public static Calendar parseAmericanDate(final String date) public static Calendar parseAmericanDate(final String date)
{ {
@ -229,6 +265,10 @@ public class DateHelper
/** /**
* Note: European parsing test made before the American parsing one. * Note: European parsing test made before the American parsing one.
*
* @param date
* the date
* @return the calendar
*/ */
public static Calendar parseDate(final String date) public static Calendar parseDate(final String date)
{ {
@ -260,7 +300,11 @@ public class DateHelper
} }
/** /**
* * Parses the european date.
*
* @param date
* the date
* @return the calendar
*/ */
public static Calendar parseEuropeanDate(final String date) public static Calendar parseEuropeanDate(final String date)
{ {
@ -283,7 +327,11 @@ public class DateHelper
} }
/** /**
* * Parses the ISO date.
*
* @param date
* the date
* @return the calendar
*/ */
public static Calendar parseISODate(final String date) public static Calendar parseISODate(final String date)
{ {
@ -306,7 +354,11 @@ public class DateHelper
} }
/** /**
* * Parses the raw date.
*
* @param date
* the date
* @return the calendar
*/ */
public static Calendar parseRawDate(final String date) public static Calendar parseRawDate(final String date)
{ {
@ -329,7 +381,11 @@ public class DateHelper
} }
/** /**
* * Raw format.
*
* @param time
* the time
* @return the string
*/ */
public static String rawFormat(final Calendar time) public static String rawFormat(final Calendar time)
{ {
@ -349,7 +405,11 @@ public class DateHelper
} }
/** /**
* * Short european format.
*
* @param time
* the time
* @return the string
*/ */
public static String shortEuropeanFormat(final Calendar time) public static String shortEuropeanFormat(final Calendar time)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -39,7 +39,11 @@ public class DateTimeHelper
private static final String AMERICAN_DATE_PATTERN = "^([01]{0,1}\\d)/([0123]{0,1}\\d)/(\\d\\d\\d\\d)$"; private static final String AMERICAN_DATE_PATTERN = "^([01]{0,1}\\d)/([0123]{0,1}\\d)/(\\d\\d\\d\\d)$";
/** /**
* * American format.
*
* @param time
* the time
* @return the string
*/ */
public static String americanFormat(final Calendar time) public static String americanFormat(final Calendar time)
{ {
@ -60,7 +64,11 @@ public class DateTimeHelper
} }
/** /**
* * European format.
*
* @param time
* the time
* @return the string
*/ */
public static String europeanFormat(final Calendar time) public static String europeanFormat(final Calendar time)
{ {
@ -81,7 +89,11 @@ public class DateTimeHelper
} }
/** /**
* * ISO format.
*
* @param time
* the time
* @return the string
*/ */
public static String ISOFormat(final Calendar time) public static String ISOFormat(final Calendar time)
{ {
@ -102,7 +114,11 @@ public class DateTimeHelper
} }
/** /**
* * Raw format.
*
* @param time
* the time
* @return the string
*/ */
public static String rawFormat(final Calendar time) public static String rawFormat(final Calendar time)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2006, 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2006,2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -32,8 +32,17 @@ import java.security.MessageDigest;
@Deprecated @Deprecated
public class Digester public class Digester
{ {
/** /**
* "SHA-1", "MD5", "SHA-256", and "SHA-512" * "SHA-1", "MD5", "SHA-256", and "SHA-512".
*
* @param digestMethod
* the digest method
* @param file
* the file
* @return the string
* @throws Exception
* the exception
*/ */
public static String computeHash(final String digestMethod, final File file) throws Exception public static String computeHash(final String digestMethod, final File file) throws Exception
{ {
@ -98,7 +107,11 @@ public class Digester
} }
/** /**
* Human readable digest.
* *
* @param digest
* the digest
* @return the string
*/ */
public static String humanReadableDigest(final byte[] digest) public static String humanReadableDigest(final byte[] digest)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -30,7 +30,14 @@ public class FileCopier
public static final int BUFFER_SIZE = 4 * 1024; public static final int BUFFER_SIZE = 4 * 1024;
/** /**
* Copy.
* *
* @param source
* the source
* @param target
* the target
* @throws Exception
* the exception
*/ */
public static void copy(final File source, final File target) throws Exception public static void copy(final File source, final File target) throws Exception
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -24,19 +24,22 @@ import java.util.Vector;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* * The Class FileIterator.
*/ */
public class FileIterator extends Vector<FileIteratorState> implements Iterator<File> public class FileIterator extends Vector<FileIteratorState> implements Iterator<File>
{ {
private static final long serialVersionUID = 8790133455427427766L; private static final long serialVersionUID = 8790133455427427766L;
protected int currentDepth; private int currentDepth;
protected Pattern pattern; private Pattern pattern;
protected File previous; private File previous;
protected boolean followLinks; private boolean followLinks;
/** /**
* * Instantiates a new file iterator.
*
* @param root
* the root
*/ */
public FileIterator(final File root) public FileIterator(final File root)
{ {
@ -57,7 +60,14 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* * Instantiates a new file iterator.
*
* @param root
* the root
* @param filter
* the filter
* @param followLinks
* the follow links
*/ */
public FileIterator(final File root, final String filter, final boolean followLinks) public FileIterator(final File root, final String filter, final boolean followLinks)
{ {
@ -99,7 +109,14 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* * Instantiates a new file iterator.
*
* @param pathnames
* the pathnames
* @param filter
* the filter
* @param followLinks
* the follow links
*/ */
public FileIterator(final String[] pathnames, final String filter, final boolean followLinks) public FileIterator(final String[] pathnames, final String filter, final boolean followLinks)
{ {
@ -109,7 +126,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Current file.
* *
* @return the file
*/ */
public File currentFile() public File currentFile()
{ {
@ -122,7 +141,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Current state.
* *
* @return the file iterator state
*/ */
protected FileIteratorState currentState() protected FileIteratorState currentState()
{ {
@ -135,7 +156,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Directory final countdown.
* *
* @return the int
*/ */
public int directoryFinalCountdown() public int directoryFinalCountdown()
{ {
@ -175,7 +198,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Filter.
* *
* @return the string
*/ */
protected String filter() protected String filter()
{ {
@ -195,7 +220,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Final countdown.
* *
* @return the int
*/ */
public int finalCountdown() public int finalCountdown()
{ {
@ -212,7 +239,11 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Follow.
* *
* @param file
* the file
* @return true, if successful
*/ */
public boolean follow(final File file) public boolean follow(final File file)
{ {
@ -243,8 +274,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#hasNext()
*/ */
@Override @Override
public boolean hasNext() public boolean hasNext()
@ -258,7 +289,14 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* * Inits the.
*
* @param pathnames
* the pathnames
* @param filter
* the filter
* @param followLinks
* the follow links
*/ */
protected void init(final String[] pathnames, final String filter, final boolean followLinks) protected void init(final String[] pathnames, final String filter, final boolean followLinks)
{ {
@ -272,8 +310,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
shift(); shift();
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#next()
*/ */
@Override @Override
public File next() public File next()
@ -297,7 +335,9 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Pattern.
* *
* @return the pattern
*/ */
public Pattern pattern() public Pattern pattern()
{ {
@ -310,7 +350,7 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* * Pop.
*/ */
public void pop() public void pop()
{ {
@ -319,7 +359,10 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Push.
* *
* @param file
* the file
*/ */
public void push(final File file) public void push(final File file)
{ {
@ -330,8 +373,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#remove()
*/ */
@Override @Override
public void remove() public void remove()
@ -344,7 +387,7 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* * Reset.
*/ */
public void reset() public void reset()
{ {
@ -362,7 +405,10 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
/** /**
* Sets the filter.
* *
* @param filter
* the new filter
*/ */
protected void setFilter(final String filter) protected void setFilter(final String filter)
{ {
@ -416,22 +462,28 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
} }
} }
/** /* (non-Javadoc)
* * @see java.util.Vector#toString()
*/ */
@Override @Override
public String toString() public String toString()
{ {
String result; String result;
result = "[depth=" + this.currentDepth + "][index=" + this.get(this.currentDepth).currentIndex() + "/" + this.get(this.currentDepth).files.length + "]"; result = "[depth=" + this.currentDepth + "][index=" + this.get(this.currentDepth).currentIndex() + "/" + this.get(this.currentDepth).files().length + "]";
// //
return result; return result;
} }
/** /**
* Checks if is link.
* *
* @param file
* the file
* @return true, if is link
* @throws Exception
* the exception
*/ */
public static boolean isLink(final File file) throws Exception public static boolean isLink(final File file) throws Exception
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2010, 2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -26,11 +26,14 @@ import java.util.Iterator;
*/ */
public class FileIteratorState implements Iterator<File> public class FileIteratorState implements Iterator<File>
{ {
protected File[] files; private File[] files;
protected int currentIndex; private int currentIndex;
/** /**
* * Instantiates a new file iterator state.
*
* @param files
* the files
*/ */
public FileIteratorState(final File[] files) public FileIteratorState(final File[] files)
{ {
@ -49,6 +52,9 @@ public class FileIteratorState implements Iterator<File>
/** /**
* Useful for the depth zero, otherwise parent path is lost. * Useful for the depth zero, otherwise parent path is lost.
*
* @param pathnames
* the pathnames
*/ */
public FileIteratorState(final String[] pathnames) public FileIteratorState(final String[] pathnames)
{ {
@ -63,7 +69,9 @@ public class FileIteratorState implements Iterator<File>
} }
/** /**
* Current file.
* *
* @return the file
*/ */
protected File currentFile() protected File currentFile()
{ {
@ -83,7 +91,9 @@ public class FileIteratorState implements Iterator<File>
} }
/** /**
* Current index.
* *
* @return the int
*/ */
protected int currentIndex() protected int currentIndex()
{ {
@ -96,7 +106,9 @@ public class FileIteratorState implements Iterator<File>
} }
/** /**
* Files.
* *
* @return the file[]
*/ */
protected File[] files() protected File[] files()
{ {
@ -108,8 +120,8 @@ public class FileIteratorState implements Iterator<File>
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#hasNext()
*/ */
@Override @Override
public boolean hasNext() public boolean hasNext()
@ -129,8 +141,8 @@ public class FileIteratorState implements Iterator<File>
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#next()
*/ */
@Override @Override
public File next() public File next()
@ -144,8 +156,8 @@ public class FileIteratorState implements Iterator<File>
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.util.Iterator#remove()
*/ */
@Override @Override
public void remove() public void remove()
@ -153,7 +165,7 @@ public class FileIteratorState implements Iterator<File>
} }
/** /**
* * Reset.
*/ */
public void reset() public void reset()
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2008-2015 Christian Pierre MOMON * Copyright (C) 2008-2015,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -35,6 +35,7 @@ import fr.devinsy.util.strings.StringList;
import fr.devinsy.util.strings.StringListUtils; import fr.devinsy.util.strings.StringListUtils;
/** /**
* The Class FileTools.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
@ -43,11 +44,12 @@ public class FileTools
public static final String DEFAULT_CHARSET_NAME = "UTF-8"; public static final String DEFAULT_CHARSET_NAME = "UTF-8";
/** /**
* * Adds the before extension.
* *
* @param fileName * @param fileName
* Source. * Source.
* * @param addition
* the addition
* @return Extension value or null. * @return Extension value or null.
*/ */
public static String addBeforeExtension(final String fileName, final String addition) public static String addBeforeExtension(final String fileName, final String addition)
@ -83,11 +85,12 @@ public class FileTools
} }
/** /**
* * Adds the to name.
* *
* @param file * @param file
* Source. * Source.
* * @param addition
* the addition
* @return Extension value or null. * @return Extension value or null.
*/ */
public static File addToName(final File file, final String addition) public static File addToName(final File file, final String addition)
@ -149,9 +152,8 @@ public class FileTools
* <li>getExtension("abc.efg") = "efg"</li> * <li>getExtension("abc.efg") = "efg"</li>
* </ul> * </ul>
* *
* @param file * @param fileName
* Source. * the file name
*
* @return Extension value or null. * @return Extension value or null.
* @deprecated See * @deprecated See
* <code>org.apache.commons.io.FilenameUtils.getExtension</code> * <code>org.apache.commons.io.FilenameUtils.getExtension</code>
@ -183,10 +185,13 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* @return * the source
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final File source) throws IOException public static String load(final File source) throws IOException
{ {
@ -199,9 +204,15 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* the source
* @param charsetName
* the charset name
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final File source, final String charsetName) throws IOException public static String load(final File source, final String charsetName) throws IOException
{ {
@ -214,10 +225,13 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* @return * the source
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final URL source) throws IOException public static String load(final URL source) throws IOException
{ {
@ -230,9 +244,15 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* the source
* @param charsetName
* the charset name
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final URL source, final String charsetName) throws IOException public static String load(final URL source, final String charsetName) throws IOException
{ {
@ -250,9 +270,13 @@ public class FileTools
} }
/** /**
* Load string list.
* *
* @param file * @param source
* the source
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadStringList(final File source) throws IOException public static StringList loadStringList(final File source) throws IOException
{ {
@ -265,9 +289,15 @@ public class FileTools
} }
/** /**
* Load string list.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadStringList(final File file, final String charsetName) throws IOException public static StringList loadStringList(final File file, final String charsetName) throws IOException
{ {
@ -280,9 +310,13 @@ public class FileTools
} }
/** /**
* Load to string buffer.
* *
* @param file * @param source
* the source
* @return the string buffer
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringBuffer loadToStringBuffer(final File source) throws IOException public static StringBuffer loadToStringBuffer(final File source) throws IOException
{ {
@ -295,9 +329,15 @@ public class FileTools
} }
/** /**
* Load to string buffer.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string buffer
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException
{ {
@ -345,9 +385,13 @@ public class FileTools
} }
/** /**
* Load to string list.
* *
* @param file * @param source
* the source
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final File source) throws IOException public static StringList loadToStringList(final File source) throws IOException
{ {
@ -360,9 +404,15 @@ public class FileTools
} }
/** /**
* Load to string list.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final File file, final String charsetName) throws IOException public static StringList loadToStringList(final File file, final String charsetName) throws IOException
{ {
@ -410,10 +460,13 @@ public class FileTools
} }
/** /**
* Load to string list.
* *
* @param file * @param source
* @return * the source
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final URL source) throws IOException public static StringList loadToStringList(final URL source) throws IOException
{ {
@ -426,9 +479,15 @@ public class FileTools
} }
/** /**
* Load to string list.
* *
* @param file * @param source
* the source
* @param charsetName
* the charset name
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final URL source, final String charsetName) throws IOException public static StringList loadToStringList(final URL source, final String charsetName) throws IOException
{ {
@ -442,9 +501,16 @@ public class FileTools
} }
/** /**
* Read.
* *
* @param file * @param out
* the out
* @param is
* the is
* @param charsetName
* the charset name
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static void read(final StringBuffer out, final InputStream is, final String charsetName) throws IOException public static void read(final StringBuffer out, final InputStream is, final String charsetName) throws IOException
{ {
@ -487,11 +553,11 @@ public class FileTools
} }
/** /**
* Removes the extension.
* *
* @param source * @param source
* @param extension * the source
* @return * @return the string
*
* @deprecated See * @deprecated See
* <code>org.apache.commons.io.FilenameUtils.removeExtension</code> * <code>org.apache.commons.io.FilenameUtils.removeExtension</code>
*/ */
@ -524,10 +590,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
* @throws FileNotFoundException
* the file not found exception
*/ */
public static void save(final File file, final String source) throws UnsupportedEncodingException, FileNotFoundException public static void save(final File file, final String source) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -548,10 +620,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
* @throws FileNotFoundException
* the file not found exception
*/ */
public static void save(final File file, final StringBuffer source) throws UnsupportedEncodingException, FileNotFoundException public static void save(final File file, final StringBuffer source) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -559,10 +637,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
* @throws FileNotFoundException
* the file not found exception
*/ */
public static void save(final File file, final StringList source) throws UnsupportedEncodingException, FileNotFoundException public static void save(final File file, final StringList source) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -570,10 +654,13 @@ public class FileTools
} }
/** /**
* Sets the extension.
* *
* @param source * @param source
* the source
* @param extension * @param extension
* @return * the extension
* @return the file
*/ */
public static File setExtension(final File source, final String extension) public static File setExtension(final File source, final String extension)
{ {
@ -593,10 +680,13 @@ public class FileTools
} }
/** /**
* Sets the extension.
* *
* @param source * @param source
* the source
* @param extension * @param extension
* @return * the extension
* @return the string
*/ */
public static String setExtension(final String source, final String extension) public static String setExtension(final String source, final String extension)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2009-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2009-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -25,11 +25,16 @@ package fr.devinsy.util;
*/ */
public class Fraction public class Fraction
{ {
protected long numerator; private long numerator;
protected long denominator; private long denominator;
/** /**
* Instantiates a new fraction.
* *
* @param numerator
* the numerator
* @param denominator
* the denominator
*/ */
public Fraction(final long numerator, final long denominator) public Fraction(final long numerator, final long denominator)
{ {
@ -38,7 +43,9 @@ public class Fraction
} }
/** /**
* Denominator.
* *
* @return the long
*/ */
public long denominator() public long denominator()
{ {
@ -51,7 +58,9 @@ public class Fraction
} }
/** /**
* Numerator.
* *
* @return the long
*/ */
public long numerator() public long numerator()
{ {
@ -64,7 +73,11 @@ public class Fraction
} }
/** /**
* Percentage.
* *
* @return the long
* @throws Exception
* the exception
*/ */
public long percentage() throws Exception public long percentage() throws Exception
{ {
@ -77,7 +90,9 @@ public class Fraction
} }
/** /**
* Percentage full string.
* *
* @return the string
*/ */
public String percentageFullString() public String percentageFullString()
{ {
@ -90,7 +105,9 @@ public class Fraction
} }
/** /**
* Percentage string.
* *
* @return the string
*/ */
public String percentageString() public String percentageString()
{ {
@ -102,8 +119,8 @@ public class Fraction
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() public String toString()
@ -117,7 +134,15 @@ public class Fraction
} }
/** /**
* Percentage.
* *
* @param numerator
* the numerator
* @param denominator
* the denominator
* @return the long
* @throws Exception
* the exception
*/ */
public static long percentage(final long numerator, final long denominator) throws Exception public static long percentage(final long numerator, final long denominator) throws Exception
{ {
@ -137,7 +162,13 @@ public class Fraction
} }
/** /**
* Percentage full string.
* *
* @param numerator
* the numerator
* @param denominator
* the denominator
* @return the string
*/ */
public static String percentageFullString(final long numerator, final long denominator) public static String percentageFullString(final long numerator, final long denominator)
{ {
@ -150,7 +181,13 @@ public class Fraction
} }
/** /**
* Percentage string.
* *
* @param numerator
* the numerator
* @param denominator
* the denominator
* @return the string
*/ */
public static String percentageString(final long numerator, final long denominator) public static String percentageString(final long numerator, final long denominator)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2009-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2009-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -19,18 +19,17 @@
package fr.devinsy.util; package fr.devinsy.util;
/** /**
* * The Class InternetProxyConfiguration.
*/ */
public class InternetProxyConfiguration public class InternetProxyConfiguration
{ {
// private String host;
protected String host; private int port;
protected int port; private String login;
protected String login; private String password;
protected String password;
/** /**
* * Instantiates a new internet proxy configuration.
*/ */
public InternetProxyConfiguration() public InternetProxyConfiguration()
{ {
@ -40,8 +39,17 @@ public class InternetProxyConfiguration
this.password = ""; this.password = "";
} }
/** /**
* * Instantiates a new internet proxy configuration.
*
* @param host
* the host
* @param port
* the port
* @param login
* the login
* @param password
* the password
*/ */
public InternetProxyConfiguration(final String host, final int port, final String login, final String password) public InternetProxyConfiguration(final String host, final int port, final String login, final String password)
{ {
@ -79,8 +87,19 @@ public class InternetProxyConfiguration
} }
} }
/** /**
* * Instantiates a new internet proxy configuration.
*
* @param host
* the host
* @param port
* the port
* @param login
* the login
* @param password
* the password
* @throws Exception
* the exception
*/ */
public InternetProxyConfiguration(final String host, final String port, final String login, final String password) throws Exception public InternetProxyConfiguration(final String host, final String port, final String login, final String password) throws Exception
{ {
@ -133,8 +152,10 @@ public class InternetProxyConfiguration
} }
} }
/** /**
* * Host.
*
* @return the string
*/ */
public String host() public String host()
{ {
@ -147,7 +168,9 @@ public class InternetProxyConfiguration
} }
/** /**
* Checks if is initialized.
* *
* @return true, if is initialized
*/ */
public boolean isInitialized() public boolean isInitialized()
{ {
@ -166,8 +189,10 @@ public class InternetProxyConfiguration
return result; return result;
} }
/** /**
* * Login.
*
* @return the string
*/ */
public String login() public String login()
{ {
@ -179,8 +204,10 @@ public class InternetProxyConfiguration
return result; return result;
} }
/** /**
* * Password.
*
* @return the string
*/ */
public String password() public String password()
{ {
@ -192,8 +219,10 @@ public class InternetProxyConfiguration
return result; return result;
} }
/** /**
* * Port.
*
* @return the int
*/ */
public int port() public int port()
{ {
@ -205,8 +234,8 @@ public class InternetProxyConfiguration
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() public String toString()

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2009-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2009-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -24,13 +24,12 @@ package fr.devinsy.util;
*/ */
public class SimpleAveragemeter public class SimpleAveragemeter
{ {
// private long sum;
protected long sum; private long cardinal;
protected long cardinal; private long MAX_ADD = 1 * 24 * 60 * 60 * 1000; // One day in millisecond.
protected long MAX_ADD = 1 * 24 * 60 * 60 * 1000; // One day in millisecond.
/** /**
* * Instantiates a new simple averagemeter.
*/ */
public SimpleAveragemeter() public SimpleAveragemeter()
{ {
@ -38,7 +37,10 @@ public class SimpleAveragemeter
} }
/** /**
* Adds the.
* *
* @param value
* the value
*/ */
synchronized public void add(final long value) synchronized public void add(final long value)
{ {
@ -63,7 +65,9 @@ public class SimpleAveragemeter
} }
/** /**
* Average.
* *
* @return the long
*/ */
synchronized public long average() synchronized public long average()
{ {
@ -83,7 +87,9 @@ public class SimpleAveragemeter
} }
/** /**
* Cardinal.
* *
* @return the long
*/ */
public long cardinal() public long cardinal()
{ {
@ -96,7 +102,7 @@ public class SimpleAveragemeter
} }
/** /**
* * Reset.
*/ */
synchronized public void reset() synchronized public void reset()
{ {
@ -104,8 +110,8 @@ public class SimpleAveragemeter
this.cardinal = 0; this.cardinal = 0;
} }
/** /* (non-Javadoc)
* * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() public String toString()
@ -119,7 +125,9 @@ public class SimpleAveragemeter
} }
/** /**
* Value.
* *
* @return the long
*/ */
public long value() public long value()
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2008-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2008-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -21,15 +21,15 @@ package fr.devinsy.util;
import java.util.Date; import java.util.Date;
/** /**
* * The Class SimpleChronometer.
*/ */
public class SimpleChronometer public class SimpleChronometer
{ {
// //
protected long firstTime; private long firstTime;
/** /**
* * Instantiates a new simple chronometer.
*/ */
public SimpleChronometer() public SimpleChronometer()
{ {
@ -37,7 +37,9 @@ public class SimpleChronometer
} }
/** /**
* Interval.
* *
* @return the long
*/ */
public long interval() public long interval()
{ {
@ -50,7 +52,7 @@ public class SimpleChronometer
} }
/** /**
* * Reset.
*/ */
public void reset() public void reset()
{ {
@ -59,6 +61,10 @@ public class SimpleChronometer
/** /**
* TO BE COMPLETED. * TO BE COMPLETED.
*
* @param interval
* the interval
* @return the string
*/ */
public static String humanString(final long interval) public static String humanString(final long interval)
{ {
@ -95,7 +101,11 @@ public class SimpleChronometer
} }
/** /**
* Short human string.
* *
* @param interval
* the interval
* @return the string
*/ */
public static String shortHumanString(final long interval) public static String shortHumanString(final long interval)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2010, 2013-2016 Christian Pierre MOMON * Copyright (C) 2010,2013-2016,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -22,13 +22,21 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
/** /**
* The Class StacktraceWriter.
*
* @deprecated use <code>SLF4J.Logger.error("blabla", exception)</code> method * @deprecated use <code>SLF4J.Logger.error("blabla", exception)</code> method
* or the ExceptionUtils.getStackTrace(throwable). * or the ExceptionUtils.getStackTrace(throwable).
*/ */
@Deprecated @Deprecated
public class StacktraceWriter public class StacktraceWriter
{ {
/** /**
* To string.
*
* @param exception
* the exception
* @return the string
* @deprecated use <code>SLF4J.Logger.error("blabla", exception)</code> * @deprecated use <code>SLF4J.Logger.error("blabla", exception)</code>
* method or the ExceptionUtils.getStackTrace(throwable). * method or the ExceptionUtils.getStackTrace(throwable).
*/ */

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2008-2010, 2013-2014 Christian Pierre MOMON * Copyright (C) 2008-2010,2013-2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -27,12 +27,19 @@ import org.apache.commons.lang3.StringUtils;
import fr.devinsy.util.strings.StringList; import fr.devinsy.util.strings.StringList;
/** /**
* The Class ToolBox.
* *
* @author christian.momon@devinsy.fr * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class ToolBox public class ToolBox
{ {
/**
* Clean.
*
* @param source
* the source
* @return the string
*/
public static String clean(final String source) public static String clean(final String source)
{ {
String result; String result;
@ -126,10 +133,13 @@ public class ToolBox
} }
/** /**
* Index of.
* *
* @param pattern * @param pattern
* the pattern
* @param source * @param source
* @return * the source
* @return the int
*/ */
public static int indexOf(final String pattern, final List<String> source) public static int indexOf(final String pattern, final List<String> source)
{ {
@ -172,10 +182,13 @@ public class ToolBox
} }
/** /**
* Matches any.
* *
* @param string * @param string
* the string
* @param targets * @param targets
* @return * the targets
* @return true, if successful
*/ */
public static boolean matchesAny(final String string, final String... targets) public static boolean matchesAny(final String string, final String... targets)
{ {
@ -218,8 +231,11 @@ public class ToolBox
} }
/** /**
* Sort.
* *
* @return * @param source
* the source
* @return the double[]
*/ */
public static Double[] sort(final Set<Double> source) public static Double[] sort(final Set<Double> source)
{ {
@ -296,9 +312,11 @@ public class ToolBox
} }
/** /**
* To string.
* *
* @param source * @param source
* @return * the source
* @return the string
*/ */
public static String toString(final String source) public static String toString(final String source)
{ {

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2013 Christian Pierre MOMON * Copyright (C) 2013,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -26,86 +26,89 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.util.FileIterator; import fr.devinsy.util.FileIterator;
/** /**
* * The Class FileIteratorSandbox.
*/ */
public class FileIteratorSandbox public class FileIteratorSandbox
{ {
private static final Logger logger; private static Logger logger;
static static
{ {
// Initialize logger. // Initialize logger.
org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.BasicConfigurator.configure();
org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG); org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
logger = LoggerFactory.getLogger(FileIteratorSandbox.class); logger = LoggerFactory.getLogger(FileIteratorSandbox.class);
// //
org.apache.log4j.Logger defaultLogger = org.apache.log4j.Logger.getRootLogger(); org.apache.log4j.Logger defaultLogger = org.apache.log4j.Logger.getRootLogger();
defaultLogger.removeAllAppenders(); defaultLogger.removeAllAppenders();
defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - dutils [%-5p] %34.34c.%-25M - %m%n"))); defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - dutils [%-5p] %34.34c.%-25M - %m%n")));
// //
logger.debug("Log initialized."); logger.debug("Log initialized.");
} }
/** /**
* The main method.
* *
* @param args
* the arguments
*/ */
public static void main(final String[] args) public static void main(final String[] args)
{ {
test(); test();
} }
/** /**
* * Test.
*/ */
protected static void test() protected static void test()
{ {
System.out.println("user.dir=" + System.getProperty("user.dir")); System.out.println("user.dir=" + System.getProperty("user.dir"));
try try
{ {
// File f = new File("TestTree/DirectoryOne/titi2"); // File f = new File("TestTree/DirectoryOne/titi2");
// File f = new File("/home/cpm/.kde//cache-cpmstar"); // File f = new File("/home/cpm/.kde//cache-cpmstar");
File f = new File("tests/TestTree/xine.jpg"); File f = new File("tests/TestTree/xine.jpg");
System.out.println("exists=" + f.exists()); System.out.println("exists=" + f.exists());
System.out.println("canonical path = " + f.getCanonicalPath()); System.out.println("canonical path = " + f.getCanonicalPath());
System.out.println("absolute path = " + f.getAbsolutePath()); System.out.println("absolute path = " + f.getAbsolutePath());
System.out.println("name = " + f.getName()); System.out.println("name = " + f.getName());
System.out.println("parent = " + f.getParent()); System.out.println("parent = " + f.getParent());
System.out.println("path = " + f.getPath()); System.out.println("path = " + f.getPath());
System.out.println("path = " + f.lastModified()); System.out.println("path = " + f.lastModified());
System.out.println("path = " + f.length()); System.out.println("path = " + f.length());
System.out.println("path = " + f.isFile()); System.out.println("path = " + f.isFile());
System.out.println("path = " + f.isDirectory()); System.out.println("path = " + f.isDirectory());
System.out.println("list = " + f.list()); System.out.println("list = " + f.list());
System.out.println("----"); System.out.println("----");
// FileIterator i = new FileIterator(new File("tests/TestTree")); // FileIterator i = new FileIterator(new File("tests/TestTree"));
FileIterator i = new FileIterator(new File("tests/TestTree/xine.jpg"), null, true); FileIterator i = new FileIterator(new File("tests/TestTree/xine.jpg"), null, true);
// FileIterator i = new FileIterator(new // FileIterator i = new FileIterator(new
// File("/home/cpm/.kde/cache-cpmstar"), ".*cache.*", false); // File("/home/cpm/.kde/cache-cpmstar"), ".*cache.*", false);
// FileIterator i = new FileIterator(new File("tests/TestTree"), // FileIterator i = new FileIterator(new File("tests/TestTree"),
// ".*dsc.*", false); // ".*dsc.*", false);
// FileIterator i = new FileIterator(new // FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/")); // File("/home/cpm/Images/Photos/"));
// FileIterator i = new FileIterator(new // FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/"), ".*\\.(JPG|jpg)", false); // File("/home/cpm/Images/Photos/"), ".*\\.(JPG|jpg)", false);
// FileIterator i = new FileIterator(new // FileIterator i = new FileIterator(new
// File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false); // File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false);
while (i.hasNext()) while (i.hasNext())
{ {
// System.out.println(i.toString()); // System.out.println(i.toString());
System.out.println("File=[" + i.next().getPath() + "]"); System.out.println("File=[" + i.next().getPath() + "]");
} }
i.reset(); i.reset();
System.out.println("Cardinal=" + i.finalCountdown()); System.out.println("Cardinal=" + i.finalCountdown());
} }
catch (Exception exception) catch (Exception exception)
{ {
System.out.println("ERROR:" + exception.getMessage()); System.out.println("ERROR:" + exception.getMessage());
} }
} }
} }

View file

@ -1,3 +1,21 @@
/*
* Copyright (C) 2013,2017 Christian Pierre MOMON
*
* This file is part of Devinsy-utils.
*
* Devinsy-utils 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.
*
* Devinsy-utils 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-utils. If not, see <http://www.gnu.org/licenses/>
*/
import org.junit.Test; import org.junit.Test;
public class Foot1Test public class Foot1Test

View file

@ -1,5 +1,5 @@
/** /*
* Copyright (C) 2014 Christian Pierre MOMON * Copyright (C) 2014,2017 Christian Pierre MOMON
* *
* This file is part of Devinsy-utils. * This file is part of Devinsy-utils.
* *
@ -30,15 +30,17 @@ import org.junit.Test;
import fr.devinsy.util.strings.StringList; import fr.devinsy.util.strings.StringList;
/** /**
* The Class FileToolsTest.
* *
* @author Christian P. Momon * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class FileToolsTest public class FileToolsTest
{ {
static protected org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FileToolsTest.class); public final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FileToolsTest.class);
/** /**
* * Before.
*/ */
@Before @Before
public void before() public void before()
@ -48,13 +50,16 @@ public class FileToolsTest
} }
/** /**
* * Load to string list URL 01.
*/ *
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test @Test
public void loadToStringListURL01() throws IOException public void loadToStringListURL01() throws IOException
{ {
// //
logger.debug("===== test starting..."); this.logger.debug("===== test starting...");
// //
StringList source = FileTools.loadToStringList(FileTools.class.getResource("/fr/devinsy/util/lines.txt")); StringList source = FileTools.loadToStringList(FileTools.class.getResource("/fr/devinsy/util/lines.txt"));
@ -63,18 +68,17 @@ public class FileToolsTest
Assert.assertEquals("trois", source.get(3 - 1)); Assert.assertEquals("trois", source.get(3 - 1));
// //
logger.debug("===== test done."); this.logger.debug("===== test done.");
} }
/** /**
* @throws IOException * Test get extension.
*
*/ */
@Test @Test
public void testGetExtension() public void testGetExtension()
{ {
// //
logger.debug("===== test starting..."); this.logger.debug("===== test starting...");
// //
String extension = FileTools.getExtension("test.ext"); String extension = FileTools.getExtension("test.ext");
@ -83,6 +87,6 @@ public class FileToolsTest
Assert.assertEquals(extension, "ext"); Assert.assertEquals(extension, "ext");
// //
logger.debug("===== test done."); this.logger.debug("===== test done.");
} }
} }