View Javadoc

1   package net.sf.tomp.xml.type.xtcl;
2   
3   import net.sf.tomp.xml.type.TypeDatabase;
4   import net.sf.tomp.xml.type.TypeDetectorFilter;
5   import net.sf.tomp.xtcl.Context;
6   import net.sf.tomp.xtcl.command.FilterCommand;
7   
8   import java.io.PrintStream;
9   
10  /***
11   * DOCUMENT ME!
12   * 
13   * @author tomp
14   */
15  public class TypeDetectorFilterCommand extends FilterCommand {
16      /*** DOCUMENT ME! */
17      protected String tdVar;
18  
19      /***
20       * DOCUMENT ME!
21       * 
22       * @param v DOCUMENT ME!
23       */
24      public void setTypeDatabaseVar(String v) {
25          tdVar = v;
26      }
27  
28      /***
29       * DOCUMENT ME!
30       * 
31       * @param context DOCUMENT ME!
32       * @return DOCUMENT ME!
33       * @throws Exception DOCUMENT ME!
34       */
35      public int execute(Context context) throws Exception {
36          PrintStream out = context.getOut();
37  
38          if (out == null) {
39              return 0;
40          }
41  
42          TypeDetectorFilter tf = new TypeDetectorFilter();
43          TypeDatabase tdb = (TypeDatabase) context.get(tdVar);
44  
45          if (tdb == null) {
46              out.print("ERR " + this);
47  
48              return 1;
49          } else {
50              tf.setTypeDatabase(tdb);
51              initFilter(tf, context);
52              context.put(var, tf);
53              out.print("OK " + this);
54  
55              return 0;
56          }
57      }
58  
59      /***
60       * DOCUMENT ME!
61       * 
62       * @return DOCUMENT ME!
63       */
64      public String toString() {
65          return "TYPEDETECTORFILTER " + var + " type-database=" + tdVar + " ("
66                  + listMap(params) + ")";
67      }
68  }
69  
70  /*
71   * The contents of this file are subject to the Mozilla Public License Version
72   * 1.1 (the "License"); you may not use this file except in compliance with the
73   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
74   * Software distributed under the License is distributed on an "AS IS" basis,
75   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
76   * the specific language governing rights and limitations under the License. The
77   * Original Code is: all this file. The Initial Developer of the Original Code
78   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
79   */