com.caucho.quercus.env
Class Env

java.lang.Object
  extended by com.caucho.quercus.env.Env
Direct Known Subclasses:
CgiEnv, GoogleEnv, ProEnv, ProfileEnv

public class Env
extends java.lang.Object

Represents the Quercus environment.


Nested Class Summary
static class Env.OVERLOADING_TYPES
           
 
Field Summary
 java.util.HashMap<java.lang.String,AbstractFunction> _anonymousFunMap
           
 ClassDef[] _classDef
           
 Value[] _const
           
 AbstractFunction[] _fun
           
 QuercusClass[] _qClass
           
protected  QuercusContext _quercus
           
static int B_COMPILE_ERROR
           
static int B_COMPILE_WARNING
           
static int B_CORE_ERROR
           
static int B_CORE_WARNING
           
static int B_ERROR
           
static int B_LAST
           
static int B_NOTICE
           
static int B_PARSE
           
static int B_RECOVERABLE_ERROR
           
static int B_STRICT
           
static int B_USER_ERROR
           
static int B_USER_NOTICE
           
static int B_USER_WARNING
           
static int B_WARNING
           
static int[] DEFAULT_QUERY_SEPARATOR_MAP
           
static int E_ALL
           
static int E_COMPILE_ERROR
           
static int E_COMPILE_WARNING
           
static int E_CORE_ERROR
           
static int E_CORE_WARNING
           
static int E_DEFAULT
           
static int E_ERROR
           
static int E_NOTICE
           
static int E_PARSE
           
static int E_RECOVERABLE_ERROR
           
static int E_STRICT
           
static int E_USER_ERROR
           
static int E_USER_NOTICE
           
static int E_USER_WARNING
           
static int E_WARNING
           
static Value[] EMPTY_VALUE
           
 
Constructor Summary
Env(QuercusContext quercus)
           
Env(QuercusContext quercus, QuercusPage page, WriteStream out, HttpServletRequest request, HttpServletResponse response)
           
 
Method Summary
 void addAutoloadFunction(Callable fun)
           
 void addClass(ClassDef def, int classId, int parentId)
          Adds the class with the given name
 void addClass(java.lang.String name, ClassDef def)
           
 void addClassDef(java.lang.String name, ClassDef cl)
          Adds a class, e.g.
 void addCleanup(EnvCleanup envCleanup)
          add resource to the list of refrences that are cleaned up when finished with this environment.
 Value addConstant(int id, Value value, boolean isCaseInsensitive)
          Sets a constant.
 Value addConstant(java.lang.String name, Value value, boolean isCaseInsensitive)
          Sets a constant.
 Value addConstant(StringValue name, Value value, boolean isCaseInsensitive)
          Sets a constant.
 Value addFunction(java.lang.String name, AbstractFunction fun)
           
 Value addFunctionFromPage(java.lang.String name, java.lang.String lowerName, AbstractFunction fun)
          Adds a function from a compiled include
 void addInitializedClass(java.lang.String name)
          Mark this class as being initialized.
 void addObjectCleanup(ObjectExtValue objCleanup)
          add an object with a destructor to the list of references that are cleaned up when finished with this environment.
 void addRemovePath(Path path)
          Adds an auto-remove path.
 void addShutdown(Callable callback, Value[] args)
          Registers a shutdown function.
 void addWildcardImport(java.lang.String name)
          Adds a Quercus class import.
 RegexpState allocateRegexpState()
          Allocate the free regexp
 Value call(java.lang.String name)
          Evaluates the named function.
 Value call(java.lang.String name, Value a0)
          Evaluates the named function.
 Value call(java.lang.String name, Value[] args)
          Evaluates the named function.
 Value call(java.lang.String name, Value a0, Value a1)
          Evaluates the named function.
 Value call(java.lang.String name, Value a0, Value a1, Value a2)
          Evaluates the named function.
 Value call(java.lang.String name, Value a0, Value a1, Value a2, Value a3)
          Evaluates the named function.
 Value call(java.lang.String name, Value a0, Value a1, Value a2, Value a3, Value a4)
          Evaluates the named function.
 Value callRef(java.lang.String name)
          Evaluates the named function.
 Value callRef(java.lang.String name, Value a0)
          EvalRefuates the named function.
 Value callRef(java.lang.String name, Value[] args)
          Evaluates the named function.
 Value callRef(java.lang.String name, Value a0, Value a1)
          EvalRefuates the named function.
 Value callRef(java.lang.String name, Value a0, Value a1, Value a2)
          EvalRefuates the named function.
 Value callRef(java.lang.String name, Value a0, Value a1, Value a2, Value a3)
          Evaluates the named function.
 Value callRef(java.lang.String name, Value a0, Value a1, Value a2, Value a3, Value a4)
          Evaluates the named function.
 Value cast(java.lang.Class cl, Value value)
          Handles exit/die
 void checkTimeout()
          Checks for the program timeout.
 void checkTypeHint(Value value, java.lang.String type, java.lang.String argName, java.lang.String functionName)
          Check for type hinting
 void clearClassCache()
           
 void close()
          Called when the Env is no longer needed.
 void closeDuplex()
           
static double comma(double a0, double a1)
          Returns the last value.
static Value comma(double a0, Value a1)
          Returns the last value.
static long comma(long a0, long a1)
          Returns the last value.
static Value comma(long a0, Value a1)
          Returns the last value.
static double comma(Value a0, double a1)
          Returns the last value.
static long comma(Value a0, long a1)
          Returns the last value.
static Value comma(Value a0, Value a1)
          Returns the last value.
static Value comma(Value a0, Value a1, Value a2)
          Returns the last value.
static Value comma(Value a0, Value a1, Value a2, Value a3)
          Returns the last value.
static Value comma(Value a0, Value a1, Value a2, Value a3, Value a4)
          Returns the last value.
 Value compileError(java.lang.String msg)
          A parse error
 Value compileWarning(java.lang.String msg)
          A parse warning
 AbstractFunction createAnonymousFunction(java.lang.String args, java.lang.String code)
           
 StringValue createBinaryBuilder()
          Creates a binary builder.
 StringValue createBinaryBuilder(byte[] buffer)
          Creates a binary builder.
 StringValue createBinaryBuilder(byte[] buffer, int offset, int length)
          Creates a binary builder.
 StringValue createBinaryBuilder(int length)
          Creates a binary builder.
 StringValue createBinaryString(TempBuffer head)
          Creates a PHP string from a buffer.
 QuercusRuntimeException createErrorException(Location location, java.lang.String msg)
          A fatal runtime error.
 QuercusRuntimeException createErrorException(java.lang.String msg)
          A fatal runtime error.
 QuercusRuntimeException createErrorException(java.lang.Throwable e)
          A fatal runtime error.
 Value createException(java.lang.String exceptionClass, java.lang.String message)
           
 Value createException(java.lang.Throwable e)
          Creates a PHP Exception.
 ObjectValue createIncompleteObject(java.lang.String name)
          Creates a stdClass object.
 StringValue createLargeBinaryBuilder()
          Creates a binary builder for large things like files.
 ObjectValue createObject()
          Creates a stdClass object.
 SessionArrayValue createSession(java.lang.String sessionId, boolean create)
          Create the session.
 StringValue createStaticName()
          Gets a static variable name.
 StringValue createString(byte[] buffer, int offset, int length)
          Creates a PHP string from a byte buffer.
 StringValue createString(char ch)
          Creates a string from a byte.
 StringValue createString(char[] buffer, int length)
          Creates a PHP string from a byte buffer.
 StringValue createString(char[] buffer, int offset, int length)
          Creates a PHP string from a char buffer.
 StringValue createString(java.lang.String s)
          Creates a PHP string from a java String.
 StringValue createStringBuilder()
           
 StringValue createUnicodeBuilder()
          Creates a unicode builder.
 java.lang.String dbgId()
           
