ruper2/src/java/core/org/krysalis/ruper/api/tool FileUpdater.java,NONE,1.1 ClasspathUpdater.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/api/tool
In directory sc8-pr-cvs1:/tmp/cvs-serv13800/src/java/core/org/krysalis/ruper/api/tool

Added Files:
	FileUpdater.java ClasspathUpdater.java 
Log Message:
Tools and APIs (still not happy w/ this stuff)

--- NEW FILE: FileUpdater.java ---
/*
 * Created on Aug 27, 2003
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.krysalis.ruper.api.tool;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import org.krysalis.ruper.ResourceUpdater;
import org.krysalis.ruper.RuperException;
import org.krysalis.ruper.api.FileAPI;
import org.krysalis.ruper.impl.ResourceUpdaterIdentifier;
import org.krysalis.ruper.query.ResourceRequest;
import org.krysalis.ruper.query.ResourceRequestContext;
import org.krysalis.ruper.query.ResourceResult;
import org.krysalis.ruper.repository.DefaultRepositorySet;
import org.krysalis.ruper.repository.RepositorySet;
import org.krysalis.ruper.util.RuperConstants;
import org.krysalis.ruper.util.text.Messages;
import org.krysalis.version.util.debug.DebugUtils;

/**
 * @author arb_jack
 */
public class FileUpdater /* implements Referenceable */ {
	private ResourceUpdater m_ruper = null;
	private FileAPI m_api = null;
	private RepositorySet m_repos = null;

	/**
	 * 
	 */
	public FileUpdater() throws RuperException {
		this(
			new FileAPI(),
			new ResourceUpdaterIdentifier(RuperConstants.DEFAULT));
	}

	/**
	 * 
	 */
	public FileUpdater(String identifier) throws RuperException {
		this(new FileAPI(), new ResourceUpdaterIdentifier(identifier));
	}

	/**
	 * 
	 */
	public FileUpdater(FileAPI api, String identifier) throws RuperException {
		this(api, new ResourceUpdaterIdentifier(identifier));
	}

	/**
	 * 
	 */
	public FileUpdater(FileAPI api, ResourceUpdaterIdentifier identifier)
		throws RuperException {
		this(api, ResourceUpdater.getResourceUpdater(identifier, true));
	}

	/**
	 * 
	 */
	public FileUpdater(FileAPI api, ResourceUpdater ruper) {
		m_ruper = ruper;
		m_api = api;
		m_repos = new DefaultRepositorySet();
	}

	/**
	* 
	*/
	public FileUpdater(ResourceUpdater ruper) {
		m_ruper = ruper;
		m_api = new FileAPI();
		m_repos = new DefaultRepositorySet();
	}

	public void updateFilesInPlace(List files) throws RuperException {
		for (Iterator i = files.iterator(); i.hasNext();) {
			updateFileInPlace((File) i.next());
		}
	}

	public void updateFileInPlace(File file) throws RuperException {
		ResourceRequest request =
			new ResourceRequest(m_api.getResourceSpecifierForFile(file));

		ResourceRequestContext context = new ResourceRequestContext();

		context.getLogger().debug(
			Messages.getString("ResourceRequest", request));

		ResourceResult result = m_ruper.query(m_repos, request, context);

		DebugUtils.dump(result);
	}

	public ResourceResult determineFileUpdates(String fileName)
		throws RuperException {
		return determineFileUpdates(new File(fileName));
	}

	public ResourceResult determineFileUpdates(File file)
		throws RuperException {
		ResourceRequest request =
			new ResourceRequest(m_api.getResourceSpecifierForFile(file));

		ResourceRequestContext context = new ResourceRequestContext();

		context.getLogger().debug(
			Messages.getString("ResourceRequest", request));

		return m_ruper.query(m_repos, request, context);
	}

	public static void main(String args[]) throws Exception {
		String file = "test.jar";
		if (args.length > 0)
			file = args[0];

		FileUpdater fu = new FileUpdater(new FileAPI(), "test");

		fu.updateFileInPlace(new File(file));
	}
}

--- NEW FILE: ClasspathUpdater.java ---
/*
 * Created on Aug 27, 2003
 */
package org.krysalis.ruper.api.tool;

import org.krysalis.ruper.ResourceUpdater;
import org.krysalis.ruper.RuperException;
import org.krysalis.ruper.impl.ResourceUpdaterIdentifier;
import org.krysalis.version.util.classpath.PathSet;

/**
 * @author arb_jack
 */
public class ClasspathUpdater extends FileUpdater {

	/**
	 * 
	 */
	public ClasspathUpdater(String identifier) throws RuperException {
		this(new ResourceUpdaterIdentifier(identifier));
	}

	/**
	 * 
	 */
	public ClasspathUpdater(ResourceUpdaterIdentifier identifier)
		throws RuperException {
		this(ResourceUpdater.getResourceUpdater(identifier, true));
	}

	/**
	 * 
	 */
	public ClasspathUpdater(ResourceUpdater ruper) {
		super(ruper);
	}

	public void updateClasspathInPlace(final String classpathStr) {
		PathSet classpath = new PathSet(/* getIdentifier().getId() */
		":TODO:", classpathStr);

	}

}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.