View Javadoc

1   /*
2    * Copyright (C) 1998-2001 Semiotek Inc.  All Rights Reserved.
3    *
4    * Redistribution and use in source and binary forms, with or without
5    * modification, are permitted under the terms of either of the following
6    * Open Source licenses:
7    *
8    * The GNU General Public License, version 2, or any later version, as
9    * published by the Free Software Foundation
10   * (http://www.fsf.org/copyleft/gpl.html);
11   *
12   *  or
13   *
14   * The Semiotek Public License (http://webmacro.org/LICENSE.)
15   *
16   * This software is provided "as is", with NO WARRANTY, not even the
17   * implied warranties of fitness to purpose, or merchantability. You
18   * assume all risks and liabilities associated with its use.
19   *
20   * See www.webmacro.org for more information on the WebMacro project.
21   */
22  
23  
24  /***
25   * EvaluationExceptionHandler
26   *
27   * An interface for specifying how certain classes of errors will be
28   * handled.  The handle method is called when an exception is thrown
29   * when trying to expand a variable or property reference.  The error
30   * and warning methods are called from directives and context tools to
31   * generate output warnings.  Any of these routines may throw exceptions,
32   * in which case the enclosing servlet will catch it and generate an error
33   * which the user sees (useful for debugging.)
34   *
35   * @author Brian Goetz
36   * @since 0.96 */
37  
38  package org.webmacro.engine;
39  
40  import org.webmacro.Broker;
41  import org.webmacro.Context;
42  import org.webmacro.PropertyException;
43  import org.webmacro.util.Settings;
44  
45  public interface EvaluationExceptionHandler
46  {
47  
48      /***
49       * Initialize the EEH
50       */
51      public void init (Broker b, Settings config);
52  
53      /***
54       * When an exception is detected in the process of expanding (writing)
55       * a variable reference, this method is consulted.  It either throws
56       * an exception, or it returns a String which can be written to the
57       * output in place of the property expansion.
58       */
59      public String expand (Variable variable,
60                            Context context,
61                            Exception problem)
62              throws PropertyException;
63  
64      /***
65       * When an exception is detected in the process of evaluating
66       * a variable reference, this method is consulted.  It either returns,
67       * in which case the caller is supposed to supply a default value (like
68       * null), or will throw.
69       */
70      public void evaluate (Variable variable,
71                            Context context,
72                            Exception problem)
73              throws PropertyException;
74  
75      public String warningString (String warningText)
76              throws PropertyException;
77  
78      public String errorString (String errorText)
79              throws PropertyException;
80  
81  }