01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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
28: AbstractSourceCreator {
29: /**
30: * AbstractGeneratorClassCreator associated with the method currently in
31: * process.
32: */
33: protected AbstractGeneratorClassCreator currentCreator;
34:
35: /**
36: * Constructor for <code>AbstractMethodCreator</code>.
37: *
38: * @param classCreator
39: */
40: public AbstractMethodCreator(
41: AbstractGeneratorClassCreator classCreator) {
42: this .currentCreator = classCreator;
43: }
44:
45: /**
46: * Generate the method body for the target method.
47: *
48: * @param logger
49: * @param targetMethod Method
50: * @param value Arbitrary value
51: * @throws UnableToCompleteException
52: */
53: public abstract void createMethodFor(TreeLogger logger,
54: JMethod targetMethod, String value)
55: throws UnableToCompleteException;
56:
57: /**
58: * Prints to the current <code>AbstractGeneratorClassCreator</code>.
59: *
60: * @param printMe <code>Object</code> to print
61: */
62: public void println(Object printMe) {
63: currentCreator.getWriter().println(printMe.toString());
64: }
65:
66: /**
67: * Indent subsequent lines.
68: */
69: protected void indent() {
70: currentCreator.getWriter().indent();
71: }
72:
73: /**
74: * Outdent subsequent lines.
75: */
76: protected void outdent() {
77: currentCreator.getWriter().outdent();
78: }
79:
80: /**
81: * Prints to the current <code>AbstractGeneratorClassCreator</code>.
82: *
83: * @param printMe
84: */
85: protected void print(String printMe) {
86: currentCreator.getWriter().print(printMe);
87: }
88: }
|