protected static java.lang.String decodeValue(java.lang.String s)
           
 Value deprecatedArgument(java.lang.String name)
          A warning about an deprecated argument passed to a function.
 void destroySession(java.lang.String sessionId)
          Destroy the session.
 Value die()
          Handles exit/die
 Value die(java.lang.String msg)
          Handles exit/die
 Value error(int code, Location location, java.lang.String msg)
           
 Value error(int code, Location location, java.lang.String loc, java.lang.String msg)
          Writes an error.
 Value error(int code, java.lang.String locString, java.lang.String msg)
           
 Value error(Location location, java.lang.String msg)
          A fatal runtime error.
 Value error(java.lang.String msg)
          A fatal runtime error.
 Value error(java.lang.String loc, java.lang.String msg)
          A fatal runtime error.
 Value error(java.lang.String msg, java.lang.Throwable e)
          A warning with an exception.
 Value error(java.lang.Throwable e)
          A warning with an exception.
 Value evalCode(java.lang.String code)
          Compiles and evalutes the given code
 void execute()
          Evaluates the top-level code and prepend and append code.
protected  Value executePage(QuercusPage page)
          Executes the given page
protected  Value executePageTop(QuercusPage page)
          Executes the given page
 Value executeTop()
          Evaluates the top-level code
 Value exit()
          Handles exit/die
 Value exit(Value msg)
          Handles exit/die
 Value expectBoolean(Value value)
          Check for expected type.
 Value expectNumeric(Value value)
          Check for expected type.
 Value expectString(Value value)
          Check for expected type.
protected  void fillPost(ArrayValue postArray, ArrayValue files, HttpServletRequest request, boolean isMagicQuotes)
           
 QuercusClass findAbstractClass(java.lang.String name)
          Finds the class with the given name.
 QuercusClass findClass(int id, boolean useAutoload, boolean useImport)
           
 QuercusClass findClass(java.lang.String name)
          Finds the class with the given name.
 QuercusClass findClass(java.lang.String name, boolean useAutoload, boolean useImport)
          Finds the class with the given name.
 ClassDef findClassDef(java.lang.String name)
           
protected  javax.sql.DataSource findDatabase(java.lang.String driver, java.lang.String url)
           
 AbstractFunction findFunction(int id)
          Returns the function with a given name.
 AbstractFunction findFunction(java.lang.String name)
          Returns the function with a given name.
 AbstractFunction findFunction(java.lang.String className, java.lang.String methodName)
          Finds the class and method.
 int findFunctionId(java.lang.String name)
          Returns the function with a given name.
 AbstractFunction findMethod(java.lang.String className, java.lang.String methodName)
          Finds the java reflection method for the function with the given name.
static double first(double value, double a1)
          Returns the first value
static double first(double value, Value a1)
          Returns the first value
static long first(long value, double a1)
          Returns the first value
static long first(long value, Value a1)
          Returns the first value
static Value first(Value value)
          Returns the first value
static Value first(Value value, double a1)
          Returns the first value
static Value first(Value value, Value a1)
          Returns the first value
static Value first(Value value, Value a1, Value a2)
          Returns the first value
static Value first(Value value, Value a1, Value a2, Value a3)
          Returns the first value
static Value first(Value value, Value a1, Value a2, Value a3, Value a4)
          Returns the first value
static Value first(Value value, Value a1, Value a2, Value a3, Value a4, Value a5)
          Returns the first value
 void flush()
          Flushes the output buffer.
 void freeRegexpState(RegexpState state)
          Free the free regexp
 int generateId()
          Generate an object id.
 java.lang.String generateSessionId()
          Returns a new session id.
 java.util.ArrayList<Callable> getAutoloadFunctions()
           
 ByteToChar getByteToChar()
          Returns the ByteToChar converter.
 int getCallDepth()
          Returns the stack depth.
 QuercusClass getCallingClass()
           
 QuercusClass getCallingClass(Value qThis)
           
 Value getCallingClassName()
           
 QuercusClass getClass(int classId)
          Returns the class with the given id
 QuercusClass getClass(java.lang.String name)
          Finds the class with the given name.
 Value getConfigVar(java.lang.String name)
          Returns the configuration value of an init var.
 ConnectionEntry getConnection(java.lang.String driver, java.lang.String url, java.lang.String userName, java.lang.String password, boolean isReuse)
          Returns a connection to the given database.
 int getConnectionStatus()
          Returns the connection status
 Value getConstant(int id)
          Returns a constant.
 Value getConstant(java.lang.String name)
          Returns a constant.
 Value getConstant(java.lang.String name, boolean isAutoCreateString)
          Returns a constant.
protected  java.lang.String getContentType()
           
protected  ArrayValue getCookies()
           
static Env getCurrent()
           
 long getCurrentTime()
          Returns the current time (may be cached).
 javax.sql.DataSource getDatabase()
          Returns the configured database.
 javax.sql.DataSource getDataSource(java.lang.String driver, java.lang.String url)
          Returns the configured database.
 QDate getDate()
           
 Value getDeclaredClasses()
          Returns the declared classes.
protected  AbstractFunction[] getDefaultFunctionMap()
           
 StreamContextResource getDefaultStreamContext()
          Returns the default stream resource.
 java.util.TimeZone getDefaultTimeZone()
           
 ArrayValue getDefinedConstants()
          Returns an array of the defined functions.
 ArrayValue getDefinedFunctions()
           
 java.lang.Object getDuplex()
           
 StringValue getEmptyString()
           
 java.util.Map<StringValue,EnvVar> getEnv()
          Returns the current environment.
 EnvVar getEnvVar(StringValue name)
           
 EnvVar getEnvVar(StringValue name, boolean isAutoCreate, boolean isOutputNotice)
          Gets a variable
 int getErrorMask()
          Returns the error mask.
 long getExactTime()
          Returns the current time (not cached).
 Callable getExceptionHandler()
          Gets the exception handler
 Value getExtensionFuncs(java.lang.String name)
          Returns true if an extension is loaded.
 AbstractFunction getFunction(java.lang.String name)
           
 AbstractFunction getFunction(Value name)
          Finds the java reflection method for the function with the given name.
 Value[] getFunctionArgs()
          Returns the function args.
 java.lang.String getFunctionLocation()
          Returns the current function.
 java.util.Map<StringValue,EnvVar> getGlobalEnv()
          Returns the current environment.
 EnvVar getGlobalEnvVar(StringValue name)
          Gets a variable
 EnvVar getGlobalEnvVar(StringValue name, boolean isAutoCreate, boolean isOutputNotice)
          Gets a variable
 EnvVar getGlobalRaw(java.lang.String name)
          Returns the raw global lookup.
 Var getGlobalRef(StringValue name)
          Gets a global value.
protected  EnvVar getGlobalScriptContextRef(StringValue name)
           
protected  EnvVar getGlobalSpecialRef(StringValue name)
          Gets a value.
 Value getGlobalValue(java.lang.String name)
           
 Value getGlobalValue(StringValue name)
          Gets a global
 Var getGlobalVar(java.lang.String name)
          Gets a value.
 Var getGlobalVar(StringValue name)
          Gets a value.
 Var getGlobalVar(StringValue name, Value value)
          Gets a variable
 QDate getGmtDate()
           
 java.lang.Object getGzStream()
           
 java.lang.String getHttpInputEncoding()
          Returns the encoding used for input, i.e.
 ArrayValue getIncludedFiles()
          Returns all the included files.
 StringValue getIni(java.lang.String name)
          Returns an ini value.
 boolean getIniBoolean(java.lang.String name)
          Returns an ini value.
 long getIniBytes(java.lang.String name, long deflt)
          Returns an ini value.
 long getIniLong(java.lang.String name)
          Returns an ini value as a long.
 java.util.HashMap<java.lang.String,Value> getIniMap(boolean create)
          Returns a map of the ini values that have been explicitly set.
 java.lang.String getIniString(java.lang.String name)
          Returns an ini value as a string, null for missing or empty string
 StringValue getInputData()
           
static Env getInstance()
           
 JavaClassDef getJavaClassDefinition(java.lang.Class<?> type)
          Returns an introspected Java class definition.
 JavaClassDef getJavaClassDefinition(java.lang.String className)
          Returns an introspected Java class definition.
 HttpSession getJavaSession()
          Returns the Java Http session.
 java.util.HashSet<java.lang.String> getLoadedExtensions()
          Returns true if an extension is loaded.
 QDate getLocalDate()
           
 LocaleInfo getLocaleInfo()
          Returns the locale info.
static Value getLocalValue(Value var)
          Gets a local value
static Value getLocalVar(Value var)
          Gets a local
 Location getLocation()
          Returns the current execution location.
