KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > jet > JETConstantDataGenerator


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: JETConstantDataGenerator.java,v 1.2 2005/06/08 06:15:56 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.jet;
18
19
20
21 /**
22  * The JETConstantDataGenerator generates constant declaration of the strings.
23  */

24 public class JETConstantDataGenerator
25   extends JETCharDataGenerator
26 {
27   protected static final String JavaDoc CONSTANT_DECLARATION_BEGIN = "protected final String ";
28   protected static final String JavaDoc CONSTANT_DECLARATION_MIDDLE = " = ";
29   protected static final String JavaDoc CONSTANT_DECLARATION_END = ";";
30
31   protected String JavaDoc label;
32
33   public JETConstantDataGenerator(char[] characters, String JavaDoc label)
34   {
35     super(characters);
36     this.label = label;
37   }
38
39   public String JavaDoc generate()
40   {
41     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc(FUNCTION_CALL_BEGIN);
42     stringBuffer.append(label);
43     stringBuffer.append(FUNCTION_CALL_END);
44     return stringBuffer.toString();
45   }
46
47   public String JavaDoc generateConstant()
48   {
49     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc(CONSTANT_DECLARATION_BEGIN);
50     stringBuffer.append(label);
51     stringBuffer.append(CONSTANT_DECLARATION_MIDDLE);
52     stringBuffer.append(generateCharData());
53     stringBuffer.append(CONSTANT_DECLARATION_END);
54     return stringBuffer.toString();
55   }
56 }
57
Popular Tags