View Javadoc

1   package net.sf.tomp.xtcl.command;
2   
3   import net.sf.tomp.xtcl.Context;
4   
5   import org.w3c.dom.Document;
6   
7   import javax.xml.parsers.DocumentBuilder;
8   
9   import java.io.PrintStream;
10  
11  /***
12   * DOCUMENT ME!
13   * 
14   * @author tomp
15   */
16  public class Doc extends VarCommand {
17      /***
18       * DOCUMENT ME!
19       * 
20       * @param context DOCUMENT ME!
21       * @return DOCUMENT ME!
22       * @throws Exception DOCUMENT ME!
23       */
24      public int execute(Context context) throws Exception {
25          DocumentBuilder db = context.getDocumentBuilder();
26          PrintStream out = context.getOut();
27          Document doc = db.newDocument();
28  
29          context.put(var, doc);
30  
31          if (out != null) {
32              out.print("OK " + this);
33          }
34  
35          return 0;
36      }
37  
38      /***
39       * DOCUMENT ME!
40       * 
41       * @return DOCUMENT ME!
42       */
43      public String toString() {
44          return "DOCUMENT " + var;
45      }
46  }
47  
48  /*
49   * The contents of this file are subject to the Mozilla Public License Version
50   * 1.1 (the "License"); you may not use this file except in compliance with the
51   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
52   * Software distributed under the License is distributed on an "AS IS" basis,
53   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
54   * the specific language governing rights and limitations under the License. The
55   * Original Code is: all this file. The Initial Developer of the Original Code
56   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
57   */