KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > page > InterpretedPage


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.quercus.page;
31
32 import com.caucho.quercus.env.Env;
33 import com.caucho.quercus.env.Value;
34 import com.caucho.quercus.program.AbstractFunction;
35 import com.caucho.quercus.program.ClassDef;
36 import com.caucho.quercus.program.InterpretedClassDef;
37 import com.caucho.quercus.program.QuercusProgram;
38 import com.caucho.vfs.Path;
39
40 import java.util.HashMap JavaDoc;
41
42 /**
43  * Represents an interpreted Quercus program.
44  */

45 public class InterpretedPage extends QuercusPage
46 {
47   private final QuercusProgram _program;
48
49   public InterpretedPage(QuercusProgram program)
50   {
51     _program = program;
52   }
53   
54   /**
55    * Execute the program
56    *
57    * @param env the calling environment
58    */

59   public Value execute(Env env)
60   {
61     return _program.execute(env);
62   }
63
64   /**
65    * Returns the pwd according to the source page.
66    */

67   public Path getPwd(Env env)
68   {
69     return getSelfPath(env).getParent();
70   }
71
72   /**
73    * Returns the pwd according to the source page.
74    */

75   public Path getSelfPath(Env env)
76   {
77     return _program.getSourcePath();
78   }
79   
80   /**
81    * Imports the page definitions.
82    */

83   public void init(Env env)
84   {
85     _program.init(env);
86   }
87
88   /**
89    * Imports the page definitions.
90    */

91   public void importDefinitions(Env env)
92   {
93     _program.importDefinitions(env);
94   }
95
96   /**
97    * Finds the function
98    */

99   public AbstractFunction findFunction(String JavaDoc name)
100   {
101     return _program.findFunction(name);
102   }
103
104   /**
105    * Finds the class
106    */

107   public InterpretedClassDef findClass(String JavaDoc name)
108   {
109     //return _program.findClass(name);
110
return null;
111   }
112
113   /**
114    * Returns the class map.
115    */

116   public HashMap JavaDoc<String JavaDoc,ClassDef> getClassMap()
117   {
118     //return _program.getClassMap();
119
return null;
120   }
121
122   public boolean equals(Object JavaDoc o)
123   {
124     if (! (o instanceof InterpretedPage))
125       return false;
126
127     InterpretedPage page = (InterpretedPage) o;
128
129     return _program == page._program;
130   }
131   
132   public String JavaDoc toString()
133   {
134     return "InterpretedPage[" + _program.getSourcePath() + "]";
135   }
136 }
137
138
Popular Tags