001/* 002 GRANITE DATA SERVICES 003 Copyright (C) 2011 GRANITE DATA SERVICES S.A.S. 004 005 This file is part of Granite Data Services. 006 007 Granite Data Services is free software; you can redistribute it and/or modify 008 it under the terms of the GNU Library General Public License as published by 009 the Free Software Foundation; either version 2 of the License, or (at your 010 option) any later version. 011 012 Granite Data Services is distributed in the hope that it will be useful, but 013 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License 015 for more details. 016 017 You should have received a copy of the GNU Library General Public License 018 along with this library; if not, see <http://www.gnu.org/licenses/>. 019*/ 020 021package org.granite.generator.java; 022 023import java.io.File; 024 025import org.granite.generator.Listener; 026import org.granite.generator.as3.ClientType; 027import org.granite.generator.as3.JavaAs3GroovyConfiguration; 028import org.granite.generator.as3.JavaClientGroovyTransformer; 029import org.granite.generator.as3.JavaAs3Input; 030import org.granite.generator.gsp.GroovyTemplate; 031 032/** 033 * @author Franck WOLFF 034 */ 035public class JavaGroovyTransformer extends JavaClientGroovyTransformer { 036 037 private static final String GENERATED_FILE_EXTENSION = "java"; 038 039 public JavaGroovyTransformer() { 040 } 041 042 public JavaGroovyTransformer(JavaAs3GroovyConfiguration config, Listener listener) { 043 super(config, listener); 044 } 045 046 @Override 047 protected File getOutputFile(JavaAs3Input input, GroovyTemplate template, File outputDir) { 048 ClientType clientType = input.getJavaType().getClientType(); 049 050 StringBuilder sb = new StringBuilder() 051 .append(outputDir.getAbsolutePath()) 052 .append(File.separatorChar) 053 .append(clientType.getQualifiedName().replace('.', File.separatorChar)) 054 .append(getOutputFileSuffix(input, template)) 055 .append('.') 056 .append(GENERATED_FILE_EXTENSION); 057 058 return new File(sb.toString()); 059 } 060}