String va = n.substring(i + 1,n.length());
va = va.trim();
n =n.substring(0,i);
n = n.trim();
jiqlTableInfo ti = sqp.getJiqlTableInfo();
if (ti.getFieldList().contains(n))
throw new SQLException(n + " FIELD ALREADY EXISTS ON TABLE " + sqp.getTable());
String tok = null;
i = va.indexOf(" ");
/*if (n.toLowerCase().equals("primary") && va.toLowerCase().startsWith("key"))
{
va = va.substring("key".length(),va.length());
va = va.trim();
va = va.substring( 1,va.length());
va = va.trim();
while (!va.endsWith(")")){
ct = ct + 1;
va = va + "," + v.elementAt(ct).toString();
}
va = va.trim();
va = va.substring( 0,va.length() -1);
va = va.trim();
primaryKeys = new EZArrayList(new StringTokenizer(va,","),true);
}
else*/ if (i > 0)
{
tok = va.substring(i,va.length());
va = va.substring(0,i);
tok = tok.trim();
va = va.trim();
if (va.endsWith("("))
{
i = tok.indexOf(")");
va = va + tok.substring(0,i + 1);
tok = tok.substring(i + 1,tok.length());
tok = tok.trim();
va = va.trim();
}
else if (tok.startsWith("("))
{
i = tok.indexOf(")");
va = va + tok.substring(0,i + 1);
tok = tok.substring(i + 1,tok.length());
tok = tok.trim();
va = va.trim();
}
String tok2 = tok.toLowerCase();
i = tok2.indexOf("not ");
if (i > -1 && tok2.indexOf(" null") > i)
{
if (!sqp.getNotNulls().contains(n)){
sqp.getNotNulls().add(n);
}
}
i = tok2.indexOf("primary ");
if (i > -1 && tok2.indexOf(" key") > i)
{
n = StringUtil.trimQuotes(new StringBuffer(n)).toString();
if (!sqp.getPrimaryKeys().contains(n))
sqp.getPrimaryKeys().add(n);
}
i = tok2.indexOf("default ");
if (i > -1 )
{
tok = tok.substring(i + "default ".length(),tok.length());
tok = tok.trim();
if (tok.startsWith("'"))
{
tok = tok.substring(1,tok.length());
i = tok.indexOf("'");
tok2 = tok.substring(0,i);
tok = tok.substring(i + 1,tok.length());
tok = tok.trim();
tok2 = sqp.decode(tok2);
sqp.getDefaultValues().put(n,tok2);
}
else{
i = tok.indexOf(" ");
if (i > 0)
tok = tok.substring(0,i);
tok = tok.trim();
tok = StringUtil.getTrimmedValue(tok);
tok = sqp.decode(tok);
sqp.getDefaultValues().put(n,tok);
}
}
if (!JGUtil.validFieldType(va,sqp))
throw JGException.get("invalid_field_type",n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());
// throw new SQLException (n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());
sqp.getHash().put(n,sqp.convert(va,n));
ti.addFieldList(n);
}
else{
if (!JGUtil.validFieldType(va,sqp))
throw JGException.get("invalid_field_type",n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());
//throw new SQLException (n + " --> " + va + " Invalid Field Type on Table " + sqp.getTable());
sqp.getHash().put(n,sqp.convert(va,n));
ti.addFieldList(n);
}
sqp.setAction("AlterAddField");
sqp.setSpecial(true);
sqp.setStatementProcessor(spro);
return true;