protected  Location getLocationImpl()
           
 java.util.logging.Logger getLogger()
          Returns the logger used for syslog.
 long getMicroTime()
           
 ModuleContext getModuleContext()
          Returns the owning PHP engine.
 WriteStream getOriginalOut()
          Returns the writer.
 WriteStream getOut()
          Returns the writer.
 OutputBuffer getOutputBuffer()
          Returns the current output buffer.
 java.lang.String getOutputEncoding()
          Returns the encoding used for output, null if unicode.semantics is off.
 Path getPwd()
          Returns the current directory.
 QuercusContext getQuercus()
          Returns the owning PHP engine.
protected  java.lang.String getQueryString()
           
 java.lang.String getRealPath(java.lang.String path)
          Returns the real path.
 Var getRef(StringValue name)
          Gets a value.
 Var getRef(StringValue name, boolean isAutoCreate)
          Gets a value.
 HttpServletRequest getRequest()
          Returns the request.
 HttpServletResponse getResponse()
          Returns the response.
 java.lang.String getRuntimeEncoding()
          Returns the encoding used for runtime conversions, e.g.
 EncodingReader getRuntimeEncodingFactory()
          Returns the encoding used for runtime conversions, e.g.
 java.lang.String getScriptEncoding()
          Returns the encoding used for scripts.
 Path getSelfDirectory()
          Returns the initial directory.
 Path getSelfPath()
          Returns the initial directory.
 ServletContext getServletContext()
           
 SessionArrayValue getSession()
          Returns the session.
 SessionCallback getSessionCallback()
          Gets the session callback.
 java.lang.String getShellPwd()
           
static java.lang.String[] getSourceLine(Path path, int sourceLine, int length)
          Returns the source of an error line.
 int getSourceLine(java.lang.String className, int javaLine)
           
 java.lang.Object getSpecialValue(java.lang.String name)
          Gets a special value, a special value is used to store and retrieve module specific values in the env using a unique name.
 java.util.ArrayList<java.lang.String> getStackTrace()
           
 long getStartTime()
           
 Value getStaticValue(StringValue name)
          Gets a static variable
 Var getStaticVar(StringValue name)
          Gets a static variable
 Path getTempDirectory()
          Returns the temp directory (used by tmpfile()).
 Value getThis()
          Returns the 'this' value.
 Path getUploadDirectory()
          Returns the upload directory.
 Value getValue(StringValue name)
          Gets a value.
 Value getValue(StringValue name, boolean isAutoCreate, boolean isOutputNotice)
          Gets a value.
 Var getVar(java.lang.String name)
           
 Var getVar(StringValue name)
          Gets a value.
 Var getVar(StringValue name, Value value)
          Gets a variable
 Path getWorkDir()
          Returns the current directory.
 Value ifNull(Value condition, Value ifNull, Value ifNotNull)
          Returns ifNull if condition.isNull(), otherwise returns ifNotNull.
 JavaClassDef importJavaClass(java.lang.String className)
          Imports a Java class.
 boolean importPhpClass(java.lang.String name)
          Imports a PHP class.
 Value include(Path scriptPwd, StringValue include, boolean isRequire, boolean isOnce)
          Evaluates an included file.
 Value include(StringValue include)
          Evaluates an included file.
 Value includeOnce(Path scriptPwd, StringValue include, boolean isRequire)
          Evaluates an included file.
 Value includeOnce(StringValue include)
          Evaluates an included file.
 Value invalidArgument(java.lang.String name, java.lang.Object value)
          A warning about an invalid argument passed to a function.
 boolean isAllowUrlFopen()
           
 boolean isAllowUrlInclude()
           
 boolean isDefined(java.lang.String name)
          Returns true if the constant is defined.
 boolean isExtensionLoaded(java.lang.String name)
          Returns true if an extension is loaded.
 boolean isGlobalEnv()
           
 boolean isInitializedClass(java.lang.String name)
          Returns true if class has already been initialized.
 boolean isStrict()
          Returns true for strict mode.
 boolean isUnicodeSemantics()
          Returns true if unicode.semantics is on.
 Path lookup(StringValue relPath)
          Looks up the path.
 Path lookupInclude(StringValue relPath)
          Looks up the path.
 Path lookupPwd(Value relPathV)
          Looks up based on the pwd.
 java.lang.String normalizePath(java.lang.CharSequence path)
           
 Value notice(java.lang.String msg)
          A notice.
 Value notice(java.lang.String msg, java.lang.Throwable e)
          A notice with an exception.
static Value nullAsFalse(Value value)
           
protected  QuercusPage pageInit(QuercusPage page)
          Initialize the page, loading any functions and classes
 Value parse(java.lang.String msg)
          A parse error
 Value[] peekArgs(int depth)
          Peeks at the the top call.
 Expr peekCall(int depth)
          Peeks at the the top call.
 Value peekCallThis(int depth)
          Peeks at the "this" top call.
 Expr popCall()
          Pops the top call.
 void popEnv(java.util.Map<StringValue,EnvVar> oldEnv)
          Restores the old environment.
 void popFieldGet(Env.OVERLOADING_TYPES type)
           
 boolean popOutputBuffer()
          Pops the output buffer
 void popProfile(long nanos)
           
 void print(char v)
          Prints a char
 void print(char[] buffer, int offset, int length)
          Prints a character buffer.
 void print(double v)
          Prints a double
 void print(long v)
          Prints a long
 void print(java.lang.Object v)
          Prints an object
 void print(java.lang.String v)
          Prints a string
 void print(Value v)
          Prints a value
 void println()
          Prints a string
 void println(java.lang.Object v)
          Prints and object.
 void println(java.lang.String v)
          Prints a string
 void println(Value v)
          Prints a string
 void pushCall(Expr call, Value obj, Value[] args)
          Sets the calling function expression.
 java.util.Map<StringValue,EnvVar> pushEnv(java.util.Map<StringValue,EnvVar> map)
          Pushes a new environment.
 boolean pushFieldGet(Env.OVERLOADING_TYPES type, java.lang.String className, StringValue fieldName)
           
 void pushOutputBuffer(Callable callback, int chunkSize, boolean erase)
          Returns the writer.
 void pushProfile(int id)
           
 void putQualifiedImport(java.lang.String javaName)
          Adds a Quercus class import.
 void removeAutoloadFunction(Callable fun)
           
 void removeCleanup(EnvCleanup envCleanup)
          remove resource from the list of references that are cleaned up when finished with this environment.
 Value removeConstant(java.lang.String name)
          Removes a constant.
 java.lang.Object removeSpecialValue(java.lang.String name)
          Removes a specialValue
 Value require(StringValue include)
          Evaluates an included file.
 Value requireOnce(StringValue include)
          Evaluates an included file.
 void resetTimeout()
           
 void restoreErrorHandler()
          Sets an error handler
 void restoreExceptionHandler()
          Restore an exception handler
 void restoreFunctionArgs(Value[] args)
          Pushes a new environment.
 void restoreIncludePath()
          Restores the default include path.
 void restoreState(SaveState saveState)
          Restores to a given state
 SaveState saveState()
          Saves the current state
 void sessionWriteClose()
           
 void setArgs(java.lang.String[] args)
           
 QuercusClass setCallingClass(QuercusClass cls)
           
 void setDefaultTimeZone(java.lang.String id)
           
 void setDefaultTimeZone(java.util.TimeZone zone)
           
static Var setEnvRef(Var oldVar, Value value)
          Sets a reference
 void setErrorHandler(int mask, Callable fun)
          Sets an error handler
 int setErrorMask(int mask)
          Sets the error mask.
 Value setExceptionHandler(Callable fun)
          Sets an exception handler
static Value setFieldVar(Value oldValue, Value value)
          Sets a vield variable
 Value[] setFunctionArgs(Value[] args)
          Pushes a new environment.
 Value[] setFunctionArgsNoCopy(Value[] args)
          Pushes a new environment.
 Value setGlobalValue(java.lang.String name, Value value)
          External calls to set a global value.
 Value setGlobalValue(StringValue name, Value value)
          External calls to set a global value.
 void setGzStream(java.lang.Object obj)
           
 java.lang.String setIncludePath(java.lang.String path)
          Sets the include path.
 StringValue setIni(java.lang.String name, java.lang.String value)
          Sets an ini value.
 StringValue setIni(java.lang.String name, Value value)
          Sets an ini value.
 void setInputData(StringValue data)
           
static Value setLocalVar(Value var, Value value)
          Gets a local
 Location setLocation(Location newLocation)
           
 void setPwd(Path path)
          Sets the current directory.
 Var setRef(StringValue name, Value value)
          Sets a value.
