KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > rebind > AbstractMethodCreator


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.user.rebind;
17
18 import com.google.gwt.core.ext.TreeLogger;
19 import com.google.gwt.core.ext.UnableToCompleteException;
20 import com.google.gwt.core.ext.typeinfo.JMethod;
21
22 /**
23  * Creates method factories depending upon the method type. Includes the core
24  * concrete implementations as package-protected classes to avoid cluttering up
25  * the package space.
26  */

27 public abstract class AbstractMethodCreator extends AbstractSourceCreator {
28   /**
29    * AbstractGeneratorClassCreator associated with the method currently in
30    * process.
31    */

32   protected AbstractGeneratorClassCreator currentCreator;
33
34   /**
35    * Constructor for <code>AbstractMethodCreator</code>.
36    *
37    * @param classCreator
38    */

39   public AbstractMethodCreator(AbstractGeneratorClassCreator classCreator) {
40     this.currentCreator = classCreator;
41   }
42
43   /**
44    * Generate the method body for the target method.
45    *
46    * @param logger
47    * @param targetMethod Method
48    * @param value Arbitrary value
49    * @throws UnableToCompleteException
50    */

51   public abstract void createMethodFor(TreeLogger logger, JMethod targetMethod,
52       String JavaDoc value) throws UnableToCompleteException;
53
54   /**
55    * Prints to the current <code>AbstractGeneratorClassCreator</code>.
56    *
57    * @param printMe <code>Object</code> to print
58    */

59   public void println(Object JavaDoc printMe) {
60     currentCreator.getWriter().println(printMe.toString());
61   }
62
63   /**
64    * Indent subsequent lines.
65    */

66   protected void indent() {
67     currentCreator.getWriter().indent();
68   }
69
70   /**
71    * Outdent subsequent lines.
72    */

73   protected void outdent() {
74     currentCreator.getWriter().outdent();
75   }
76
77   /**
78    * Prints to the current <code>AbstractGeneratorClassCreator</code>.
79    *
80    * @param printMe
81    */

82   protected void print(String JavaDoc printMe) {
83     currentCreator.getWriter().print(printMe);
84   }
85 }
86
Popular Tags