@Override protected String prettyPrintSingleArg( SQLSkin skin, OperatorDefinition opDef, OperatorPiece piece, String[] args) throws RenderingException { String txt = "CAST("; txt += args[0] + " AS "; if (CastOperatorDefinition.TO_TIMESTAMP.equals(opDef.getExtendedID())) { txt += "DATETIME)"; } else if (CastOperatorDefinition.TO_DATE.equals(opDef.getExtendedID())) { txt += "DATE)"; } else if (CastOperatorDefinition.TO_CHAR.equals(opDef.getExtendedID())) { // length is optional on mysql txt = "CHAR("; txt += ((CastOperatorDefinition) opDef).getPieceLength(getExtendedPieces(piece)) + "))"; } else if (CastOperatorDefinition.TO_NUMBER.equals(opDef.getExtendedID())) { if (args.length == 1) { // txt = "(" + args[0] + " + 0.0)"; txt += "DECIMAL(65,30))"; } else if (args.length == 3) { txt += "DECIMAL(" + args[1] + "," + args[2] + "))"; } } else if (CastOperatorDefinition.TO_INTEGER.equals(opDef.getExtendedID())) { txt += "SIGNED)"; } return txt; }
@Override public String prettyPrint( SQLSkin skin, OperatorPiece piece, OperatorDefinition opDef, String[] args) throws RenderingException { if (args.length == 1) { return prettyPrintSingleArg(skin, opDef, piece, args); } else if (args.length == 2) { return prettyPrintTwoArgs(skin, piece, opDef, args); } else { if (CastOperatorDefinition.TO_NUMBER.equals(opDef.getExtendedID())) { return prettyPrintSingleArg(skin, opDef, piece, args); } else { throw new RenderingException("Invalid operator " + opDef.getSymbol()); } } }