blob: 5486de9c8569e42604771c11446ce996cf2e8d8e [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Thales Corporate Services S.A.S - initial API and implementation
*
* </copyright>
*/
package org.eclipse.egf.pattern.utils;
import org.eclipse.egf.model.fcore.NamedModelElement;
import org.eclipse.egf.model.pattern.PatternMethod;
import org.eclipse.egf.pattern.extension.PatternFactory;
/**
* @author Thomas Guiu
*
*/
public class JavaMethodGenerationHelper {
private final String bufferName;
private StringBuilder content;
public JavaMethodGenerationHelper(String bufferName) {
this.bufferName = bufferName;
}
public void addCallStatement(PatternMethod called) {
content.append("method_").append(called.getName()).append("(ictx.getBuffer(), ictx);"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void addSignature(PatternMethod called) {
content.append("protected void method_").append(called.getName()).append("(final StringBuffer ").append(bufferName).append(", final PatternContext ctx)throws Exception "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void addConditionSignature(PatternMethod called) {
content.append("public boolean ").append(PatternFactory.PRECONDITION_METHOD_NAME).append("() throws Exception "); //$NON-NLS-1$ //$NON-NLS-2$
}
public void setContent(StringBuilder content) {
this.content = content;
}
public static String getSetterMethod(NamedModelElement paramOrVariable) {
String name = paramOrVariable.getName();
return "set_" + name; //$NON-NLS-1$
}
}