static Value setRef(Value oldValue, Value value)
          Sets a reference
 Value setRuntimeEncoding(java.lang.String encoding)
          Sets the encoding used for runtime conversions.
 void setScriptContext(javax.script.ScriptContext context)
           
 Value setScriptGlobal(java.lang.String name, java.lang.Object object)
          External calls to set a global value.
 void setSelfPath(Path path)
          Sets the initial directory.
 void setSession(SessionArrayValue session)
          Sets the session.
 void setSessionCallback(SessionCallback callback)
          Sets the session callback.
 java.lang.Object setSpecialValue(java.lang.String name, java.lang.Object value)
          Sets a special value, a special value is used to store and retrieve module specific values in the env using a unique name.
 Var setStaticRef(StringValue name, Value value)
          Gets a static variable
 Value setThis(Value value)
          Sets the 'this' value, returning the old value.
 void setTimeLimit(long ms)
          Sets the time limit.
 void setValue(java.lang.String name, Value value)
           
 Value setValue(StringValue name, Value value)
          Sets a value.
 Var setVar(java.lang.String name, Value value)
          Gets a variable
 Var setVar(StringValue name, Var var)
          Sets a variable.
 void start()
           
 void startDuplex(java.lang.Object duplex)
           
 Value strict(java.lang.String msg)
          A runtime strict warning.
 Value stub(java.lang.String msg)
          A stub notice.
 Value suppress(int errorMask, Value value)
          Handles error suppression.
 java.lang.String toString()
          Calls a parent::name method.
static Value toValue(boolean value)
          Converts a boolean to the boolean value
static Value toValue(long value)
          Converts a boolean to the boolean value
static Var toVar(Value value)
          Converts to a variable
 Var unsetGlobalVar(StringValue name)
          Unsets variable
 Var unsetLocalVar(StringValue name)
          Unsets variable
 Var unsetVar(StringValue name)
          Unsets variable
 void updateFunction(int id, AbstractFunction fun)
           
 void updateTimeout()
           
 Value warning(Location location, java.lang.String msg)
          A runtime warning.
 Value warning(Location location, java.lang.String msg, java.lang.Throwable e)
          A warning with an exception.
 Value warning(Location location, java.lang.Throwable e)
          A warning with an exception.
 Value warning(java.lang.String msg)
          A runtime warning.
 Value warning(java.lang.String msg, java.lang.Throwable e)
          A warning with an exception.
 Value warning(java.lang.Throwable e)
          A warning with an exception.
 Value wrapJava(java.lang.Object obj)
          Returns a PHP value for a Java object
 Value wrapJava(java.lang.Object obj, boolean isNullAsFalse)
          Returns a PHP value for a Java object
 Value wrapJava(java.lang.Object obj, JavaClassDef def)
          Returns a PHP value for a Java object
 Value wrapJava(java.lang.Object obj, JavaClassDef def, boolean isNullAsFalse)
          Returns a PHP value for a Java object
 void write(byte[] buffer, int offset, int length)
          Prints a byte buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

B_ERROR

public static final int B_ERROR
See Also:
Constant Field Values

B_WARNING

public static final int B_WARNING
See Also:
Constant Field Values

B_PARSE

public static final int B_PARSE
See Also:
Constant Field Values

B_NOTICE

public static final int B_NOTICE
See Also:
Constant Field Values

B_CORE_ERROR

public static final int B_CORE_ERROR
See Also:
Constant Field Values

B_CORE_WARNING

public static final int B_CORE_WARNING
See Also:
Constant Field Values

B_COMPILE_ERROR

public static final int B_COMPILE_ERROR
See Also:
Constant Field Values

B_COMPILE_WARNING

public static final int B_COMPILE_WARNING
See Also:
Constant Field Values

B_USER_ERROR

public static final int B_USER_ERROR
See Also:
Constant Field Values

B_USER_WARNING

public static final int B_USER_WARNING
See Also:
Constant Field Values

B_USER_NOTICE

public static final int B_USER_NOTICE
See Also:
Constant Field Values

B_STRICT

public static final int B_STRICT
See Also:
Constant Field Values

B_RECOVERABLE_ERROR

public static final int B_RECOVERABLE_ERROR
See Also:
Constant Field Values

B_LAST

public static final int B_LAST
See Also:
Constant Field Values

E_ERROR

public static final int E_ERROR
See Also:
Constant Field Values

E_WARNING

public static final int E_WARNING
See Also:
Constant Field Values

E_PARSE

public static final int E_PARSE
See Also:
Constant Field Values

E_NOTICE

public static final int E_NOTICE
See Also:
Constant Field Values

E_CORE_ERROR

public static final int E_CORE_ERROR
See Also:
Constant Field Values

E_CORE_WARNING

public static final int E_CORE_WARNING
See Also:
Constant Field Values

E_COMPILE_ERROR

public static final int E_COMPILE_ERROR
See Also:
Constant Field Values

E_COMPILE_WARNING

public static final int E_COMPILE_WARNING
See Also:
Constant Field Values

E_USER_ERROR

public static final int E_USER_ERROR
See Also:
Constant Field Values

E_USER_WARNING

public static final int E_USER_WARNING
See Also:
Constant Field Values

E_USER_NOTICE

public static final int E_USER_NOTICE
See Also:
Constant Field Values

E_ALL

public static final int E_ALL
See Also:
Constant Field Values

E_STRICT

public static final int E_STRICT
See Also:
Constant Field Values

E_RECOVERABLE_ERROR

public static final int E_RECOVERABLE_ERROR
See Also:
Constant Field Values

E_DEFAULT

public static final int E_DEFAULT
See Also:
Constant Field Values

EMPTY_VALUE

public static final Value[] EMPTY_VALUE

_quercus

protected final QuercusContext _quercus

_fun

public AbstractFunction[] _fun

_anonymousFunMap

public java.util.HashMap<java.lang.String,AbstractFunction> _anonymousFunMap

_classDef

public ClassDef[] _classDef

_qClass

public QuercusClass[] _qClass

_const

public Value[] _const

DEFAULT_QUERY_SEPARATOR_MAP

public static final int[] DEFAULT_QUERY_SEPARATOR_MAP
Constructor Detail

Env

public Env(QuercusContext quercus,
           QuercusPage page,
           WriteStream out,
           HttpServletRequest request,
           HttpServletResponse response)

Env

public Env(QuercusContext quercus)
Method Detail

getCurrent

public static Env getCurrent()

getInstance

public static Env getInstance()

fillPost

protected void fillPost(ArrayValue postArray,
                        ArrayValue files,
                        HttpServletRequest request,
                        boolean isMagicQuotes)

getDefaultFunctionMap

protected AbstractFunction[] getDefaultFunctionMap()

pageInit

protected QuercusPage pageInit(QuercusPage page)
Initialize the page, loading any functions and classes


setScriptGlobal

public Value setScriptGlobal(java.lang.String name,
                             java.lang.Object object)
External calls to set a global value.


isUnicodeSemantics

public boolean isUnicodeSemantics()
Returns true if unicode.semantics is on.


getScriptEncoding

public java.lang.String getScriptEncoding()
Returns the encoding used for scripts.


getRuntimeEncoding

public java.lang.String getRuntimeEncoding()
Returns the encoding used for runtime conversions, e.g. files XXX: ISO-8859-1 when unicode.semantics is OFF


setRuntimeEncoding

public Value setRuntimeEncoding(java.lang.String encoding)
Sets the encoding used for runtime conversions.


getRuntimeEncodingFactory

public EncodingReader getRuntimeEncodingFactory()
                                         throws java.io.IOException
Returns the encoding used for runtime conversions, e.g. files

Throws:
java.io.IOException

getHttpInputEncoding

public java.lang.String getHttpInputEncoding()
Returns the encoding used for input, i.e. post, null if unicode.semantics is off.


getOutputEncoding

public java.lang.String getOutputEncoding()
Returns the encoding used for output, null if unicode.semantics is off.


createBinaryBuilder

public StringValue createBinaryBuilder()
Creates a binary builder.


createLargeBinaryBuilder

public StringValue createLargeBinaryBuilder()
Creates a binary builder for large things like files.


createBinaryBuilder

public StringValue createBinaryBuilder(int length)
Creates a binary builder.


createBinaryBuilder

