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

org.apache.torque.mojo.morph.DataMorpher Maven / Gradle / Ivy

Go to download

Maven plugin for converting database agnostic XML files into platform specific SQL files and for examining proprietary databases via JDBC to generate database agnostic XML files

The newest version!
package org.apache.torque.mojo.morph;

import org.codehaus.plexus.util.StringUtils;

public class DataMorpher extends Morpher {
	// Ant prologue
	String antPrologue = "";
	// New prologue
	String newPrologue = "";

	// The hard coded Ant impex document type
	String antDocType = "";

	public DataMorpher() {
		this(null, null);
	}

	public DataMorpher(MorphRequest morphRequest, String artifactId) {
		super(morphRequest, artifactId);
	}

	protected String getNewDocType() {
		return "";
	}

	protected String getMorphedContents(String contents) {
		contents = StringUtils.replace(contents, antPrologue, newPrologue);
		return StringUtils.replace(contents, antDocType, getNewDocType());
	}

	/**
	 * Return true if we need to morph this file
	 */
	protected boolean isMorphNeeded(String contents) {
		// Look for the DTD the Maven Impex Plugin uses
		int pos = contents.indexOf(getNewDocType());

		if (pos == -1) {
			// It isn't there so we should morph
			return true;
		} else {
			// It is already there, we are good to go
			return false;
		}
	}

	public String getAntPrologue() {
		return antPrologue;
	}

	public void setAntPrologue(String antPrologue) {
		this.antPrologue = antPrologue;
	}

	public String getNewPrologue() {
		return newPrologue;
	}

	public void setNewPrologue(String newPrologue) {
		this.newPrologue = newPrologue;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy