var.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,555 行 · 第 1/2 页
JAVA
1,555 行
/* * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Scott Ferguson */package com.caucho.quercus.env;import com.caucho.quercus.Location;import com.caucho.quercus.expr.Expr;import com.caucho.quercus.program.AbstractFunction;import com.caucho.vfs.WriteStream;import java.io.IOException;import java.io.Serializable;import java.math.BigDecimal;import java.math.BigInteger;import java.net.URL;import java.util.*;/** * Represents a PHP variable value. */public class Var extends Value implements Serializable{ Value _value; private int _refCount; public Var() { _value = NullValue.NULL; } public Var(Value value) { _value = value; } /** * Adds a reference. */ public void setReference() { _refCount = 1; } /** * Sets as a global variable */ public void setGlobal() { _refCount = 1; } /** * Sets the value. */ @Override public Value set(Value value) { _value = value.toValue(); return _value; } /** * Sets the value. */ protected Value setRaw(Value value) { // quercus/0431 _value = value; return _value; } /** * Returns the type. */ @Override public String getType() { return _value.getType(); } /* * Returns the type of the resource. */ @Override public String getResourceType() { return _value.getResourceType(); } /** * Returns the ValueType. */ @Override public ValueType getValueType() { return _value.getValueType(); } /** * Returns the class name. */ @Override public String getClassName() { return _value.getClassName(); } /** * Returns true for an object. */ @Override public boolean isObject() { return _value.isObject(); } /* * Returns true for a resource. */ @Override public boolean isResource() { return _value.isResource(); } /** * Returns true for an implementation of a class */ @Override public boolean isA(String name) { return _value.isA(name); } /** * True for a long */ @Override public boolean isLongConvertible() { return _value.isLongConvertible(); } /** * True to a double. */ @Override public boolean isDoubleConvertible() { return _value.isDoubleConvertible(); } /** * True for a number */ @Override public boolean isNumberConvertible() { return _value.isNumberConvertible(); } /** * Returns true for is_numeric */ @Override public boolean isNumeric() { return _value.isNumeric(); } /** * Returns true for a scalar */ /* public boolean isScalar() { return _value.isScalar(); } */ /** * Returns true for a StringValue. */ @Override public boolean isString() { return _value.isString(); } /** * Returns true for a BinaryValue. */ @Override public boolean isBinary() { return _value.isBinary(); } /** * Returns true for a UnicodeValue. */ @Override public boolean isUnicode() { return _value.isUnicode(); } /** * Returns true for a BooleanValue */ @Override public boolean isBoolean() { return _value.isBoolean(); } /** * Returns true for a DefaultValue */ @Override public boolean isDefault() { return _value.isDefault(); } /** * Returns true if the value is set */ @Override public boolean isset() { return _value.isset(); } /** * Returns true if the value is empty */ @Override public boolean isEmpty() { return _value.isEmpty(); } /** * True if the object is null */ @Override public boolean isNull() { return _value.isNull(); } // // Conversions // @Override public String toString() { return _value.toString(); } /** * Converts to a boolean. */ @Override public boolean toBoolean() { return _value.toBoolean(); } /** * Converts to a long. */ @Override public long toLong() { return _value.toLong(); } /** * Converts to a double. */ @Override public double toDouble() { return _value.toDouble(); } /** * Converts to a long. */ @Override public LongValue toLongValue() { return _value.toLongValue(); } /** * Converts to a double. */ @Override public DoubleValue toDoubleValue() { return _value.toDoubleValue(); } /** * Converts to a string. * @param env */ @Override public StringValue toString(Env env) { return _value.toString(env); } /** * Converts to an object. */ @Override public Object toJavaObject() { return _value.toJavaObject(); } /** * Converts to an object. */ @Override public Object toJavaObject(Env env, Class type) { return _value.toJavaObject(env, type); } /** * Converts to an object. */ @Override public Object toJavaObjectNotNull(Env env, Class type) { return _value.toJavaObjectNotNull(env, type); } /** * Converts to a java Collection object. */ @Override public Collection toJavaCollection(Env env, Class type) { return _value.toJavaCollection(env, type); } /** * Converts to a java List object. */ @Override public List toJavaList(Env env, Class type) { return _value.toJavaList(env, type); } /** * Converts to a java map. */ @Override public Map toJavaMap(Env env, Class type) { return _value.toJavaMap(env, type); } /** * Converts to a Java Calendar. */ @Override public Calendar toJavaCalendar() { return _value.toJavaCalendar(); } /** * Converts to a Java Date. */ @Override public Date toJavaDate() { return _value.toJavaDate(); } /** * Converts to a Java URL. */ @Override public URL toJavaURL(Env env) { return _value.toJavaURL(env); } /** * Converts to a Java BigDecimal. */ public BigDecimal toBigDecimal() { return _value.toBigDecimal(); } /** * Converts to a Java BigInteger. */ public BigInteger toBigInteger() { return _value.toBigInteger(); } /** * Converts to an array */ @Override public Value toArray() { return _value.toArray(); } /** * Converts to an array */ @Override public ArrayValue toArrayValue(Env env) { return _value.toArrayValue(env); } /** * Converts to an array */ @Override public Value toAutoArray() { _value = _value.toAutoArray(); return _value; } /** * Converts to an object. */ @Override public Value toObject(Env env) { return _value.toObject(env); } /** * Append to a unicode builder. */ @Override public StringValue appendTo(UnicodeBuilderValue sb) { return _value.appendTo(sb); } /** * Append to a binary builder. */ @Override public StringValue appendTo(BinaryBuilderValue sb) { return _value.appendTo(sb); } /** * Append to a string builder. */ @Override public StringValue appendTo(StringBuilderValue sb) { return _value.appendTo(sb); } /** * Append to a string builder. */ @Override public StringValue appendTo(LargeStringBuilderValue sb) { return _value.appendTo(sb); } /** * Returns to the value value. */ public final Value getRawValue() { return _value; } /** * Converts to a raw value. */ @Override public Value toValue() { return _value; } /** * Converts to a function argument value that is never assigned or modified. */ @Override public Value toArgValueReadOnly() { return _value; } /** * Converts to a raw value. */ @Override public Value toArgValue() { return _value.toArgValue(); } /** * Converts to a function argument ref value, i.e. an argument * declared as a reference, but not assigned */ @Override public Value toRefValue() { // php/344r return _value.toRefValue(); } /** * Converts to a variable */ @Override public Var toVar() { // php/3d04 return new Var(_value.toArgValue()); } /** * Converts to a reference variable */ @Override public Var toRefVar() { _refCount = 2; return this; } /** * Converts to a key. */ @Override public Value toKey() { return _value.toKey(); } @Override public StringValue toStringValue() { return _value.toStringValue(); } @Override public StringValue toBinaryValue(Env env) { return _value.toBinaryValue(env); } @Override public StringValue toUnicodeValue(Env env) { return _value.toUnicodeValue(env); } @Override public StringValue toStringBuilder() { return _value.toStringBuilder(); } @Override public StringValue toStringBuilder(Env env) { return _value.toStringBuilder(env); } @Override public java.io.InputStream toInputStream() { return _value.toInputStream(); } // // Operations // /** * Copy the value. */ @Override public Value copy() { // php/041d return _value.copy(); } /** * Copy for serialization */ public Value copyTree(Env env, CopyRoot root) { return _value.copyTree(env, root); } /** * Clone for the clone keyword */ public Value clone() { return _value.clone(); } /** * Copy the value as an array item. */ @Override public Value copyArrayItem() { _refCount = 2; // php/041d return this; } /** * Copy the value as a return value. */ @Override public Value copyReturn() { if (_refCount < 1) return _value; else return _value.copy(); } /** * Converts to a variable reference (for function arguments) */ @Override public Value toRef() { _refCount = 2; return new RefVar(this); } /** * Returns true for an array. */ @Override public boolean isArray() { return _value.isArray(); } /** * Negates the value. */ @Override public Value neg() { return _value.neg(); } /** * Adds to the following value. */ @Override public Value add(Value rValue) { return _value.add(rValue); } /** * Adds to the following value. */ @Override public Value add(long rValue) { return _value.add(rValue); } /** * Pre-increment the following value. */ @Override public Value preincr(int incr) { _value = _value.preincr(incr); return _value; } /** * Post-increment the following value. */ @Override public Value postincr(int incr) { Value value = _value; _value = value.postincr(incr); return value; } /** * Subtracts to the following value. */ @Override public Value sub(Value rValue) { return _value.sub(rValue); } /** * Subtracts to the following value. */ @Override public Value sub(long rValue) { return _value.sub(rValue); } /** * Multiplies to the following value. */ @Override public Value mul(Value rValue)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?