public StringValue createBinaryBuilder(byte[] buffer,
                                       int offset,
                                       int length)
Creates a binary builder.


createBinaryBuilder

public StringValue createBinaryBuilder(byte[] buffer)
Creates a binary builder.


createUnicodeBuilder

public StringValue createUnicodeBuilder()
Creates a unicode builder.


getDefaultTimeZone

public java.util.TimeZone getDefaultTimeZone()

getGmtDate

public QDate getGmtDate()

getLocalDate

public QDate getLocalDate()

getDate

public QDate getDate()

setDefaultTimeZone

public void setDefaultTimeZone(java.lang.String id)

setDefaultTimeZone

public void setDefaultTimeZone(java.util.TimeZone zone)

getServletContext

public ServletContext getServletContext()

setScriptContext

public void setScriptContext(javax.script.ScriptContext context)

getInputData

public StringValue getInputData()

setInputData

public void setInputData(StringValue data)

isStrict

public final boolean isStrict()
Returns true for strict mode.


isAllowUrlInclude

public boolean isAllowUrlInclude()

isAllowUrlFopen

public boolean isAllowUrlFopen()

getConnectionStatus

public int getConnectionStatus()
Returns the connection status


start

public void start()

getCurrentTime

public long getCurrentTime()
Returns the current time (may be cached).


getExactTime

public long getExactTime()
Returns the current time (not cached).


addCleanup

public void addCleanup(EnvCleanup envCleanup)
add resource to the list of refrences that are cleaned up when finished with this environment.


addObjectCleanup

public void addObjectCleanup(ObjectExtValue objCleanup)
add an object with a destructor to the list of references that are cleaned up when finished with this environment.


removeCleanup

public void removeCleanup(EnvCleanup envCleanup)
remove resource from the list of references that are cleaned up when finished with this environment.

Parameters:
resource -

getQuercus

public QuercusContext getQuercus()
Returns the owning PHP engine.


getModuleContext

public ModuleContext getModuleContext()
Returns the owning PHP engine.


getDatabase

public javax.sql.DataSource getDatabase()
Returns the configured database.


findDatabase

protected final javax.sql.DataSource findDatabase(java.lang.String driver,
                                                  java.lang.String url)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

getConnection

public ConnectionEntry getConnection(java.lang.String driver,
                                     java.lang.String url,
                                     java.lang.String userName,
                                     java.lang.String password,
                                     boolean isReuse)
                              throws java.lang.Exception
Returns a connection to the given database. If there is already a connection to this specific database, then return the connection from the pool. Otherwise, create a new connection and add it to the pool.

Throws:
java.lang.Exception

getDataSource

public javax.sql.DataSource getDataSource(java.lang.String driver,
                                          java.lang.String url)
                                   throws java.lang.Exception
Returns the configured database.

Throws:
java.lang.Exception

setTimeLimit

public void setTimeLimit(long ms)
Sets the time limit.


checkTimeout

public void checkTimeout()
Checks for the program timeout.


updateTimeout

public void updateTimeout()

resetTimeout

public void resetTimeout()

getStartTime

public long getStartTime()

getOut

public WriteStream getOut()
Returns the writer.


getOriginalOut

public WriteStream getOriginalOut()
Returns the writer.


flush

public final void flush()
Flushes the output buffer.


print

public final void print(java.lang.String v)
Prints a string


print

public final void print(char[] buffer,
                        int offset,
                        int length)
Prints a character buffer.


print

public final void print(char v)
Prints a char


print

public final void print(long v)
Prints a long


print

public final void print(double v)
Prints a double


print

public final void print(java.lang.Object v)
Prints an object


print

public final void print(Value v)
Prints a value


println

public final void println()
Prints a string


println

public final void println(java.lang.String v)
Prints a string


println

public final void println(Value v)
Prints a string


println

public final void println(java.lang.Object v)
Prints and object.


write

public final void write(byte[] buffer,
                        int offset,
                        int length)
Prints a byte buffer.


getOutputBuffer

public OutputBuffer getOutputBuffer()
Returns the current output buffer.


pushOutputBuffer

public void pushOutputBuffer(Callable callback,
                             int chunkSize,
                             boolean erase)
Returns the writer.


popOutputBuffer

public boolean popOutputBuffer()
Pops the output buffer


getPwd

public Path getPwd()
Returns the current directory.


getShellPwd

public java.lang.String getShellPwd()

getWorkDir

public Path getWorkDir()
Returns the current directory.


setPwd

public void setPwd(Path path)
Sets the current directory.


getSelfPath

public Path getSelfPath()
Returns the initial directory.


getSelfDirectory

public Path getSelfDirectory()
Returns the initial directory.


setSelfPath

public void setSelfPath(Path path)
Sets the initial directory.


getUploadDirectory

public Path getUploadDirectory()
Returns the upload directory.


getRealPath

public java.lang.String getRealPath(java.lang.String path)
Returns the real path.


getTempDirectory

public Path getTempDirectory()
Returns the temp directory (used by tmpfile()).


addRemovePath

public void addRemovePath(Path path)
Adds an auto-remove path.


getRequest

public HttpServletRequest getRequest()
Returns the request.


getResponse

public HttpServletResponse getResponse()
Returns the response.


setSessionCallback

public void setSessionCallback(SessionCallback callback)
Sets the session callback.


getSessionCallback

public SessionCallback getSessionCallback()
Gets the session callback.


getSession

public SessionArrayValue getSession()
Returns the session.


getJavaSession

public HttpSession getJavaSession()
Returns the Java Http session.


setSession

public void setSession(SessionArrayValue session)
Sets the session.


generateSessionId

public java.lang.String generateSessionId()
Returns a new session id.


createSession

public SessionArrayValue createSession(java.lang.String sessionId,
                                       boolean create)
Create the session.


destroySession

public void destroySession(java.lang.String sessionId)
Destroy the session.


getLogger

public java.util.logging.Logger getLogger()
Returns the logger used for syslog.


getConfigVar

public Value getConfigVar(java.lang.String name)
Returns the configuration value of an init var.


getIniMap

public java.util.HashMap<java.lang.String,Value> getIniMap(boolean create)
Returns a map of the ini values that have been explicitly set.


setIni

public StringValue setIni(java.lang.String name,
                          Value value)
Sets an ini value.


setIni

public StringValue setIni(java.lang.String name,
                          java.lang.String value)
Sets an ini value.


getIni

public StringValue getIni(java.lang.String name)
Returns an ini value.


getIniBoolean

public boolean getIniBoolean(java.lang.String name)
Returns an ini value.


getIniLong

public long getIniLong(java.lang.String name)
Returns an ini value as a long.


getIniString

public java.lang.String getIniString(java.lang.String name)
Returns an ini value as a string, null for missing or empty string


getIniBytes

public long getIniBytes(java.lang.String name,
                        long deflt)
Returns an ini value.


getByteToChar

public ByteToChar getByteToChar()
Returns the ByteToChar converter.


getThis

public Value getThis()
Returns the 'this' value.


setThis

public Value setThis(Value value)
Sets the 'this' value, returning the old value.


getValue

public Value getValue(StringValue name)
Gets a value.


getValue

public Value getValue(StringValue name,
                      boolean isAutoCreate,
                      boolean isOutputNotice)
Gets a value.


getSpecialValue

public java.lang.Object getSpecialValue(java.lang.String name)
Gets a special value, a special value is used to store and retrieve module specific values in the env using a unique name.


setSpecialValue

public java.lang.Object setSpecialValue(java.lang.String name,
                                        java.lang.Object value)
Sets a special value, a special value is used to store and retrieve module specific values in the env using a unique name.


getGlobalValue

public Value getGlobalValue(java.lang.String name)

getGlobalValue

public Value getGlobalValue(StringValue name)
Gets a global


getVar

public final Var getVar(StringValue name,
                        Value value)
Gets a variable

Parameters:
name - the variable name
var - the current value of the variable

getGlobalVar

public final Var getGlobalVar(StringValue name,
                              Value value)
Gets a variable

Parameters:
name - the variable name
value - the current value of the variable

getRef

public Var getRef(StringValue name)
Gets a value.


getRef

public Var getRef(StringValue name,
                  boolean isAutoCreate)
Gets a value.


getGlobalRaw

public EnvVar getGlobalRaw(java.lang.String name)
Returns the raw global lookup.


getGlobalRef

