Commit 06cf653d authored by Christian P. MOMON's avatar Christian P. MOMON
Browse files

Peformed a code review and Javadoc review.

parent 0845ab52
/**
/*
* Copyright (C) 2013-2017 Christian Pierre MOMON
*
* This file is part of devinsy-strings.
......@@ -21,14 +21,14 @@ package fr.devinsy.util.strings;
import java.util.Comparator;
/**
*
* The Class StringLengthComparator.
*/
public class StringLengthComparator implements Comparator<String>
{
private static StringLengthComparator instance;
/**
*
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(final String alpha, final String bravo)
......@@ -39,13 +39,10 @@ public class StringLengthComparator implements Comparator<String>
Integer alphaValue;
if (alpha == null)
{
//
alphaValue = null;
}
else
{
//
alphaValue = alpha.length();
}
......@@ -53,13 +50,10 @@ public class StringLengthComparator implements Comparator<String>
Integer bravoValue;
if (bravo == null)
{
//
bravoValue = null;
}
else
{
//
bravoValue = bravo.length();
}
......@@ -98,25 +92,18 @@ public class StringLengthComparator implements Comparator<String>
//
if ((alpha == null) && (bravo == null))
{
//
result = 0;
}
else if (alpha == null)
{
//
result = -1;
}
else if (bravo == null)
{
//
result = +1;
}
else
{
//
result = alpha.compareTo(bravo);
}
......@@ -125,8 +112,9 @@ public class StringLengthComparator implements Comparator<String>
}
/**
* Instance.
*
* @return
* @return the string length comparator
*/
public static StringLengthComparator instance()
{
......
/**
* Copyright (C) 2008-2010 Christian Pierre MOMON
* Copyright (C) 2013-2015 Christian Pierre MOMON
* Copyright (C) 2017 Christian Pierre MOMON
/*
* Copyright (C) 2008-2010,2013-2015,2017 Christian Pierre MOMON
*
* This file is part of devinsy-strings.
*
......@@ -323,9 +321,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param string
* @return
* the string
* @return the string list
*/
public StringList appendln(final Collection<String> string)
{
......@@ -338,9 +338,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param value
* @return
* the value
* @return the string list
*/
public StringList appendln(final double value)
{
......@@ -353,9 +355,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param value
* @return
* the value
* @return the string list
*/
public StringList appendln(final int value)
{
......@@ -368,9 +372,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param value
* @return
* the value
* @return the string list
*/
public StringList appendln(final long value)
{
......@@ -383,9 +389,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param value
* @return
* the value
* @return the string list
*/
public StringList appendln(final Object value)
{
......@@ -398,9 +406,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param value
* @return
* the value
* @return the string list
*/
public StringList appendln(final short value)
{
......@@ -413,9 +423,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param string
* @return
* the string
* @return the string list
*/
public StringList appendln(final String string)
{
......@@ -428,9 +440,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Appendln.
*
* @param strings
* @return
* the strings
* @return the string list
*/
public StringList appendln(final String... strings)
{
......@@ -461,9 +475,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Char at.
*
* @param position
* @return
* the position
* @return the char
*/
public char charAt(final StringListCharPosition position)
{
......@@ -480,7 +496,7 @@ public class StringList extends ArrayList<String> implements CharSequence
* Deep copy and shallow copy have no sense about a list of immutable
* objects.
*
* @return
* @return the string list
*/
@Override
public StringList clone()
......@@ -499,9 +515,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Contains any.
*
* @param source
* @return
* @param target
* the target
* @return true, if successful
*/
public boolean containsAny(final Collection<String> target)
{
......@@ -541,9 +559,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Contains any.
*
* @param source
* @return
* @param target
* the target
* @return true, if successful
*/
public boolean containsAny(final String... target)
{
......@@ -587,8 +607,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Contains blank.
*
* @return
* @return true, if successful
*/
public boolean containsBlank()
{
......@@ -621,8 +642,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Contains empty.
*
* @return
* @return true, if successful
*/
public boolean containsEmpty()
{
......@@ -655,8 +677,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Contains null.
*
* @return
* @return true, if successful
*/
public boolean containsNull()
{
......@@ -689,9 +712,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the by index.
*
* @param id
* @return
* the id
* @return the by index
*/
public String getByIndex(final int id)
{
......@@ -704,8 +729,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the first.
*
* @return
* @return the first
*/
public String getFirst()
{
......@@ -746,8 +772,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the longest bytes line.
*
* @return
* @return the longest bytes line
*/
public String getLongestBytesLine()
{
......@@ -776,8 +803,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the longest line.
*
* @return
* @return the longest line
*/
public String getLongestLine()
{
......@@ -806,8 +834,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the not blank.
*
* @return
* @return the not blank
*/
public StringList getNotBlank()
{
......@@ -828,8 +857,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the not empty.
*
* @return
* @return the not empty
*/
public StringList getNotEmpty()
{
......@@ -850,8 +880,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the not null.
*
* @return
* @return the not null
*/
public StringList getNotNull()
{
......@@ -872,8 +903,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the shortest bytes line.
*
* @return
* @return the shortest bytes line
*/
public String getShortestBytesLine()
{
......@@ -902,8 +934,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Gets the shortest line.
*
* @return
* @return the shortest line
*/
public String getShortestLine()
{
......@@ -932,9 +965,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Index of.
*
* @param index
* @return
* the index
* @return the string list char position
*/
public StringListCharPosition indexOf(final int index)
{
......@@ -971,8 +1006,10 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Index of next line not null.
*
* @param startIndex
* the start index
* @return the index of the next line not null, -1 otherwise.
*/
public int indexOfNextLineNotNull(final int startIndex)
......@@ -1008,9 +1045,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Checks if is out of bounds.
*
* @param position
* @return
* the position
* @return true, if is out of bounds
*/
public boolean isOutOfBounds(final StringListCharPosition position)
{
......@@ -1041,9 +1080,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Checks if is out of line.
*
* @param position
* @return
* the position
* @return true, if is out of line
*/
public boolean isOutOfLine(final StringListCharPosition position)
{
......@@ -1070,9 +1111,11 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Checks if is out of list.
*
* @param position
* @return
* the position
* @return true, if is out of list
*/
public boolean isOutOfList(final StringListCharPosition position)
{
......@@ -1099,7 +1142,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* Iterator of char.
*
* @return the iterator
*/
public Iterator<Character> iteratorOfChar()
{
......@@ -1114,6 +1159,8 @@ public class StringList extends ArrayList<String> implements CharSequence
/**
* Returns the length of the string list concatenation. Null strings are
* ignored.
*
* @return the int
*/
@Override
public int length()
......@@ -1137,7 +1184,7 @@ public class StringList extends ArrayList<String> implements CharSequence
* operation, the new string is the first of the list and the size list is
* 1.
*
* @return
* @return the string list
*/
public StringList merge()
{
......@@ -1402,11 +1449,15 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* To string.
*
* @param prefix
* the prefix
* @param separator
* @param postifx
* @return
* the separator
* @param postfix
* the postfix
* @return the string
*/
public String toString(final String prefix, final String separator, final String postfix)
{
......@@ -1439,7 +1490,7 @@ public class StringList extends ArrayList<String> implements CharSequence
* Returns an array containing all of the strings in this list in proper
* sequence (from first to last element).
*
* @return
* @return the string[]
*/
public String[] toStringArray()
{
......@@ -1462,8 +1513,8 @@ public class StringList extends ArrayList<String> implements CharSequence
* concatenated too.
*
* @param separator
*
* @return
* the separator
* @return the string
*/
public String toStringSeparatedBy(final String separator)
{
......@@ -1489,9 +1540,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* To string with bracket.
*
* @param strings
* @return
* @return the string
*/
public String toStringWithBracket()
{
......@@ -1504,9 +1555,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* To string with brackets.
*
* @param source
* @return
* @return the string
*/
public String toStringWithBrackets()
{
......@@ -1526,8 +1577,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* To string with commas.
*
* @return
* @return the string
*/
public String toStringWithCommas()
{
......@@ -1540,8 +1592,9 @@ public class StringList extends ArrayList<String> implements CharSequence
}
/**
* To string with french commas.
*
* @return
* @return the string
*/
public String toStringWithFrenchCommas()
{
......@@ -1558,8 +1611,8 @@ public class StringList extends ArrayList<String> implements CharSequence
*
* @param out
* The {@code PrintWriter} where to write.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public void writeInto(final java.io.PrintWriter out) throws IOException
{
......@@ -1574,8 +1627,8 @@ public class StringList extends ArrayList<String> implements CharSequence
*
* @param out
* The {@code Writer} where to write.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public void writeInto(final java.io.Writer out) throws IOException
{
......
/**
* Copyright (C) 2014-2015 Christian Pierre MOMON
* Copyright (C) 2017 Christian Pierre MOMON
/*
* Copyright (C) 2014-2015,2017 Christian Pierre MOMON
*
* This file is part of devinsy-strings.
*
......@@ -22,16 +21,18 @@ package fr.devinsy.util.strings;
import java.util.Iterator;
/**
*
* The Class StringListCharIterator.
*/
public class StringListCharIterator implements Iterator<Character>
{
private StringList source;
private StringListCharPosition currentPosition;
private StringListCharPosition nextPosition;
/**
*
* Instantiates a new string list char iterator.
*
* @param source
* the source
*/
public StringListCharIterator(final StringList source)
{
......@@ -41,8 +42,8 @@ public class StringListCharIterator implements Iterator<Character>
this.nextPosition = new StringListCharPosition();
}
/**
*
/* (non-Javadoc)
* @see java.util.Iterator#hasNext()
*/
@Override
public boolean hasNext()
......@@ -69,8 +70,8 @@ public class StringListCharIterator implements Iterator<Character>
return result;
}
/**
*
/* (non-Javadoc)
* @see java.util.Iterator#next()
*/
@Override
public Character next()
......@@ -110,8 +111,9 @@ public class StringListCharIterator implements Iterator<Character>
}
/**
* Next position.
*
* @return
* @return the string list char position
*/
public StringListCharPosition nextPosition()
{
......
/**
* Copyright (C) 2013-2015 Christian Pierre MOMON
* Copyright (C) 2017 Christian Pierre MOMON
/*
* Copyright (C) 2013-2015,2017 Christian Pierre MOMON
*
* This file is part of devinsy-strings.
*
......@@ -31,10 +30,7 @@ public class StringListCharPosition
private int localCharIndex;
/**
*
* @param index
* @param stringIndex
* @param localIndex
* Instantiates a new string list char position.
*/
public StringListCharPosition()
{
......@@ -44,10 +40,14 @@ public class StringListCharPosition
}
/**