All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.tool.schema.internal.exec.GenerationTargetToScript Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.tool.schema.internal.exec;

import org.hibernate.tool.schema.spi.SchemaManagementException;
import org.hibernate.tool.schema.spi.ScriptTargetOutput;

/**
 * GenerationTarget implementation for handling generation to scripts
 *
 * @author Steve Ebersole
 */
public class GenerationTargetToScript implements GenerationTarget {

	private final ScriptTargetOutput scriptTarget;
	private final String delimiter;

	public GenerationTargetToScript(
			ScriptTargetOutput scriptTarget,
			String delimiter) {
		if ( scriptTarget == null ) {
			throw new SchemaManagementException( "ScriptTargetOutput cannot be null" );
		}
		this.scriptTarget = scriptTarget;
		this.delimiter = delimiter;
	}

	@Override
	public void prepare() {
		scriptTarget.prepare();
	}

	@Override
	public void accept(String command) {
		if ( delimiter != null ) {
			command += delimiter;
		}
		scriptTarget.accept( command );
	}

	@Override
	public void release() {
		scriptTarget.release();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy