FileDocCategorySizeDatePackage
ExpressionJavaPrinter.javaAPI DocGlassfish v2 API8189Tue May 22 16:54:32 BST 2007oracle.toplink.essentials.internal.expressions

ExpressionJavaPrinter

public class ExpressionJavaPrinter extends Object

Purpose: Expression Java printer.

Responsibilities:

  • Print an expression in Java format.
  • Used in project class generation.
since
TOPLink10.1.3

Fields Summary
protected StringWriter
writer
protected String
builderString
protected DatabasePlatform
platform
Constructors Summary
public ExpressionJavaPrinter(String builderString, StringWriter writer, DatabasePlatform platform)

        this.builderString = builderString;
        this.writer = writer;
        this.platform = platform;
    
Methods Summary
public java.lang.StringgetBuilderString()

        return builderString;
    
public oracle.toplink.essentials.internal.databaseaccess.DatabasePlatformgetPlatform()

        return platform;
    
public java.io.StringWritergetWriter()

        return writer;
    
public voidprintByte(java.lang.Byte aByte)

            printString("new Byte((byte)");
            printString((aByte).toString());
            printString(")");        
    
public voidprintCharacter(java.lang.Character aCharacter)

            printString("new Character('");
            printString((aCharacter).toString());
            printString("')");
    
public voidprintJava(java.lang.Object object)

        if (object == null) {
            printString("null");
        } else if (object.getClass() == ClassConstants.STRING) {
            printString("\"");
            printString((String)object);
            printString("\"");
        } else if (object instanceof Calendar) {
            printString("new java.util.Date(");
            printString(String.valueOf(((Calendar)object).getTimeInMillis()));
            printString("L)");
        } else if (object.getClass() == ClassConstants.TIMESTAMP) {
            printString("new java.sql.Timestamp(");
            printString(String.valueOf(((java.sql.Timestamp)object).getTime()));
            printString("L)");
        } else if (object.getClass() == ClassConstants.SQLDATE) {
            printString("new java.sql.Date(");
            printString(String.valueOf(((java.sql.Date)object).getTime()));
            printString("L)");
        } else if (object.getClass() == ClassConstants.TIME) {
            printString("new java.sql.Time(");
            printString(String.valueOf(((java.sql.Time)object).getTime()));
            printString("L)");
        } else if (object.getClass() == ClassConstants.UTILDATE) {
            printString("new java.util.Date(");
            printString(String.valueOf(((java.util.Date)object).getTime()));
            printString("L)");
        } else if (object.getClass() == ClassConstants.BYTE) {
            printByte((Byte)object);
        } else if (object.getClass() == ClassConstants.APBYTE) {
            printString("new byte[] {");
            byte[] bytes = (byte[])object;
            if (bytes.length > 0) {
                printString(String.valueOf((int)bytes[0]));                
                for (int index = 1; index < bytes.length; index++) {
                    printString(",");                
                    printString(String.valueOf((int)bytes[index]));                
                }
            }
            printString("}");
        } else if (object.getClass() == ClassConstants.ABYTE) {
            printString("new Byte[] {");
            Byte[] bytes = (Byte[])object;
            if (bytes.length > 0) {
                printByte(bytes[0]);                
                for (int index = 1; index < bytes.length; index++) {
                    printString(",");                
                    printByte(bytes[index]);                
                }
            }
            printString("}");
        } else if (object.getClass() == ClassConstants.CHAR) {
            printCharacter((Character)object);
        } else if (object.getClass() == ClassConstants.APCHAR) {
            printString("new char[] {");
            char[] chars = (char[])object;
            if (chars.length > 0) {
                printString("'");                                
                printString(String.valueOf(chars[0]));                
                printString("'");                                
                for (int index = 1; index < chars.length; index++) {
                    printString(",");                
                    printString("'");                                
                    printString(String.valueOf(chars[index]));                
                    printString("'");                                
                }
            }
            printString("}");
        } else if (object.getClass() == ClassConstants.ACHAR) {
            printString("new Character[] {");
            Character[] chars = (Character[])object;
            if (chars.length > 0) {
                printCharacter(chars[0]);                
                for (int index = 1; index < chars.length; index++) {
                    printString(",");                
                    printCharacter(chars[index]);                
                }
            }
            printString("}");
        } else if (object.getClass() == ClassConstants.BIGDECIMAL) {
            printString("new java.math.BigDecimal(\"");
            printString(((BigDecimal)object).toString());
            printString("\")");                
        } else if (object.getClass() == ClassConstants.BIGINTEGER) {
            printString("new java.math.BigInteger(\"");
            printString(((BigInteger)object).toString());
            printString("\")");                
        } else {
            printString((String)ConversionManager.getDefaultManager().convertObject(object, String.class));
        }
        
    
public voidprintString(java.lang.String value)

        getWriter().write(value);