public Var getGlobalRef(StringValue name)
Gets a global value.


getEnvVar

public final EnvVar getEnvVar(StringValue name)

getEnvVar

public final EnvVar getEnvVar(StringValue name,
                              boolean isAutoCreate,
                              boolean isOutputNotice)
Gets a variable

Parameters:
name - the variable name
var - the current value of the variable

getGlobalEnvVar

public final EnvVar getGlobalEnvVar(StringValue name)
Gets a variable

Parameters:
name - the variable name

getGlobalEnvVar

public final EnvVar getGlobalEnvVar(StringValue name,
                                    boolean isAutoCreate,
                                    boolean isOutputNotice)
Gets a variable

Parameters:
name - the variable name
isAutoCreate -

pushEnv

public java.util.Map<StringValue,EnvVar> pushEnv(java.util.Map<StringValue,EnvVar> map)
Pushes a new environment.


popEnv

public void popEnv(java.util.Map<StringValue,EnvVar> oldEnv)
Restores the old environment.


getEnv

public java.util.Map<StringValue,EnvVar> getEnv()
Returns the current environment.


getGlobalEnv

public java.util.Map<StringValue,EnvVar> getGlobalEnv()
Returns the current environment.


isGlobalEnv

public boolean isGlobalEnv()

createStaticName

public final StringValue createStaticName()
Gets a static variable name.


getStaticVar

public final Var getStaticVar(StringValue name)
Gets a static variable

Parameters:
name - the variable name

getStaticValue

public final Value getStaticValue(StringValue name)
Gets a static variable

Parameters:
name - the variable name

setStaticRef

public final Var setStaticRef(StringValue name,
                              Value value)
Gets a static variable

Parameters:
name - the variable name

unsetVar

public final Var unsetVar(StringValue name)
Unsets variable

Parameters:
name - the variable name

setVar

public final Var setVar(java.lang.String name,
                        Value value)
Gets a variable

Parameters:
name - the variable name
value - the current value of the variable

unsetLocalVar

public final Var unsetLocalVar(StringValue name)
Unsets variable

Parameters:
name - the variable name

unsetGlobalVar

public final Var unsetGlobalVar(StringValue name)
Unsets variable

Parameters:
name - the variable name

getLocalVar

public static final Value getLocalVar(Value var)
Gets a local

Parameters:
var - the current value of the variable

getLocalValue

public static final Value getLocalValue(Value var)
Gets a local value

Parameters:
var - the current value of the variable

setLocalVar

public static final Value setLocalVar(Value var,
                                      Value value)
Gets a local

Parameters:
var - the current value of the variable

getQueryString

protected java.lang.String getQueryString()

getContentType

protected java.lang.String getContentType()

getCookies

protected ArrayValue getCookies()

setArgs

public void setArgs(java.lang.String[] args)

getGlobalSpecialRef

protected EnvVar getGlobalSpecialRef(StringValue name)
Gets a value.


getGlobalScriptContextRef

protected EnvVar getGlobalScriptContextRef(StringValue name)

decodeValue

protected static java.lang.String decodeValue(java.lang.String s)

getVar

public Var getVar(java.lang.String name)

getVar

public Var getVar(StringValue name)
Gets a value.


getGlobalVar

public Var getGlobalVar(java.lang.String name)
Gets a value.


getGlobalVar

public Var getGlobalVar(StringValue name)
Gets a value.


setValue

public void setValue(java.lang.String name,
                     Value value)

setValue

public Value setValue(StringValue name,
                      Value value)
Sets a value. value must not be a Var.


setVar

public Var setVar(StringValue name,
                  Var var)
Sets a variable.


setRef

public Var setRef(StringValue name,
                  Value value)
Sets a value.


setGlobalValue

public Value setGlobalValue(java.lang.String name,
                            Value value)
External calls to set a global value.


setGlobalValue

public Value setGlobalValue(StringValue name,
                            Value value)
External calls to set a global value.


pushCall

public void pushCall(Expr call,
                     Value obj,
                     Value[] args)
Sets the calling function expression.


popCall

public Expr popCall()
Pops the top call.


getCallDepth

public int getCallDepth()
Returns the stack depth.


peekCall

public Expr peekCall(int depth)
Peeks at the the top call.


peekCallThis

public Value peekCallThis(int depth)
Peeks at the "this" top call.


peekArgs

public Value[] peekArgs(int depth)
Peeks at the the top call.


allocateRegexpState

public RegexpState allocateRegexpState()
Allocate the free regexp


freeRegexpState

public void freeRegexpState(RegexpState state)
Free the free regexp


pushProfile

public void pushProfile(int id)

popProfile

public void popProfile(long nanos)

pushFieldGet

public boolean pushFieldGet(Env.OVERLOADING_TYPES type,
                            java.lang.String className,
                            StringValue fieldName)

popFieldGet

public void popFieldGet(Env.OVERLOADING_TYPES type)

getCallingClass

public QuercusClass getCallingClass()

getCallingClassName

public Value getCallingClassName()

getCallingClass

public QuercusClass getCallingClass(Value qThis)

setCallingClass

public QuercusClass setCallingClass(QuercusClass cls)

getStackTrace

public java.util.ArrayList<java.lang.String> getStackTrace()

setFunctionArgs

public final Value[] setFunctionArgs(Value[] args)
Pushes a new environment.


setFunctionArgsNoCopy

public final Value[] setFunctionArgsNoCopy(Value[] args)
Pushes a new environment.


restoreFunctionArgs

public final void restoreFunctionArgs(Value[] args)
Pushes a new environment.


getFunctionArgs

public final Value[] getFunctionArgs()
Returns the function args.


removeSpecialValue

public java.lang.Object removeSpecialValue(java.lang.String name)
Removes a specialValue


getConstant

public Value getConstant(java.lang.String name)
Returns a constant.


getConstant

public Value getConstant(java.lang.String name,
                         boolean isAutoCreateString)
Returns a constant.


isDefined

public boolean isDefined(java.lang.String name)
Returns true if the constant is defined.


getConstant

public Value getConstant(int id)
Returns a constant.


removeConstant

public Value removeConstant(java.lang.String name)
Removes a constant.


addConstant

public Value addConstant(java.lang.String name,
                         Value value,
                         boolean isCaseInsensitive)
Sets a constant.


addConstant

public Value addConstant(StringValue name,
                         Value value,
                         boolean isCaseInsensitive)
Sets a constant.


addConstant

public Value addConstant(int id,
                         Value value,
                         boolean isCaseInsensitive)
Sets a constant.


getDefinedConstants

public ArrayValue getDefinedConstants()
Returns an array of the defined functions.


isExtensionLoaded

public boolean isExtensionLoaded(java.lang.String name)
Returns true if an extension is loaded.


getLoadedExtensions

public java.util.HashSet<java.lang.String> getLoadedExtensions()
Returns true if an extension is loaded.


getExtensionFuncs

public Value getExtensionFuncs(java.lang.String name)
Returns true if an extension is loaded.


getDefaultStreamContext

public StreamContextResource getDefaultStreamContext()
Returns the default stream resource.


getDefinedFunctions

public ArrayValue getDefinedFunctions()

findFunctionId

public int findFunctionId(java.lang.String name)
Returns the function with a given name. Compiled mode normally uses the _fun array directly, so this call is rare.


findFunction

public AbstractFunction findFunction(java.lang.String name)
Returns the function with a given name. Compiled mode normally uses the _fun array directly, so this call is rare.


findFunction

public AbstractFunction findFunction(int id)
Returns the function with a given name. Compiled mode normally uses the _fun array directly, so this call is rare.


getFunction

public AbstractFunction getFunction(java.lang.String name)

updateFunction

public void updateFunction(int id,
                           AbstractFunction fun)

getFunction

public AbstractFunction getFunction(Value name)
Finds the java reflection method for the function with the given name.

Parameters:
name - the method name
Returns:
the found method or null if no method found.

addFunction

public Value addFunction(java.lang.String name,
                         AbstractFunction fun)

createAnonymousFunction

public AbstractFunction createAnonymousFunction(java.lang.String args,
                                                java.lang.String code)
                                         throws java.io.IOException
Throws:
java.io.IOException

addFunctionFromPage

public Value addFunctionFromPage(java.lang.String name,
                                 java.lang.String lowerName,
                                 AbstractFunction fun)
Adds a function from a compiled include

