/* --------------------------------------------------------- * * __________ D E L T A S C R I P T * * (_________() * * / === / - A fast, dynamic scripting language * * | == | - Version 4.13.11.0 * * / === / - Developed by Adam R. Nelson * * | = = | - 2011-2013 * * / === / - Distributed under GNU LGPL v3 * * (________() - http://github.com/ar-nelson/deltascript * * * * --------------------------------------------------------- */ package com.sector91.delta.script.objects; import java.io.ObjectStreamException; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import com.sector91.delta.script.DScriptErr; import com.sector91.delta.script.DeltaScript; import com.sector91.delta.script.Operator; import com.sector91.delta.script.annotations.DSType; /** * <p>DeltaScript's equivalent of a "null" value, represented with the keyword * {@code blank} in code.</p> * * <p>Actual Java {@code null} values should never exist in a DeltaScript scope; * any nulls should be replaced with this object.</p> * * <p>{@code DS_Blank} is a singleton. New instances cannot be created; instead, * access the single instance with {@link #BLANK}.</p> * * @author Adam R. Nelson * @version 4.13.11.0 */ @DSType("Blank") public class DS_Blank implements DS_Object, Serializable { private static final long serialVersionUID = DeltaScript.VERSION.majorVersion(); /** <p>The value returned by {@link #getTypeName()}.</p> */ public static final String TYPE_NAME = "Blank"; /** * <p>The single, immutable instance of {@code blank}.</p> * @see {@link DS_Blank} */ public static final DS_Blank BLANK = new DS_Blank(); private DS_Blank() {} public boolean booleanValue() {return false;} public String getTypeName() {return TYPE_NAME;} public Object unbox() {return null;} public int compare(DS_Object other) { if (other instanceof DS_Blank) return 0; else return -1; } @Override public String toString() {return "blank";} public boolean equals(DS_Object other) {return other == this;} @Override public DS_Object clone() throws CloneNotSupportedException {return this;} public DS_Object dotGet(DS_Tag prop) throws DScriptErr { throw new DScriptErr("Attempted to get property \"" +prop.str + "\" of blank.", DScriptErr.T_UNDEFINED, DScriptErr.T_BLANK); } public void dotSet(DS_Tag prop, DS_Object value) throws DScriptErr { throw new DScriptErr("Attempted to set property \"" + prop.str + "\" of blank.", DScriptErr.T_UNDEFINED, DScriptErr.T_BLANK); } public Set<DS_Tag> getMembers() {return new HashSet<DS_Tag>();} public DS_Object operator(Operator op, DS_Object other) throws DScriptErr {throw DScriptErr.invalidOperation(op.str, this, other);} public boolean is(DS_Object typeObj) {return typeObj == this;} private Object readResolve() throws ObjectStreamException { assert(BLANK != null); return BLANK; } }