ViewBean

 


 package edu.jbs.ooc.databeans;

import java.util.*;
/**
 * Insert the type's description here.
 * Creation date: (3/4/2002 9:58:39 AM)
 * @author: Administrator
 */
public class ViewBean extends ObjectBean{

	/********************************
	
	Used to present a view of response
	originaiting iwth a user request.
	Oriented toward presentation.
	Carries labels and specialized display 
	forms of values, e.g., dates.
	Can generate XML output with standardized tags:
	
	<field>
	  <label></label>
	  <name></name>
	  <value></value>
	</field>
		
	********************************/
	
	private java.util.Vector fields;
	private java.util.Hashtable labels;
	private java.util.Hashtable valuesForDisplay;
	
	private java.lang.String message;
		
	private java.lang.String targetName;


	private java.lang.String objectID;
/**
 * ViewBean constructor comment.
 */
public ViewBean() {
	
	super();

	fields = new Vector();
	labels = new Hashtable();
	valuesForDisplay = new Hashtable();
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/11/2002 9:13:31 AM)
 * @return java.lang.String
 * @param param int
 */
public String getField(int position) {
	
	return (String)fields.get( position );
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/11/2002 9:07:17 AM)
 * @return java.util.Vector
 */
public java.util.Vector getFields() {
	
	return fields;
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:00:04 AM)
 * @return java.lang.String
 */
public java.lang.String getLabel( String fieldName ) {
	
	return (String)labels.get( fieldName );
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 9:59:38 AM)
 * @return java.util.Hashtable
 */
public java.util.Hashtable getLabels() {
	return labels;
}
/**
 * Insert the method's description here.
 * Creation date: (3/28/2002 2:07:31 PM)
 * @return java.lang.String
 */
public java.lang.String getMessage() {
	return message;
}
/**
 * Insert the method's description here.
 * Creation date: (3/11/2002 9:37:47 AM)
 * @return int
 */
public int getNumberOfFields() {

	return fields.size();

}
/**
 * Insert the method's description here.
 * Creation date: (4/1/2002 11:10:57 AM)
 * @return java.lang.String
 */
public java.lang.String getObjectID() {
	return objectID;
}
/**
 * Insert the method's description here.
 * Creation date: (3/6/2002 3:50:32 PM)
 * @return java.lang.String
 */
public java.lang.String getTargetName() {
	return targetName;
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:01:36 AM)
 * @return java.util.Hashtable
 */
public String getValueForDisplay( String fieldName ) {
	
	String valueForDisplay = (String)valuesForDisplay.get( fieldName );
	if ( valueForDisplay != null )  return valueForDisplay;
	
	Object value = getValue( fieldName );
	if ( value != null )  return value.toString();
	
	return "";
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:01:03 AM)
 * @return java.util.Hashtable
 */
public java.util.Hashtable getValuesForDisplay() {
	
	return valuesForDisplay;
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:02:17 AM)
 * @return java.lang.String
 */
public java.lang.String getXML() {
	
	String xmlString = new String();

	for ( int i=0; i<this.getNumberOfFields(); i++ )  {
		
		String currentField = getField(i);
		String label = getLabel( currentField );
		String valueForDisplay = getValueForDisplay ( currentField );
		
		xmlString += "<field>";

		xmlString += "<label>" + label + "</label>";
		xmlString += "<name>" + currentField + "</name>";
		xmlString += "<value>" + valueForDisplay + "</value>";
		
		xmlString += "</field>";
		
	}
	
	return xmlString;
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/11/2002 9:26:53 AM)
 * @param fieldName java.lang.String
 */
public void setField(String fieldName) {
	
	fields.add( fieldName );
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/11/2002 9:07:17 AM)
 * @param newFields java.util.Vector
 */
public void setFields(java.util.Vector newFields) {
	fields = newFields;
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:00:04 AM)
 * @param newLabel java.lang.String
 */
public void setLabel( String fieldName, String newLabel ) {
	
	labels.put( fieldName, newLabel );
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 9:59:38 AM)
 * @param newLabels java.util.Hashtable
 */
public void setLabels(java.util.Hashtable newLabels) {
	labels = newLabels;
}
/**
 * Insert the method's description here.
 * Creation date: (3/28/2002 2:07:31 PM)
 * @param newMessage java.lang.String
 */
public void setMessage(java.lang.String newMessage) {
	message = newMessage;
}
/**
 * Insert the method's description here.
 * Creation date: (4/1/2002 11:10:57 AM)
 * @param newObjectID java.lang.String
 */
public void setObjectID(java.lang.String newObjectID) {
	objectID = newObjectID;
}
/**
 * Insert the method's description here.
 * Creation date: (3/6/2002 3:50:32 PM)
 * @param newTargetName java.lang.String
 */
public void setTargetName(java.lang.String newTargetName) {
	targetName = newTargetName;
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:01:36 AM)
 * @param newValueForDisplay java.util.Hashtable
 */
public void setValueForDisplay( String fieldName, String newValueForDisplay ) {
	
	valuesForDisplay.put( fieldName, newValueForDisplay );
	
}
/**
 * Insert the method's description here.
 * Creation date: (3/4/2002 10:01:03 AM)
 * @param newValuesForDisplay java.util.Hashtable
 */
public void setValuesForDisplay(java.util.Hashtable newValuesForDisplay) {
	
	valuesForDisplay = newValuesForDisplay;
	
}
}