hammant 01/11/17 00:52:57
Modified: apps/db/src/java/org/apache/avalon/db/functions
Function.java
apps/db/src/java/org/apache/avalon/db/functions/impl
AbstractFunction.java ConcatFunction.java
Added: apps/db/src/java/org/apache/avalon/db/data/impl
AbstractContrivedColumn.java
ContrivedStringFunctionColumn.java
StringConstantColumn.java
apps/db/src/java/org/apache/avalon/db/functions
NumericFunction.java StringFunction.java
TemporalFunction.java
apps/db/src/java/org/apache/avalon/db/functions/impl
AbstractStringFunction.java
LowerCaseStringFunction.java SubStringFunction.java
TrimStringFunction.java
UpperCaseStringFunction.java
Removed: apps/db/src/java/org/apache/avalon/db/data/impl
ConcatVarCharColumn.java
Log:
column rework and new functions
Revision Changes Path
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractContrivedColumn.java
Index: AbstractContrivedColumn.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.data.impl;
import org.apache.avalon.db.data.Table;
import org.apache.avalon.db.data.Queryable;
import org.apache.avalon.db.data.Column;
import org.apache.avalon.db.data.Row;
/**
* Class AbstractColumn
*
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>*
* @version $Revision: 1.1 $
*/
public abstract class AbstractContrivedColumn extends AbstractColumn {
public static int MGENCOL = 0;
public AbstractContrivedColumn(String name, String sqlType, String
javaType) {
super(name,sqlType,javaType);
}
protected static String getNameOfColumn(String namePassedIn) {
if (namePassedIn == null) {
return "COL" + MGENCOL++;
} else {
return namePassedIn;
}
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/ContrivedStringFunctionColumn.java
Index: ContrivedStringFunctionColumn.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.data.impl;
import org.apache.avalon.db.data.types.StringType;
import org.apache.avalon.db.data.ValidationException;
import org.apache.avalon.db.data.Row;
import org.apache.avalon.db.functions.StringFunction;
import org.apache.avalon.db.actions.ActionException;
/**
* Class ContrivedStringFunctionColumn
*
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class ContrivedStringFunctionColumn extends AbstractContrivedColumn
implements StringType {
StringFunction mStringFunction;
/**
* Constructor ContrivedStringFunctionColumn
*
*
* @param name
* @param stringFunction
*
*/
public ContrivedStringFunctionColumn(String name, StringFunction
stringFunction) throws ActionException {
super(getNameOfColumn(name),"varchar",String.class.getName());
mStringFunction = stringFunction;
}
public Object getValue(Row row) {
return mStringFunction.getValue(row);
}
public void test(Object obj) throws ValidationException {
throw new ValidationException("ContrivedStringFunctionColumn is not
settable");
}
public Object convertFromString(String str) throws ValidationException {
test(str);
return str;
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/StringConstantColumn.java
Index: StringConstantColumn.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.data.impl;
import org.apache.avalon.db.data.ValidationException;
import org.apache.avalon.db.data.types.StringType;
/**
* Class StringConstantColumn
*
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>*
* @version $Revision: 1.1 $
*/
public class StringConstantColumn extends AbstractColumn implements
StringType {
private String mStrConstant;
/**
* Constructor StringConstantColumn
*
*
* @param name
* @param strConstant
*
*/
public StringConstantColumn(String name, String strConstant) {
super(name,"varchar",String.class.getName());
mStrConstant = strConstant;
}
public void test(Object obj) throws ValidationException {
throw new ValidationException("StringConstantColumn is not settable");
}
public Object convertFromString(String str) throws ValidationException {
test(str);
return str;
}
}
1.6 +3 -1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/Function.java
Index: Function.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/Function.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Function.java 2001/11/14 18:35:31 1.5
+++ Function.java 2001/11/17 08:52:56 1.6
@@ -11,11 +11,13 @@
import org.apache.avalon.db.data.Column;
import org.apache.avalon.db.data.Row;
+
/**
* Interface Function
*
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
- * @version * $Revision: 1.5 $
+ * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
+ * @version * $Revision: 1.6 $
*/
public interface Function {
void initialize(Column[] columns) throws ActionException;
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/NumericFunction.java
Index: NumericFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions;
import org.apache.avalon.db.data.Row;
import java.util.Properties;
/**
* Interface NumericFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version * $Revision: 1.1 $
*/
public interface NumericFunction extends Function {
int getIntValue(Row row);
long getLongValue(Row row);
float getFloatValue(Row row);
double getDoubleValue(Row row);
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/StringFunction.java
Index: StringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions;
import org.apache.avalon.db.data.Row;
import java.util.Properties;
/**
* Interface StringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version * $Revision: 1.1 $
*/
public interface StringFunction extends Function {
String getStringValue(Row row);
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/TemporalFunction.java
Index: TemporalFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions;
import org.apache.avalon.db.data.Row;
import java.util.Properties;
/**
* Interface TemporalFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version * $Revision: 1.1 $
*/
public interface TemporalFunction extends Function {
// note months begin at one not zero like in Java.
int getMonthValue(Row row);
int getDayValue(Row row);
int getYearValue(Row row);
int getHourValue(Row row);
int getMinuteValue(Row row);
int getSecondValue(Row row);
int getCenturyValue(Row row);
}
1.3 +2 -2
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractFunction.java
Index: AbstractFunction.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractFunction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractFunction.java 2001/11/14 18:35:31 1.2
+++ AbstractFunction.java 2001/11/17 08:52:57 1.3
@@ -12,12 +12,12 @@
import org.apache.avalon.db.actions.ActionException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
/**
* Class AbstractFunction
*
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
- * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public abstract class AbstractFunction extends AbstractLogEnabled implements
Function {
protected Column[] mColumns;
1.2 +4 -2
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/ConcatFunction.java
Index: ConcatFunction.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/ConcatFunction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConcatFunction.java 2001/11/14 18:35:31 1.1
+++ ConcatFunction.java 2001/11/17 08:52:57 1.2
@@ -8,16 +8,18 @@
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.data.Row;
+import org.apache.avalon.db.functions.StringFunction;
/**
* Class ConcatFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class ConcatFunction extends AbstractFunction {
- public Object getValue(Row row) {
+public class ConcatFunction extends AbstractStringFunction {
+
+ public String getStringValue(Row row) {
String retVal = "";
for (int i = 0; i < mColumns.length; i++) {
retVal += mColumns[i].getValue(row);
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractStringFunction.java
Index: AbstractStringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.functions.StringFunction;
import org.apache.avalon.db.data.Row;
/**
* Class AbstractStringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractStringFunction extends AbstractFunction
implements StringFunction {
public final Object getValue(Row row) {
return getStringValue(row);
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/LowerCaseStringFunction.java
Index: LowerCaseStringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.data.Row;
import org.apache.avalon.db.functions.StringFunction;
import java.util.Locale;
/**
* Class LowerCaseStringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class LowerCaseStringFunction extends AbstractStringFunction {
private final Locale mLocale;
public LowerCaseStringFunction(Locale locale) {
mLocale = locale;
}
public String getStringValue(Row row) {
return ((String) mColumns[0].getValue(row)).toLowerCase(mLocale);
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/SubStringFunction.java
Index: SubStringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.data.Row;
import org.apache.avalon.db.functions.StringFunction;
/**
* Class SubStringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class SubStringFunction extends AbstractStringFunction {
private final int mFrom;
private final int mLen;
public SubStringFunction(int from , int len) {
mFrom = from;
mLen = len;
}
public String getStringValue(Row row) {
final String val = mColumns[0].getValue(row).toString();
final int start = mFrom -1;
int end = mFrom + mLen - 1;
if (end > val.length()) {
return val.substring(start,val.length());
} else {
return val.substring(start,end);
}
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/TrimStringFunction.java
Index: TrimStringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.data.Row;
import org.apache.avalon.db.functions.StringFunction;
import java.util.Locale;
/**
* Class TrimStringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class TrimStringFunction extends AbstractStringFunction {
public String getStringValue(Row row) {
return ((String) mColumns[0].getValue(row)).trim();
}
}
1.1
jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/UpperCaseStringFunction.java
Index: UpperCaseStringFunction.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.db.functions.impl;
import org.apache.avalon.db.data.Row;
import org.apache.avalon.db.functions.StringFunction;
import java.util.Locale;
/**
* Class UpperCaseStringFunction
*
* @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class UpperCaseStringFunction extends AbstractStringFunction {
private final Locale mLocale;
public UpperCaseStringFunction(Locale locale) {
mLocale = locale;
}
public String getStringValue(Row row) {
return ((String) mColumns[0].getValue(row)).toUpperCase(mLocale);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>