![JAR search and dependency download from the Maven repository](/logo.png)
org.objectfabric.FileGenerator Maven / Gradle / Ivy
/**
* This file is part of ObjectFabric (http://objectfabric.org).
*
* ObjectFabric is licensed under the Apache License, Version 2.0, the terms
* of which may be found at http://www.apache.org/licenses/LICENSE-2.0.html.
*
* Copyright ObjectFabric Inc.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
package org.objectfabric;
import java.lang.reflect.Method;
abstract class FileGenerator {
static {
JVMPlatform.loadClass();
}
final String Path;
final String Name;
final String Package;
private final GeneratorBase _generator;
private String _tab = "";
FileGenerator(GeneratorBase generator, String packag, String name) {
_generator = generator;
Package = packag;
Name = name;
String path = generator.folder();
if (generator.isJava())
path += "/" + packag.replace('.', '/');
Path = path + "/" + name + generator.target().extension();
}
final GeneratorBase g() {
return _generator;
}
void copyright() {
if (g().copyright() != null)
wl(g().copyright());
}
void warning() {
wl("//==============================================================================");
wl("// ");
wl("// THIS FILE HAS BEEN GENERATED BY OBJECTFABRIC ");
wl("// ");
wl("//==============================================================================");
wl();
}
void header() {
}
void body() {
}
void footer() {
}
void generate() {
header();
body();
footer();
}
void wl() {
_generator.append(Platform.get().lineSeparator());
}
void wl(String line) {
line = onLine(line);
_generator.append(_tab + line + Platform.get().lineSeparator());
}
String onLine(String line) {
return line;
}
void write(StringBuilder sb) {
_generator.append(sb);
}
void tab() {
_tab += " ";
}
void untab() {
_tab = _tab.substring(4);
}
String getReturned(Method method) {
if (method.getReturnType().isArray())
return method.getReturnType().getComponentType().getName() + "[]";
return method.getReturnType().getName();
}
String addParameterTypeString(Class type, String current) {
if (current.length() > 0)
current += ", ";
if (type.isArray())
current += type.getComponentType().getName() + "[]";
else
current += type.getName();
return current;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy