001: /*
002: * $Id: AnyUndefined.java,v 1.25 2002/09/16 08:05:02 jkl Exp $
003: *
004: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
005: *
006: * Use is subject to license terms, as defined in
007: * Anvil Sofware License, Version 1.1. See LICENSE
008: * file, or http://njet.org/license-1.1.txt
009: */
010: package anvil.core;
011:
012: import anvil.script.Context;
013: import anvil.java.util.BindingEnumeration;
014: import java.io.IOException;
015: import java.io.OutputStream;
016: import java.io.Writer;
017:
018: /// @class undefined
019: /// <code>undefined</code> is constant indicating <i>non existent</i> value.
020: /**
021: * class AnyUndefin
022: *
023: * @author: Jani Lehtimäki
024: */
025: public final class AnyUndefined extends Any {
026:
027: public static final anvil.script.compiler.NativeClass __class__ = new anvil.script.compiler.NativeClass(
028: "undefined",
029: AnyUndefined.class,
030: //DOC{{
031: ""
032: + " @class undefined\n"
033: + " <code>undefined</code> is constant indicating <i>non existent</i> value.\n"
034: //}}DOC
035: );
036:
037: public static final Any INSTANCE = new AnyUndefined();
038:
039: private AnyUndefined() {
040: }
041:
042: public anvil.script.ClassType classOf() {
043: return __class__;
044: }
045:
046: public int typeOf() {
047: return IS_UNDEFINED;
048: }
049:
050: public boolean isDefined() {
051: return false;
052: }
053:
054: public boolean isUndefined() {
055: return true;
056: }
057:
058: public boolean isNull() {
059: return true;
060: }
061:
062: public Writer toAnvil(Writer writer) throws IOException {
063: writer.write("undefined");
064: return writer;
065: }
066:
067: public Writer toJava(Writer writer) throws IOException {
068: writer.write("anvil.core.Any.UNDEFINED");
069: return writer;
070: }
071:
072: public anvil.codec.Code toCode(anvil.codec.Code code) {
073: code.getstatic(code.getPool().addFieldRef("anvil/core/Any",
074: "UNDEFINED", "Lanvil/core/Any;"));
075: return code;
076: }
077:
078: public Any toAnyBoolean() {
079: return FALSE;
080: }
081:
082: public Any toAnyInt() {
083: return ZERO;
084: }
085:
086: public Any toAnyDouble() {
087: return DOUBLE_ZERO;
088: }
089:
090: public Any toAnyString() {
091: return EMPTY_STRING;
092: }
093:
094: public int hashCode() {
095: return 0;
096: }
097:
098: public boolean equals(Object obj) {
099: return (obj == this );
100: }
101:
102: protected int compare(Any other) {
103: return (other == this ) ? 0 : -1;
104: }
105:
106: public Any getAttribute(Context context, String attribute) {
107: return this ;
108: }
109:
110: public Any setAttribute(Context context, String attribute, Any value) {
111: return this ;
112: }
113:
114: public Any checkAttribute(Context context, String attribute) {
115: return this ;
116: }
117:
118: public boolean deleteAttribute(Context context, String attribute) {
119: return false;
120: }
121:
122: public Any getReference(Context context, Any index) {
123: return this ;
124: }
125:
126: public Any setReference(Context context, Any index, Any value) {
127: return this ;
128: }
129:
130: public Any setReference(Context context, Any value) {
131: return this ;
132: }
133:
134: public Any checkReference(Context context, Any index) {
135: return this ;
136: }
137:
138: public boolean deleteReference(Context context, Any index) {
139: return false;
140: }
141:
142: public Any invoke(Context context, String methodName,
143: Any[] parameters) {
144: return this ;
145: }
146:
147: public void serialize(Serializer serializer) throws IOException {
148: serializer.write('u');
149: }
150:
151: public BindingEnumeration enumeration() {
152: return BindingEnumeration.EMPTY;
153: }
154:
155: public byte[] toBinary() {
156: return null;
157: }
158:
159: public Any increase() {
160: return ONE;
161: }
162:
163: public Any decrease() {
164: return MINUS_ONE;
165: }
166:
167: }
|