Cleanup and making it called 'PrimitiveValue' rather than 'LeafValue'

master
Oliver Kennedy 2015-05-25 16:50:17 -04:00
parent 2eecfde84a
commit 03c54a5a06
19 changed files with 188 additions and 179 deletions

View File

@ -26,7 +26,7 @@ package net.sf.jsqlparser.expression;
/**
* Every number without a point or an exponential format is a LongValue
*/
public class BooleanValue implements LeafValue {
public class BooleanValue implements PrimitiveValue {
private boolean value;
private BooleanValue(boolean value) { this.value = value; }

View File

@ -28,7 +28,7 @@ import java.text.SimpleDateFormat;
/**
* A Date in the form {d 'yyyy-mm-dd'}
*/
public class DateValue implements Expression, LeafValue {
public class DateValue implements Expression, PrimitiveValue {
private Date value;
public DateValue(String value) {
@ -62,8 +62,10 @@ public class DateValue implements Expression, LeafValue {
return value.toString();
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public double toDouble() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public boolean equals(Object o){
try {

View File

@ -25,7 +25,7 @@ package net.sf.jsqlparser.expression;
/**
* Every number with a point or a exponential format is a DoubleValue
*/
public class DoubleValue implements Expression, LeafValue {
public class DoubleValue implements Expression, PrimitiveValue {
private double value;
public DoubleValue(double value) { this.value = value; }
@ -54,7 +54,8 @@ public class DoubleValue implements Expression, LeafValue {
return ""+value;
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() { return getValue(); }
public boolean equals(Object o){

View File

@ -1,15 +0,0 @@
package net.sf.jsqlparser.expression;
/**
* A terminal expression that can not be evaluated further (e.g., a Number or String)
*/
public interface LeafValue {
public class InvalidLeaf extends Exception {}
public long toLong() throws InvalidLeaf;
public double toDouble() throws InvalidLeaf;
}

View File

@ -25,7 +25,7 @@ package net.sf.jsqlparser.expression;
/**
* Every number without a point or an exponential format is a LongValue
*/
public class LongValue implements Expression, LeafValue {
public class LongValue implements Expression, PrimitiveValue {
private long value;
public LongValue(long value) { this.value = value; }

View File

@ -25,7 +25,7 @@ package net.sf.jsqlparser.expression;
/**
* A "NULL" in a sql statement
*/
public class NullValue implements Expression, LeafValue {
public class NullValue implements Expression, PrimitiveValue {
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}
@ -34,8 +34,10 @@ public class NullValue implements Expression, LeafValue {
return "NULL";
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public double toDouble() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public boolean equals(Object o){
return false;

View File

@ -0,0 +1,15 @@
package net.sf.jsqlparser.expression;
/**
* A terminal expression that can not be evaluated further (e.g., a Number or String)
*/
public interface PrimitiveValue {
public class InvalidPrimitive extends Exception {}
public long toLong() throws InvalidPrimitive;
public double toDouble() throws InvalidPrimitive;
}

View File

@ -25,7 +25,7 @@ package net.sf.jsqlparser.expression;
/**
* A string as in 'example_string'
*/
public class StringValue implements Expression, LeafValue {
public class StringValue implements Expression, PrimitiveValue {
private String value = "";
public StringValue(String escapedValue) {
@ -61,8 +61,10 @@ public class StringValue implements Expression, LeafValue {
return "'"+value+"'";
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public double toDouble() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public boolean equals(Object o){
try {

View File

@ -28,7 +28,7 @@ import java.sql.Time;
/**
* A Time in the form {t 'hh:mm:ss'}
*/
public class TimeValue implements Expression, LeafValue {
public class TimeValue implements Expression, PrimitiveValue {
private Time value;
public TimeValue(String value) {
@ -52,8 +52,10 @@ public class TimeValue implements Expression, LeafValue {
return "{t '"+value+"'}";
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public double toDouble() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public boolean equals(Object o){
try {

View File

@ -28,7 +28,7 @@ import java.sql.Timestamp;
/**
* A Timestamp in the form {ts 'yyyy-mm-dd hh:mm:ss.f . . .'}
*/
public class TimestampValue implements Expression, LeafValue {
public class TimestampValue implements Expression, PrimitiveValue {
private Timestamp value;
public TimestampValue(String value) {
@ -52,8 +52,10 @@ public class TimestampValue implements Expression, LeafValue {
return "{ts '"+value+"'}";
}
public long toLong() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public double toDouble() throws LeafValue.InvalidLeaf { throw new LeafValue.InvalidLeaf(); }
public long toLong() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public double toDouble() throws PrimitiveValue.InvalidPrimitive
{ throw new PrimitiveValue.InvalidPrimitive(); }
public boolean equals(Object o){
try {

View File

@ -1,24 +1,24 @@
/* Generated By:JavaCC: Do not edit this line. CCJSqlParser.java */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
@ -99,8 +99,8 @@ import net.sf.jsqlparser.statement.select.WithItem;
import net.sf.jsqlparser.statement.truncate.Truncate;
import net.sf.jsqlparser.statement.update.Update;
/**
* The parser generated by JavaCC
/**
* The parser generated by JavaCC
*/
public class CCJSqlParser implements CCJSqlParserConstants {

View File

@ -1,24 +1,24 @@
/* Generated By:JavaCC: Do not edit this line. CCJSqlParserConstants.java */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -1,24 +1,24 @@
/* Generated By:JavaCC: Do not edit this line. CCJSqlParserTokenManager.java */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -1,25 +1,25 @@
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -1,25 +1,25 @@
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -1,25 +1,25 @@
/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -1,25 +1,25 @@
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
/* JavaCCOptions: */
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
/* ================================================================
* JSQLParser : java based sql parser
* ================================================================
*
* Project Info: http://jsqlparser.sourceforge.net
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it);
*
* (C) Copyright 2004, by Leonardo Francalanci
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

View File

@ -2,8 +2,6 @@ package net.sf.jsqlparser.statement.create.table;
import java.util.List;
import sun.net.www.content.text.PlainTextInputStream;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.select.PlainSelect;

View File

@ -175,7 +175,7 @@ public class ExpressionDeParser implements ExpressionVisitor, ItemsListVisitor {
}
public void visit(LongValue longValue) {
buffer.append(longValue.getStringValue());
buffer.append(longValue.toString());
}