Parameters:
name - the function name, must be an intern() string
lowerName - the function name, must be an intern() string

findMethod

public AbstractFunction findMethod(java.lang.String className,
                                   java.lang.String methodName)
Finds the java reflection method for the function with the given name.

Parameters:
className - the class name
methodName - the method name
Returns:
the found method or null if no method found.

evalCode

public Value evalCode(java.lang.String code)
               throws java.io.IOException
Compiles and evalutes the given code

Parameters:
code - the code to evalute
Returns:
the result
Throws:
java.io.IOException

execute

public void execute()
             throws java.io.IOException
Evaluates the top-level code and prepend and append code.

Throws:
java.io.IOException

executeTop

public Value executeTop()
Evaluates the top-level code

Returns:
the result

executePage

protected Value executePage(QuercusPage page)
Executes the given page


executePageTop

protected Value executePageTop(QuercusPage page)
Executes the given page


call

public Value call(java.lang.String name)
Evaluates the named function.

Parameters:
name - the function name
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value a0)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value a0,
                  Value a1)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value a0,
                  Value a1,
                  Value a2)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value a0,
                  Value a1,
                  Value a2,
                  Value a3)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
a3 - the fourth argument
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value a0,
                  Value a1,
                  Value a2,
                  Value a3,
                  Value a4)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
a3 - the fourth argument
a4 - the fifth argument
Returns:
the function value

call

public Value call(java.lang.String name,
                  Value[] args)
Evaluates the named function.

Parameters:
name - the function name
args - the arguments
Returns:
the function value

callRef

public Value callRef(java.lang.String name)
Evaluates the named function.

Parameters:
name - the function name
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value a0)
EvalRefuates the named function.

Parameters:
name - the function name
a0 - the first argument
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value a0,
                     Value a1)
EvalRefuates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value a0,
                     Value a1,
                     Value a2)
EvalRefuates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value a0,
                     Value a1,
                     Value a2,
                     Value a3)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
a3 - the fourth argument
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value a0,
                     Value a1,
                     Value a2,
                     Value a3,
                     Value a4)
Evaluates the named function.

Parameters:
name - the function name
a0 - the first argument
a1 - the second argument
a2 - the third argument
a3 - the fourth argument
a4 - the fifth argument
Returns:
the function value

callRef

public Value callRef(java.lang.String name,
                     Value[] args)
Evaluates the named function.

Parameters:
name - the function name
args - the arguments
Returns:
the function value

addClassDef

public void addClassDef(java.lang.String name,
                        ClassDef cl)
Adds a class, e.g. from an include.


findClassDef

public ClassDef findClassDef(java.lang.String name)

saveState

public SaveState saveState()
Saves the current state


restoreState

public void restoreState(SaveState saveState)
Restores to a given state


createObject

public ObjectValue createObject()
Creates a stdClass object.


createIncompleteObject

public ObjectValue createIncompleteObject(java.lang.String name)
Creates a stdClass object.


getEmptyString

public StringValue getEmptyString()

createStringBuilder

public StringValue createStringBuilder()

createString

public StringValue createString(byte[] buffer,
                                int offset,
                                int length)
Creates a PHP string from a byte buffer.


createString

public StringValue createString(char[] buffer,
                                int length)
Creates a PHP string from a byte buffer.


createString

public StringValue createString(char[] buffer,
                                int offset,
                                int length)
Creates a PHP string from a char buffer.


createString

public StringValue createString(java.lang.String s)
Creates a PHP string from a java String.


createString

public StringValue createString(char ch)
Creates a string from a byte.


createBinaryString

public StringValue createBinaryString(TempBuffer head)
Creates a PHP string from a buffer.


createException

public Value createException(java.lang.String exceptionClass,
                             java.lang.String message)

createException

public Value createException(java.lang.Throwable e)
Creates a PHP Exception.


generateId

public int generateId()
Generate an object id.


getJavaClassDefinition

public JavaClassDef getJavaClassDefinition(java.lang.String className)
Returns an introspected Java class definition.


getJavaClassDefinition

public JavaClassDef getJavaClassDefinition(java.lang.Class<?> type)
Returns an introspected Java class definition.


importJavaClass

public JavaClassDef importJavaClass(java.lang.String className)
Imports a Java class.

Parameters:
className - name of class to import
Returns:
class definition of imported class, null if class not found

putQualifiedImport

public void putQualifiedImport(java.lang.String javaName)
Adds a Quercus class import.

Parameters:
javaName - fully qualified class import string

addWildcardImport

public void addWildcardImport(java.lang.String name)
Adds a Quercus class import.

Parameters:
name - wildcard class import string minus '*' at the end (i.e. java.util.)

wrapJava

public Value wrapJava(java.lang.Object obj,
                      boolean isNullAsFalse)
Returns a PHP value for a Java object

Parameters:
isNullAsFalse - what to return if obj is null, if true return BooleanValue.FALSE otherwise return {@link NullValue.NULL)

wrapJava

public Value wrapJava(java.lang.Object obj,
                      JavaClassDef def,
                      boolean isNullAsFalse)
Returns a PHP value for a Java object

Parameters:
isNullAsFalse - what to return if obj is null, if true return BooleanValue.FALSE otherwise return {@link NullValue.NULL)

wrapJava

public Value wrapJava(java.lang.Object obj)
Returns a PHP value for a Java object


wrapJava

public Value wrapJava(java.lang.Object obj,
                      JavaClassDef def)
Returns a PHP value for a Java object

Parameters:
isNullAsFalse - what to return if obj is null, if true return BooleanValue.FALSE otherwise return {@link NullValue.NULL)

findClass

public QuercusClass findClass(java.lang.String name)
Finds the class with the given name.

Parameters:
name - the class name
Returns:
the found class or null if no class found.

findClass

public QuercusClass findClass(java.lang.String name,
                              boolean useAutoload,
                              boolean useImport)
Finds the class with the given name.

Parameters:
name - the class name
useAutoload - use autoload to locate the class if necessary
Returns:
the found class or null if no class found.

findClass

public QuercusClass findClass(int id,
                              boolean useAutoload,
                              boolean useImport)

getClass

public QuercusClass getClass(int classId)
Returns the class with the given id


addClass

public void addClass(ClassDef def,
                     int classId,
                     int parentId)
Adds the class with the given name

Parameters:
def - the class definition
classId - the identifier for the class name
parentId - the identifier for the parent class name

addClass

public void addClass(java.lang.String name,
                     ClassDef def)

addAutoloadFunction

public void addAutoloadFunction(Callable fun)

removeAutoloadFunction

public void removeAutoloadFunction(Callable fun)

getAutoloadFunctions

public java.util.ArrayList<Callable> getAutoloadFunctions()

importPhpClass

public boolean importPhpClass(java.lang.String name)
Imports a PHP class.

Parameters:
name - of the PHP class
Returns:
true if matching php file was found and included.

getDeclaredClasses

public Value getDeclaredClasses()
Returns the declared classes.

Returns:
an array of the declared classes()

findAbstractClass

public QuercusClass findAbstractClass(java.lang.String name)
Finds the class with the given name.

Parameters:
name - the class name
Returns:
the found class or null if no class found.

getClass

public QuercusClass getClass(java.lang.String name)
Finds the class with the given name.

Parameters:
name - the class name
Returns:
the found class
Throws:
QuercusRuntimeException - if the class is not found

clearClassCache

public void clearClassCache()

isInitializedClass

public boolean isInitializedClass(java.lang.String name)
Returns true if class has already been initialized.


addInitializedClass

public void addInitializedClass(java.lang.String name)
Mark this class as being initialized.


findFunction

public AbstractFunction findFunction(java.lang.String className,
                                     java.lang.String methodName)
Finds the class and method.

Parameters:
className - the class name
methodName - the method name
Returns:
the found method or null if no method found.

requireOnce

public Value requireOnce(StringValue include)
Evaluates an included file.


require

public Value require(StringValue include)
Evaluates an included file.


include

public Value include(StringValue include)
Evaluates an included file.


includeOnce

public Value includeOnce(StringValue include)
Evaluates an included file.


includeOnce

public Value includeOnce(Path scriptPwd,
                         StringValue include,
                         boolean isRequire)
Evaluates an included file.


include

public Value include(Path scriptPwd,
                     StringValue include,
                     boolean isRequire,
                     boolean isOnce)
Evaluates an included file.


lookupPwd

