2006/unicorn/src/org/w3c/unicorn/response Message.java,NONE,1.1 Group.java,NONE,1.1 ResponseFactory.java,NONE,1.1 Context.java,NONE,1.1

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/response
In directory hutz:/tmp/cvs-serv21047/src/org/w3c/unicorn/response

Added Files:
	Message.java Group.java ResponseFactory.java Context.java 
Log Message:
new response objects

--- NEW FILE: ResponseFactory.java ---
package org.w3c.unicorn.response;
//$Id: ResponseFactory.java,v 1.1 2009/10/16 16:25:00 tgambet Exp $
//Author: Thomas Gambet
//(c) COPYRIGHT MIT, ERCIM and Keio, 2009.
//Please first read the full copyright statement in file COPYRIGHT.html
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.unicorn.Framework;
import org.w3c.unicorn.exceptions.UnicornException;
import org.w3c.unicorn.response.impl.DefaultResponseXBeans;

public class ResponseFactory {

	private static final Log logger = LogFactory.getLog(ResponseFactory.class);

	public static Response getResponse(InputStream is, String responseType, String requestUri, String charset) throws UnicornException {
		
		Response res;
		try {
			if (Framework.responseImpl.get(responseType) != null) {
				res = Framework.responseImpl.get(responseType).getConstructor(InputStream.class, String.class).newInstance(is, charset);
			} else if (Framework.responseImpl.get("default") != null) {
				res = Framework.responseImpl.get("default").getConstructor(InputStream.class, String.class).newInstance(is, charset);
				logger.warn("ResponseType unknown: " + responseType + ". The default responseType is instanciated instead.");
			} else {
				res = new DefaultResponseXBeans(is, charset);
			}
			res.setRequestUri(requestUri);
			return res;
		} catch (InvocationTargetException e) {
			if (e.getCause() instanceof UnicornException)
				throw (UnicornException) e.getCause();
			logger.error(e.getMessage(), e);
		} catch (IllegalArgumentException e) {
			logger.error(e.getMessage(), e);
		} catch (SecurityException e) {
			logger.error(e.getMessage(), e);
		} catch (InstantiationException e) {
			logger.error(e.getMessage(), e);
		} catch (IllegalAccessException e) {
			logger.error(e.getMessage(), e);
		}  catch (NoSuchMethodException e) {
			logger.error(e.getMessage(), e);
		}
		
		return null;
	}
	
}

--- NEW FILE: Message.java ---
// $Id: Message.java,v 1.1 2009/10/16 16:25:00 tgambet Exp $
// Author: Thomas Gambet
// (c) COPYRIGHT MIT, ERCIM and Keio, 2009.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.unicorn.response;

import java.util.List;

public interface Message {

	public static final int INFO = 0;
	
	public static final int WARNING = 1;
	
	public static final int ERROR = 2;
	
	public String getTitle();
	
	public String getDescription();
	
	public int getType();
	
	public int getLevel();
	
	public String getURI();
	
	public List<Context> getContexts();
	
	public String getGroupName();
	
}

--- NEW FILE: Context.java ---
// $Id: Context.java,v 1.1 2009/10/16 16:25:00 tgambet Exp $
// Author: Thomas Gambet
// (c) COPYRIGHT MIT, ERCIM and Keio, 2009.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.unicorn.response;

public interface Context {
	
	public Integer getLine();
	
	public Integer getColumn();
	
	public Integer getLineMin();
	
	public Integer getLineMax();
	
	public Integer getColumnMin();
	
	public Integer getColumnMax();
	
	public Integer getOffset();
	
	public String getPosition();
	
	public String getContext();
	
	public String getURI();
	
}

--- NEW FILE: Group.java ---
// $Id: Group.java,v 1.1 2009/10/16 16:25:00 tgambet Exp $
// Author: Thomas Gambet
// (c) COPYRIGHT MIT, ERCIM and Keio, 2009.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.unicorn.response;

public interface Group {

	public String getName();
	
	public String getParentName();
	
	public String getTitle();
	
	public String getDescription();
	
	public boolean hasParent();
	
}

Received on Friday, 16 October 2009 16:25:04 UTC