001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.quercus.env;
031:
032: import java.io.IOException;
033: import java.io.PrintWriter;
034:
035: /**
036: * Represents a PHP default value.
037: */
038: public class DefaultValue extends NullValue {
039: public static final DefaultValue DEFAULT = new DefaultValue();
040:
041: private DefaultValue() {
042: }
043:
044: /**
045: * Returns the null value singleton.
046: */
047: public static DefaultValue create() {
048: return DEFAULT;
049: }
050:
051: /**
052: * Returns true for a DefaultValue
053: */
054: @Override
055: public boolean isDefault() {
056: return true;
057: }
058:
059: /**
060: * Converts to a boolean.
061: */
062: public boolean toBoolean() {
063: return false;
064: }
065:
066: /**
067: * Converts to a long.
068: */
069: public long toLong() {
070: return 0;
071: }
072:
073: /**
074: * Converts to a double.
075: */
076: public double toDouble() {
077: return 0;
078: }
079:
080: /**
081: * Converts to an object.
082: */
083: public Object toObject() {
084: return "";
085: }
086:
087: /**
088: * Prints the value.
089: * @param env
090: */
091: public void print(Env env) {
092: }
093:
094: /**
095: * Converts to a string.
096: * @param env
097: */
098: public String toString() {
099: return "";
100: }
101:
102: /**
103: * Generates code to recreate the expression.
104: *
105: * @param out the writer to the Java source code.
106: */
107: public void generate(PrintWriter out) throws IOException {
108: out.print("DefaultValue.DEFAULT");
109: }
110:
111: /**
112: * Generates code to recreate the expression.
113: *
114: * @param out the writer to the Java source code.
115: */
116: public void generateLong(PrintWriter out) throws IOException {
117: out.print("0");
118: }
119:
120: /**
121: * Generates code to recreate the expression.
122: *
123: * @param out the writer to the Java source code.
124: */
125: public void generateString(PrintWriter out) throws IOException {
126: out.print("\"\"");
127: }
128:
129: //
130: // Java Serialization
131: //
132:
133: private Object readResolve() {
134: return DEFAULT;
135: }
136: }
|