public Path lookupPwd(Value relPathV)
Looks up based on the pwd.


lookup

public Path lookup(StringValue relPath)
Looks up the path.


lookupInclude

public Path lookupInclude(StringValue relPath)
Looks up the path.


setIncludePath

public java.lang.String setIncludePath(java.lang.String path)
Sets the include path.


normalizePath

public java.lang.String normalizePath(java.lang.CharSequence path)

restoreIncludePath

public void restoreIncludePath()
Restores the default include path.


getIncludedFiles

public ArrayValue getIncludedFiles()
Returns all the included files.


suppress

public Value suppress(int errorMask,
                      Value value)
Handles error suppression.


exit

public Value exit(Value msg)
Handles exit/die


exit

public Value exit()
Handles exit/die


die

public Value die(java.lang.String msg)
Handles exit/die


die

public Value die()
Handles exit/die


cast

public Value cast(java.lang.Class cl,
                  Value value)
Handles exit/die


first

public static Value first(Value value)
Returns the first value


first

public static Value first(Value value,
                          Value a1)
Returns the first value


first

public static Value first(Value value,
                          double a1)
Returns the first value


first

public static long first(long value,
                         Value a1)
Returns the first value


first

public static double first(double value,
                           Value a1)
Returns the first value


first

public static long first(long value,
                         double a1)
Returns the first value


first

public static double first(double value,
                           double a1)
Returns the first value


first

public static Value first(Value value,
                          Value a1,
                          Value a2)
Returns the first value


first

public static Value first(Value value,
                          Value a1,
                          Value a2,
                          Value a3)
Returns the first value


first

public static Value first(Value value,
                          Value a1,
                          Value a2,
                          Value a3,
                          Value a4)
Returns the first value


first

public static Value first(Value value,
                          Value a1,
                          Value a2,
                          Value a3,
                          Value a4,
                          Value a5)
Returns the first value


expectString

public Value expectString(Value value)
Check for expected type.


expectNumeric

public Value expectNumeric(Value value)
Check for expected type.


expectBoolean

public Value expectBoolean(Value value)
Check for expected type.


checkTypeHint

public void checkTypeHint(Value value,
                          java.lang.String type,
                          java.lang.String argName,
                          java.lang.String functionName)
Check for type hinting


error

public Value error(java.lang.String msg)
A fatal runtime error.


error

public Value error(Location location,
                   java.lang.String msg)
A fatal runtime error.


error

public Value error(java.lang.String loc,
                   java.lang.String msg)
A fatal runtime error.


error

public Value error(java.lang.String msg,
                   java.lang.Throwable e)
A warning with an exception.


error

public Value error(java.lang.Throwable e)
A warning with an exception.


createErrorException

public QuercusRuntimeException createErrorException(java.lang.String msg)
                                             throws QuercusRuntimeException
A fatal runtime error.

Throws:
QuercusRuntimeException

createErrorException

public QuercusRuntimeException createErrorException(Location location,
                                                    java.lang.String msg)
                                             throws QuercusRuntimeException
A fatal runtime error.

Throws:
QuercusRuntimeException

createErrorException

public QuercusRuntimeException createErrorException(java.lang.Throwable e)
                                             throws QuercusRuntimeException
A fatal runtime error.

Throws:
QuercusRuntimeException

warning

public Value warning(java.lang.String msg)
A runtime warning.


warning

public Value warning(Location location,
                     java.lang.String msg)
A runtime warning.


warning

public Value warning(java.lang.String msg,
                     java.lang.Throwable e)
A warning with an exception.


warning

public Value warning(Location location,
                     java.lang.String msg,
                     java.lang.Throwable e)
A warning with an exception.


warning

public Value warning(java.lang.Throwable e)
A warning with an exception.


warning

public Value warning(Location location,
                     java.lang.Throwable e)
A warning with an exception.


strict

public Value strict(java.lang.String msg)
A runtime strict warning.


invalidArgument

public Value invalidArgument(java.lang.String name,
                             java.lang.Object value)
A warning about an invalid argument passed to a function.


deprecatedArgument

public Value deprecatedArgument(java.lang.String name)
A warning about an deprecated argument passed to a function.


notice

public Value notice(java.lang.String msg)
A notice.


notice

public Value notice(java.lang.String msg,
                    java.lang.Throwable e)
A notice with an exception.


stub

public Value stub(java.lang.String msg)
A stub notice.


nullAsFalse

public static Value nullAsFalse(Value value)

parse

public Value parse(java.lang.String msg)
            throws java.lang.Exception
A parse error

Throws:
java.lang.Exception

compileError

public Value compileError(java.lang.String msg)
A parse error


compileWarning

public Value compileWarning(java.lang.String msg)
A parse warning


getErrorMask

public int getErrorMask()
Returns the error mask.


setErrorMask

public int setErrorMask(int mask)
Sets the error mask.


setErrorHandler

public void setErrorHandler(int mask,
                            Callable fun)
Sets an error handler


restoreErrorHandler

public void restoreErrorHandler()
Sets an error handler


getExceptionHandler

public Callable getExceptionHandler()
Gets the exception handler


setExceptionHandler

public Value setExceptionHandler(Callable fun)
Sets an exception handler


restoreExceptionHandler

public void restoreExceptionHandler()
Restore an exception handler


error

public Value error(int code,
                   java.lang.String locString,
                   java.lang.String msg)

error

public Value error(int code,
                   Location location,
                   java.lang.String msg)

error

public Value error(int code,
                   Location location,
                   java.lang.String loc,
                   java.lang.String msg)
Writes an error.


getSourceLine

public static java.lang.String[] getSourceLine(Path path,
                                               int sourceLine,
                                               int length)
Returns the source of an error line.


setLocation

public final Location setLocation(Location newLocation)

getLocationImpl

protected final Location getLocationImpl()

getLocation

public Location getLocation()
Returns the current execution location. Use with care, for compiled code this can be a relatively expensive operation.


getSourceLine

public int getSourceLine(java.lang.String className,
                         int javaLine)

getFunctionLocation

public java.lang.String getFunctionLocation()
Returns the current function.


toValue

public static Value toValue(boolean value)
Converts a boolean to the boolean value


toValue

public static Value toValue(long value)
Converts a boolean to the boolean value


toVar

public static Var toVar(Value value)
Converts to a variable


setFieldVar

public static Value setFieldVar(Value oldValue,
                                Value value)
Sets a vield variable


setRef

public static Value setRef(Value oldValue,
                           Value value)
Sets a reference


setEnvRef

public static Var setEnvRef(Var oldVar,
                            Value value)
Sets a reference


comma

public static Value comma(Value a0,
                          Value a1)
Returns the last value.


comma

public static Value comma(Value a0,
                          Value a1,
                          Value a2)
Returns the last value.


comma

public static Value comma(Value a0,
                          Value a1,
                          Value a2,
                          Value a3)
Returns the last value.


comma

public static Value comma(Value a0,
                          Value a1,
                          Value a2,
                          Value a3,
                          Value a4)
Returns the last value.


comma

public static long comma(Value a0,
                         long a1)
Returns the last value.


comma

public static long comma(long a0,
                         long a1)
Returns the last value.


comma

public static Value comma(long a0,
                          Value a1)
Returns the last value.


comma

public static double comma(Value a0,
                           double a1)
Returns the last value.


comma

public static double comma(double a0,
                           double a1)
Returns the last value.


comma

public static Value comma(double a0,
                          Value a1)
Returns the last value.


toString

public java.lang.String toString()
Calls a parent::name method.

Overrides:
toString in class java.lang.Object

ifNull

public Value ifNull(Value condition,
                    Value ifNull,
                    Value ifNotNull)
Returns ifNull if condition.isNull(), otherwise returns ifNotNull.


getLocaleInfo

public LocaleInfo getLocaleInfo()
Returns the locale info.


getMicroTime

public long getMicroTime()

addShutdown

public void addShutdown(Callable callback,
                        Value[] args)
Registers a shutdown function.


setGzStream

public void setGzStream(java.lang.Object obj)

getGzStream

public java.lang.Object getGzStream()

startDuplex

public void startDuplex(java.lang.Object duplex)

closeDuplex

public void closeDuplex()

getDuplex

public java.lang.Object getDuplex()

close

public void close()
Called when the Env is no longer needed.


sessionWriteClose

public void sessionWriteClose()

dbgId

public java.lang.String dbgId()