[Join-cvs] join/src/main/org/figure8/join/util DeliverablePropertiesExtractor.java,NONE,1.1 LogUtil.
Brought to you by:
lbroudoux
|
From: <lbr...@us...> - 2003-07-30 09:19:34
|
Update of /cvsroot/join/join/src/main/org/figure8/join/util
In directory sc8-pr-cvs1:/tmp/cvs-serv790
Added Files:
DeliverablePropertiesExtractor.java LogUtil.java
Log Message:
Initial checkin
--- NEW FILE: DeliverablePropertiesExtractor.java ---
/*
* DeliverablePropertiesExtractor.java
*
* Created on 9 january 2003, 19:20
*/
package org.figure8.join.util;
import org.figure8.join.view.DeliverableView;
import org.figure8.join.service.PropertiesExtractor;
import java.util.Properties;
/**
* Implementation of PropertiesExtractor that flatten <code>org.figure8.join.
* view.DeliverableView</code> objects into String properties. The result properties
* are prefixed by "version.". This properties are "id", "release.name",
* "supplier.id", "type.id" and "type.label" where type is the deliverable type.
* @author <a href="mailto:lau...@fr...">Laurent Broudoux</a>
*/
public class DeliverablePropertiesExtractor implements PropertiesExtractor{
// Constructors -------------------------------------------------------------
/** Creates a new instance of DeliverablePropertiesExtractor */
public DeliverablePropertiesExtractor() {}
// Implementation of PropertiesExtractor ------------------------------------
/**
* Extract a set of properties from the given object.
* @param obj The object to flatten into properties
* @throws IllegalArgumentException if the object class is not supported
* by extractor implementation
*/
public Properties extract(Object obj) throws IllegalArgumentException{
// Chekc that object is DeliverableView.
if (obj instanceof DeliverableView){
DeliverableView view = (DeliverableView)obj;
Properties props = new Properties();
// Get general info properties.
props.setProperty("deliverable.id", view.getId());
props.setProperty("deliverable.supplier.id", view.getSupplierId());
props.setProperty("deliverable.release.name", view.getReleaseName());
// Get deliverable type related infos.
props.setProperty("deliverable.type.id", view.getTypeId());
props.setProperty("deliverable.type.label", view.getTypeLabel());
return props;
}
else throw new IllegalArgumentException("DeliverablePropertiesExtractor can only process DeliverableView, not " + obj.getClass());
}
}
--- NEW FILE: LogUtil.java ---
/*
* LogUtil.java
*
* Created on 6 september 2002, 14:31
*/
package org.figure8.join.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Logger factory.
* @author <a href="mailto:lau...@fr...">Laurent Broudoux</a>
*/
public final class LogUtil{
// Static -------------------------------------------------------------------
/**
* Returns an instance of Jakarta Commons Log object.
* For now simply return the classname as a log.
* @param clazz Class (will use clazz.getName() to obtain the class name)
* @return A logger for the specified class
*/
public static Log getLog(Class clazz){
return LogFactory.getLog(clazz.getName());
}
/**
* Returns an instance of Jakarta Commons Log object.
* For now simply return the classname + '.' + name as a log.
* @param clazz Class (will use clazz.getName() to obtain the class name)
* @param name Method name
* @return A logger for the specified class and method
*/
public static Log getLog(Class clazz, String name){
return LogFactory.getLog(new StringBuffer(clazz.getName()).append('.').append(name).toString());
}
}
|