javaadaptervar.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,366 行 · 第 1/2 页

JAVA
1,366
字号
/* * 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 Nam Nguyen */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.math.BigDecimal;import java.math.BigInteger;import java.net.URL;import java.util.*;/** * Represents a PHP variable value. */public class JavaAdapterVar extends Var{  private JavaAdapter _adapter;  private Value _key;  public JavaAdapterVar(JavaAdapter adapter, Value key)  {    _adapter = adapter;    _key = key;  }  public Value getValue()  {    return _adapter.get(_key);  }    public void setValue(Value value)  {    _adapter.putImpl(_key, value);  }    /**   * Sets the value.   */  @Override  public Value set(Value value)  {    setRaw(getValue());        value = super.set(value);        setValue(getRawValue());        return value;  }  /**   * Returns the type.   */  @Override  public String getType()  {    return getValue().getType();  }    /**   * Returns the type of the resource.   */  @Override  public String getResourceType()  {    return getValue().getResourceType();  }  /**   * Returns the ValueType.   */  @Override  public ValueType getValueType()  {    return getValue().getValueType();  }  /**   * Returns the class name.   */  @Override  public String getClassName()  {    return getValue().getClassName();  }    /**   * Returns true for an object.   */  @Override  public boolean isObject()  {    return getValue().isObject();  }    /**   * Returns true for an object.   */  @Override  public boolean isResource()  {    return getValue().isResource();  }  /**   * Returns true for a set type.   */  @Override  public boolean isset()  {    return getValue().isset();  }  /**   * Returns true for an implementation of a class   */  @Override  public boolean isA(String name)  {    return getValue().isA(name);  }  /**   * True for a number   */  @Override  public boolean isNull()  {    return getValue().isNull();  }  /**   * True for a long   */  @Override  public boolean isLongConvertible()  {    return getValue().isLongConvertible();  }  /**   * True to a double.   */  @Override  public boolean isDoubleConvertible()  {    return getValue().isDoubleConvertible();  }  /**   * True for a number   */  @Override  public boolean isNumberConvertible()  {    return getValue().isNumberConvertible();  }  /**   * Returns true for is_numeric   */  @Override  public boolean isNumeric()  {    return getValue().isNumeric();  }  /**   * Returns true for a scalar   */  /*  public boolean isScalar()  {    return getValue().isScalar();  }  */  /**   * Returns true for a StringValue.   */  @Override  public boolean isString()  {    return getValue().isString();  }  /**   * Returns true for a BinaryValue.   */  @Override  public boolean isBinary()  {    return getValue().isBinary();  }  /**   * Returns true for a UnicodeValue.   */  @Override  public boolean isUnicode()  {    return getValue().isUnicode();  }  /**   * Returns true for a BooleanValue   */  @Override  public boolean isBoolean()  {    return getValue().isBoolean();  }    /**   * Returns true for a DefaultValue   */  @Override  public boolean isDefault()  {    return getValue().isDefault();  }    //  // Conversions  //  @Override  public String toString()  {    return getValue().toString();  }  /**   * Converts to a boolean.   */  @Override  public boolean toBoolean()  {    return getValue().toBoolean();  }  /**   * Converts to a long.   */  @Override  public long toLong()  {    return getValue().toLong();  }  /**   * Converts to a double.   */  @Override  public double toDouble()  {    return getValue().toDouble();  }  /**   * Converts to a string.   * @param env   */  @Override  public StringValue toString(Env env)  {    return getValue().toString(env);  }  /**   * Converts to an object.   */  @Override  public Object toJavaObject()  {    return getValue().toJavaObject();  }  /**   * Converts to an object.   */  @Override  public Object toJavaObject(Env env, Class type)  {    return getValue().toJavaObject(env, type);  }  /**   * Converts to an object.   */  @Override  public Object toJavaObjectNotNull(Env env, Class type)  {    return getValue().toJavaObjectNotNull(env, type);  }  /**   * Converts to a java Collection object.   */  @Override  public Collection toJavaCollection(Env env, Class type)  {    return getValue().toJavaCollection(env, type);  }    /**   * Converts to a java List object.   */  @Override  public List toJavaList(Env env, Class type)  {    return getValue().toJavaList(env, type);  }    /**   * Converts to a java Map object.   */  @Override  public Map toJavaMap(Env env, Class type)  {    return getValue().toJavaMap(env, type);  }  /**   * Converts to an array   */  @Override  public Value toArray()  {    return getValue().toArray();  }  /**   * Converts to an array   */  @Override  public ArrayValue toArrayValue(Env env)  {    return getValue().toArrayValue(env);  }  /**   * Converts to an array   */  @Override  public Value toAutoArray()  {    setRaw(getValue());        Value value = super.toAutoArray();        setValue(getRawValue());        return value;  }  /**   * Converts to an object.   */  @Override  public Value toObject(Env env)  {    return getValue().toObject(env);  }  /**   * Converts to a Java Calendar.   */  @Override  public Calendar toJavaCalendar()  {    return getValue().toJavaCalendar();  }    /**   * Converts to a Java Date.   */  @Override  public Date toJavaDate()  {    return getValue().toJavaDate();  }    /**   * Converts to a Java URL.   */  @Override  public URL toJavaURL(Env env)  {    return getValue().toJavaURL(env);  }    /**   * Converts to a Java BigDecimal.   */  public BigDecimal toBigDecimal()  {    return getValue().toBigDecimal();  }    /**   * Converts to a Java BigInteger.   */  public BigInteger toBigInteger()  {    return getValue().toBigInteger();  }    /**   * Append to a string builder.   */  @Override  public StringValue appendTo(UnicodeBuilderValue sb)  {    return getValue().appendTo(sb);  }  /**   * Append to a string builder.   */  @Override  public StringValue appendTo(BinaryBuilderValue sb)  {    return getValue().appendTo(sb);  }  /**   * Append to a string builder.   */  @Override  public StringValue appendTo(StringBuilderValue sb)  {    return getValue().appendTo(sb);  }    /**   * Append to a string builder.   */  @Override  public StringValue appendTo(LargeStringBuilderValue sb)  {    return getValue().appendTo(sb);  }  /**   * Converts to a raw value.   */  @Override  public Value toValue()  {    return getValue();  }  /**   * Converts to a function argument value that is never assigned or modified.   */  @Override  public Value toArgValueReadOnly()  {    return getValue();  }  /**   * Converts to a raw value.   */  @Override  public Value toArgValue()  {    return getValue().toArgValue();  }  /**   * Converts to a function argument ref value, i.e. an argument   * declared as a reference, but not assigned   */  @Override  public Value toRefValue()  {    setRaw(getValue());        Value value = super.toRefValue();        setValue(getRawValue());        return value;  }  /**   * Converts to a variable   */  @Override  public Var toVar()  {    setRaw(getValue());        Var value = super.toVar();        setValue(getRawValue());        return value;  }  /**   * Converts to a key.   */  @Override  public Value toKey()  {    return getValue().toKey();  }  @Override  public StringValue toStringValue()  {    return getValue().toStringValue();  }  @Override  public StringValue toBinaryValue(Env env)  {    return getValue().toBinaryValue(env);  }  @Override  public StringValue toUnicodeValue(Env env)  {    return getValue().toUnicodeValue(env);  }  @Override  public StringValue toStringBuilder()  {    return getValue().toStringBuilder();  }  /**   * Converts to a string builder   */  @Override  public StringValue toStringBuilder(Env env)  {    return getValue().toStringBuilder(env);  }  //  // Operations  //  /**   * Copy the value.   */  @Override  public Value copy()  {    setRaw(getValue());        Value value = super.copy();        setValue(getRawValue());        return value;  }  /**   * Copy the value as a return value.   */  @Override  public Value copyReturn()  {    setRaw(getValue());        Value value = super.copyReturn();        setValue(getRawValue());        return value;  }  /**   * Converts to a variable reference (for function  arguments)   */  @Override  public Value toRef()  {    setRaw(getValue());        Value value = super.toRef();        setValue(getRawValue());        return value;  }  /**   * Returns true for an array.   */  @Override  public boolean isArray()  {    return getValue().isArray();  }  /**   * Negates the value.   */  @Override  public Value neg()  {    return getValue().neg();  }  /**   * Adds to the following value.   */  @Override  public Value add(Value rValue)  {    return getValue().add(rValue);  }  /**   * Adds to the following value.   */  @Override  public Value add(long rValue)  {    return getValue().add(rValue);  }  /**   * Pre-increment the following value.   */  @Override  public Value preincr(int incr)  {    setRaw(getValue());        Value value = super.preincr(incr);        setValue(getRawValue());        return value;  }  /**   * Post-increment the following value.   */  @Override  public Value postincr(int incr)  {    setRaw(getValue());

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?