You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by fr...@apache.org on 2009/03/01 01:02:35 UTC
svn commit: r748938 - in /incubator/empire-db/trunk/empire-db/src:
main/java/org/apache/empire/commons/ main/java/org/apache/empire/db/
main/java/org/apache/empire/db/expr/column/
test/java/org/apache/empire/commons/
Author: francisdb
Date: Sun Mar 1 00:02:35 2009
New Revision: 748938
URL: http://svn.apache.org/viewvc?rev=748938&view=rev
Log:
fixed some TODO/FIXME's
cleaning up javadoc
getting rid of unused code
Modified:
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/OptionEntry.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBJoinType.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java
incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/OptionEntryTest.java
incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java Sun Mar 1 00:02:35 2009
@@ -350,10 +350,14 @@
/**
* Generic conversion function that will convert a object to another value type.
- * @param c the value type to convert to
+ *
+ * @param <T> the type to convert to
+ * @param c the class type to convert to
* @param v the object to convert
+ *
* @return the Date value of o or null
- * @throws ClassCastException
+ *
+ * @throws ClassCastException if the object is not null and is not assignable to the type T.
*/
@SuppressWarnings("unchecked")
public static <T> T convert(Class<T> c, Object v)
@@ -410,13 +414,14 @@
/**
* Generic conversion function that will convert a list to another list type.
+ *
+ * @param <T> the type of elements
* @param t the type class
* @param source the source collection
+ *
* @return the new list type
- * @throws ClassCastException
*/
public static <T> List<T> convert(Class<T> t, Collection<? extends T> source)
- throws ClassCastException
{
List<T> target = new ArrayList<T>();
target.addAll(source);
@@ -446,8 +451,11 @@
/**
* returns wheter or not a array contains a certain item
+ *
+ * @param <T> the ype of the objects in the array
* @param array the array to search
* @param item the item to search for
+ *
* @return true if the array contains the item or false otherwise
*/
public static <T> boolean contains(T[] array, T item)
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/OptionEntry.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/OptionEntry.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/OptionEntry.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/OptionEntry.java Sun Mar 1 00:02:35 2009
@@ -41,9 +41,15 @@
return value;
}
+ /**
+ * Gets the value as string
+ *
+ * @return the string representation of the value or an empty string if the value is <code>null</code>
+ */
public String getValueString()
- { // Convenience Function
- return (value!=null ? String.valueOf(value) : "");
+ {
+ // Convenience Function
+ return (value != null ? String.valueOf(value) : "");
}
public String getText()
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java Sun Mar 1 00:02:35 2009
@@ -228,34 +228,34 @@
return buf.toString();
}
+ /**
+ * Checks if a string is empty
+ *
+ * @param s the String to check
+ *
+ * @return true if s is empty or <code>null</code>
+ */
public static boolean isEmpty(String s)
{
- return (s==null || s.trim().length()==0);
+ return (s==null || s.trim().length() == 0);
}
+ /**
+ * Checks if a string is not null or empty
+ *
+ * @param s the string to validate
+ *
+ * @return true if valid
+ */
public static boolean isValid(String s)
{
- return (s!=null && s.trim().length()>0);
- }
-
- public static boolean isEmail(String s)
- {
- int indexOfAtChar = s.indexOf("@");
- if (indexOfAtChar > 0)
- {
- int indexOfDotChar = s.indexOf(".", indexOfAtChar);
- if (indexOfDotChar > 0)
- {
- return true;
- }
- return false;
- }
- return false;
+ return (s != null && s.trim().length() > 0);
}
/**
* Validates a given string. If the string is empty then null is returned.
- * Otherwise the trimmed string is returned.
+ * Otherwise the trimmed string is returned.
+ *
* @param s the string to validate
* @return the string or null if s was empty.
*/
@@ -270,7 +270,7 @@
}
/**
- * Replaces all occances of first character in a string by a string.
+ * Replaces all occurences of find in source by replace.
*
* @param source the original String.
* @param find the String to be replaced
@@ -312,9 +312,9 @@
{
if (source == null)
return null;
- if (find == null)
+ if (find == null || "".equals(find))
{
- find = "";
+ return source;
}
if (replace == null)
{
@@ -356,40 +356,5 @@
return buffer.toString();
}
-
- public static String replaceBRbyLF(String s)
- {
- return replaceAll(replaceAll(s, "<br/>", "\n\n"), "<br />", "\n\n");
- }
-
- public static String trimAll(String orig)
- {
- if (orig == null)
- return null;
- String str = orig.trim();
- StringBuilder strBuf = new StringBuilder(str.length());
- boolean hasSpace = false;
- for (int i = 0, j = 0; i < str.length(); i++)
- {
- if (str.charAt(i) == ' ')
- {
- if (!hasSpace)
- {
- strBuf.append(' ');
- hasSpace = true;
- }
- }
- else
- {
- j = str.indexOf(' ', i);
- if (j == -1)
- j = str.length();
- strBuf.append(str.substring(i, j));
- hasSpace = false;
- i = j - 1;
- }
- }
-
- return strBuf.toString();
- }
+
}
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java Sun Mar 1 00:02:35 2009
@@ -335,6 +335,8 @@
* and returns a parameter object.
*
* @param item the parameter value
+ *
+ * @return the parameter object
*/
public DBCmdParameter addCmdParam(Object item)
{
@@ -372,7 +374,9 @@
*
* @param left the left join value
* @param right the right join
- * @param joinType type of join (INNER, LEFT, RIGHT)
+ * @param joinType type of join ({@link DBJoinType#INNER}, {@link DBJoinType#LEFT}, {@link DBJoinType#RIGHT})
+ *
+ * @return the join expression
*/
public DBJoinExpr join(DBColumnExpr left, DBColumn right, DBJoinType joinType)
{
@@ -386,6 +390,8 @@
*
* @param left the left join value
* @param right the right join
+ *
+ * @return the join expresion
*/
public DBJoinExpr join(DBColumnExpr left, DBColumn right)
{
@@ -395,9 +401,11 @@
/**
* Adds a join based on a compare expression to the command.
*
- * @param rowset table of view which to join
+ * @param rowset table or view to join
* @param cmp the compare expression with wich to join the table
- * @param joinType type of join (INNER, LEFT, RIGHT)
+ * @param joinType type of join ({@link DBJoinType#INNER}, {@link DBJoinType#LEFT}, {@link DBJoinType#RIGHT})
+ *
+ * @return the join expresion
*/
public DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp, DBJoinType joinType)
{
@@ -411,6 +419,8 @@
*
* @param rowset table of view which to join
* @param cmp the compare expression with wich to join the table
+ *
+ * @return the join expresion
*/
public DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp)
{
@@ -435,6 +445,8 @@
* Returns true if the command has a join on the given
* table or false otherwise.
*
+ * @param rowset rowset table or view to join
+ *
* @return true if the command has a join on the given table or false otherwise
*/
public boolean hasJoinOn(DBRowSet rowset)
@@ -856,6 +868,8 @@
/**
* Creates the delete SQL-Command.
*
+ * @param table the table object
+ *
* @return the delete SQL-Command
*/
public String getDelete(DBTable table)
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java Sun Mar 1 00:02:35 2009
@@ -163,7 +163,10 @@
private DBColumnExpr expr;
/**
- * Constructs a new DBCmdColumn object set the specified parameters to this object
+ * Constructs a new DBCmdColumn object
+ *
+ * @param query the row set
+ * @param expr the column
*/
public DBCmdColumn(DBRowSet query, DBColumnExpr expr)
{ // call base
@@ -277,11 +280,14 @@
protected static class DBOrderByInfo extends DBExpr
{
public DBColumnExpr expr;
- public boolean desc;
+ public boolean desc;
/**
* Construct a new DBOrderByInfo object set the specified
* parameters to this object.
+ *
+ * @param expr the column
+ * @param desc set true for descending or false for ascending
*/
public DBOrderByInfo(DBColumnExpr expr, boolean desc)
{
@@ -289,15 +295,17 @@
this.desc = desc;
}
- /** Returns the current database object */
+ /**
+ * Returns the current database object
+ */
@Override
public DBDatabase getDatabase()
{
return expr.getDatabase();
}
- /**
- * @see org.apache.empire.db.DBExpr#addColumns(List)
+ /*
+ * @see org.apache.empire.db.DBExpr#addReferencedColumns(Set)
*/
@Override
public void addReferencedColumns(Set<DBColumn> list)
@@ -313,10 +321,14 @@
*/
@Override
public void addSQL(StringBuilder buf, long context)
- { // Set SQL-Order By
+ {
+ // Set SQL-Order By
expr.addSQL(buf, context);
+ // only need to add DESC as default is ASC
if (desc)
+ {
buf.append(" DESC");
+ }
}
}
@@ -444,7 +456,7 @@
}
/**
- * Creates a new DBOrderByInfo object and add it to the Vector 'orderBy'.
+ * Adds an order by with ascending or descending order
*
* @param expr the DBColumnExpr object
* @param desc if true, the results from select statement will sort top down
@@ -458,9 +470,9 @@
}
/**
- * This helper function calls the method orderBy(DBColumnExpr, boolean)
- * and sets the second parameter to false,creates a new
- * DBOrderByInfo object and adds it to the Vector 'orderBy'.
+ * Adds an order by with ascending order
+ *
+ * @param expr the column
*
* @see org.apache.empire.db.DBCommandExpr#orderBy(DBColumnExpr, boolean)
*/
@@ -508,6 +520,9 @@
* Create the insert into SQL-Command which copies
* data from a select statement to a destination table.
*
+ * @param table the table
+ * @param columns the columns
+ *
* @return the insert into SQL-Command
*/
public final String getInsertInto(DBTable table, List<DBColumnExpr> columns)
@@ -519,6 +534,8 @@
* Create the insert into SQL-Command which copies
* data from a select statement to a destination table.
*
+ * @param table the table
+ *
* @return the insert into SQL-Command
*/
public final String getInsertInto(DBTable table)
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java Sun Mar 1 00:02:35 2009
@@ -785,8 +785,11 @@
* Returns a one dimensional array from an sql query.
* The array is filled with the values of the first column.
*
+ * @param c the class type for the list
+ * @param <T> the type for th list
* @param sqlCmd the SQL statement
* @param conn a valid connection to the database.
+ *
* @return a list of the values of the first column of an sql query
*/
public <T> List<T> querySimpleList(Class<T> c, String sqlCmd, Connection conn)
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBIndex.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBIndex.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBIndex.java Sun Mar 1 00:02:35 2009
@@ -28,8 +28,20 @@
public class DBIndex extends DBObject
{
// Index Types
+ // TODO convert to an enum?
+ /**
+ * SQL Standard index
+ */
public static final int STANDARD = 0;
+
+ /**
+ * SQL Unique index
+ */
public static final int UNIQUE = 1;
+
+ /**
+ * SQL Primary key index
+ */
public static final int PRIMARYKEY = 2;
private String name;
@@ -88,7 +100,9 @@
}
/**
- * Returns the primary key type (only PRIMARYKEY).
+ * Returns the index type.
+ *
+ * @return the type of this index ({@link #PRIMARYKEY}, {@link #UNIQUE}, {@link #STANDARD})
*/
public int getType()
{
@@ -96,7 +110,11 @@
}
/**
- * Returns true if a specified DBColumn object exits in the internal DBColumn vector.
+ * Checks if this index contains the column col
+ *
+ * @param col the column
+ *
+ * @return true if this index contains this column
*/
public boolean contains(DBColumn col)
{
@@ -108,6 +126,10 @@
/**
* Gets the position of a specified DBColumn object.
+ *
+ * @param col the column
+ *
+ * @return the position or -1 if the column was not found
*/
public int getColumnPos(DBColumn col)
{
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBJoinType.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBJoinType.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBJoinType.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBJoinType.java Sun Mar 1 00:02:35 2009
@@ -26,17 +26,32 @@
*/
public enum DBJoinType
{
+ /**
+ * SQL Left join
+ */
LEFT, // =-1,
+
+ /**
+ * SQL Inner join
+ */
INNER, // = 0,
+
+ /**
+ * SQL Right join
+ */
RIGHT; // = 1
public static DBJoinType reversed(DBJoinType type)
{
switch(type)
{
- case LEFT: return RIGHT;
- case RIGHT: return LEFT;
- default: return type; // no change
+ case LEFT:
+ return RIGHT;
+ case RIGHT:
+ return LEFT;
+ default:
+ // no change
+ return type;
}
}
}
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java Sun Mar 1 00:02:35 2009
@@ -376,7 +376,11 @@
}
}
- /** returns null true if the Rowset is not null, and otherwise false */
+ /**
+ * Checks if the rowset is open
+ *
+ * @return true if the rowset is open
+ */
public boolean isOpen()
{
return (rset != null);
@@ -486,6 +490,8 @@
/**
* Moves the cursor down the given number of rows.
*
+ * @param count the number of rows to skip
+ *
* @return true if the reader is on a valid record or false otherwise
*/
public boolean skipRows(int count)
@@ -619,6 +625,12 @@
/**
* Returns the result of a query as a list of objects resticted
* to a maximum number of objects (unless maxCount is -1).
+ *
+ * @param c the class type of the objects in the list
+ * @param maxCount the maximum number of objects
+ * @param <T> the type of the objects in the list
+ *
+ * @return the list of <T>
*/
@SuppressWarnings("unchecked")
public <T> ArrayList<T> getBeanList(Class<T> c, int maxCount)
@@ -681,6 +693,11 @@
/**
* Returns the result of a query as a list of objects.
+ *
+ * @param c the class type of the objects in the list
+ * @param <T> the type of the objects in the list
+ *
+ * @return the list of <T>
*/
public <T> ArrayList<T> getBeanList(Class<T> c)
{
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java Sun Mar 1 00:02:35 2009
@@ -46,12 +46,16 @@
*/
public class DBRecord extends DBRecordData implements Record, Cloneable
{
+ /*
+ * TODO convert to an enum?
+ */
public static final int REC_INVALID = -1;
public static final int REC_EMTPY = 0;
public static final int REC_VALID = 1;
public static final int REC_MODIFIED = 2;
public static final int REC_NEW = 3;
+ @SuppressWarnings("hiding")
protected static final Log log = LogFactory.getLog(DBRecord.class);
// This is the record data
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Sun Mar 1 00:02:35 2009
@@ -180,6 +180,8 @@
/**
* Gets the column Expression with a particular name.
*
+ * @param name the name of the column to look for
+ *
* @return the column Expression at position
*/
public DBColumn getColumn(String name)
@@ -198,6 +200,8 @@
* Only the timestamp column is read only by default.
* The primary is read only if the column is of type.
*
+ * @param col the column object
+ *
* @return a new DBCountExpr object
*/
public boolean isColumnReadOnly(DBColumn col)
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java Sun Mar 1 00:02:35 2009
@@ -62,6 +62,8 @@
/**
* Construct a new DBValueExpr object set the specified parameters to this object.
+ * @param col the column
+ * @param value the value
*/
public DBValueExpr(DBColumnExpr col, Object value)
{
Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/OptionEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/OptionEntryTest.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/OptionEntryTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/OptionEntryTest.java Sun Mar 1 00:02:35 2009
@@ -36,7 +36,6 @@
@Test
public void testGetValueString()
{
- // TODO add javadoc to this method
OptionEntry entry = new OptionEntry(Boolean.TRUE, "junit");
assertEquals("true", entry.getValueString());
entry = new OptionEntry(null, "junit");
Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java?rev=748938&r1=748937&r2=748938&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java Sun Mar 1 00:02:35 2009
@@ -114,7 +114,7 @@
@Test
public void testStringToArray()
{
- // TODO see if we want to always return empty arrays instead od nulls
+ // TODO see if we want to always return empty arrays instead of nulls
assertArrayEquals(null, StringUtils.stringToArray(null , null));
assertArrayEquals(null, StringUtils.stringToArray("first null second" , null));
assertArrayEquals(null, StringUtils.stringToArray(null , "/"));
@@ -148,7 +148,6 @@
@Test
public void testIsEmpty()
{
- // TODO add javadoc to this method
assertTrue(StringUtils.isEmpty(null));
assertTrue(StringUtils.isEmpty(""));
assertTrue(StringUtils.isEmpty("\t\r\n"));
@@ -158,8 +157,6 @@
@Test
public void testIsValid()
{
- // TODO add javadoc to this method
- // TODO change implementation to ! isEmpty()
assertFalse(StringUtils.isValid(null));
assertFalse(StringUtils.isValid(""));
assertFalse(StringUtils.isValid("\t\r\n"));
@@ -167,19 +164,6 @@
}
@Test
- public void testIsEmail()
- {
- // TODO add javadoc to this method + add possible nullpointer info or fix
- // assertFalse(StringUtils.isEmail(null));
- assertFalse(StringUtils.isEmail(""));
- assertFalse(StringUtils.isEmail("@"));
- assertTrue(StringUtils.isEmail("f@f.f"));
- // FIXME these should return false (use regex?)
- assertTrue(StringUtils.isEmail(" @. "));
- assertTrue(StringUtils.isEmail("user@site@site.com"));
- }
-
- @Test
public void testValidate()
{
assertEquals(null, StringUtils.validate(null));
@@ -191,12 +175,12 @@
@Test
public void testReplace()
{
- // TODO fix javadoc spelling
assertEquals(null, StringUtils.replace(null, null, null));
assertEquals("", StringUtils.replace("", null, null));
assertEquals("test null test", StringUtils.replace("test null test", null, ""));
assertEquals("test test", StringUtils.replace("test a test", "a", null));
assertEquals("test test", StringUtils.replace("test test", "", "oops"));
+ assertEquals("test test", StringUtils.replaceAll("test test", null, "oops"));
assertEquals("testoopsoopstest", StringUtils.replace("test test", " ", "oops"));
assertEquals("1-two-3", StringUtils.replace("1 2 3", " 2 ", "-two-"));
}
@@ -204,37 +188,15 @@
@Test
public void testReplaceAll()
{
- // TODO what is the difference with the other replace method???
+ // TODO what is the difference with the other replace method, merge???
assertEquals(null, StringUtils.replaceAll(null, null, null));
assertEquals("", StringUtils.replaceAll("", null, null));
assertEquals("test null test", StringUtils.replaceAll("test null test", null, ""));
assertEquals("test test", StringUtils.replaceAll("test a test", "a", null));
- // FIXME this causes a OutOfMemoryError: Java heap space
- // assertEquals("test test", StringUtils.replaceAll("test test", "", "oops"));
+ assertEquals("test test", StringUtils.replaceAll("test test", "", "oops"));
+ assertEquals("test test", StringUtils.replaceAll("test test", null, "oops"));
assertEquals("testoopsoopstest", StringUtils.replaceAll("test test", " ", "oops"));
assertEquals("1-two-3", StringUtils.replaceAll("1 2 3", " 2 ", "-two-"));
}
- @Test
- public void testReplaceBRbyLF()
- {
- // TODO add javadoc and specify that only xhtml br's are supported
- // indicate a doule lf is added
- assertEquals(null, StringUtils.replaceBRbyLF(null));
- assertEquals("", StringUtils.replaceBRbyLF(""));
- assertEquals(" <br> ", StringUtils.replaceBRbyLF(" <br> "));
- assertEquals(" \n\n ", StringUtils.replaceBRbyLF(" <br /> "));
- assertEquals(" \n\n ", StringUtils.replaceBRbyLF(" <br/> "));
- assertEquals(" \n\n \n\n\n", StringUtils.replaceBRbyLF(" <br/> <br />\n"));
- }
-
- @Test
- public void testTrimAll()
- {
- // TODO add javadoc to this method, what does this method do??
- assertEquals(null, StringUtils.trimAll(null));
- assertEquals("", StringUtils.trimAll(" \t \r \n "));
- assertEquals("a\r \t b", StringUtils.trimAll(" \t a\r \t b \n "));
- }
-
}