- Timestamp:
- 05/11/08 23:52:52 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/branches/complex_obs/src/api/org/openmrs/obs/ComplexData.java
r4129 r4166 19 19 /** 20 20 * ComplexObs is a transient Object that extends Obs but is not itself persisted 21 * in the database. It has a binaryObject and a title.21 * in the database. It has a data Object and a title. 22 22 * 23 23 */ … … 26 26 public static final long serialVersionUID = 345734100L; 27 27 28 private Object binaryObject;28 private Object data; 29 29 private String title; 30 30 31 public ComplexData() { 32 33 } 34 35 public ComplexData(String title, Object binaryObject) { 31 /** 32 * Default constructor requires title and data. 33 * 34 * @param title Name or brief description of ComplexData. 35 * @param data The complex data for an Obs 36 */ 37 public ComplexData(String title, Object data) { 36 38 setTitle(title); 37 set BinaryObject(binaryObject);39 setData(data); 38 40 } 39 41 40 42 /** 41 * Static convenience method to get the ComplexObsHandler associated with a 42 * complex Obs. Returns the ComplexObsHandler. Returns null if the 43 * Obs.isComplexObs() is false or there is an error instantiating the 44 * handler class. 43 * Set the data Object. 45 44 * 46 * TODO: Should ComplexObsHandler be an abstract class and 47 * put this method there instead? 48 * 49 * @param obs A complex Obs. 50 * @return ComplexObsHandler for the complex Obs. or null on error. 45 * @param data 51 46 */ 52 public static ComplexObsHandler getHandler(Obs obs) { 53 if (!obs.getConcept().isComplex()) { 54 return null; 55 } 56 String className = ((ConceptComplex) obs.getConcept()).getHandler() 57 .getHandlerClass(); 58 ComplexObsHandler handler = null; 59 try { 60 Class handlerClass = Class.forName(className); 61 handler = (ComplexObsHandler) handlerClass.newInstance(); 62 } catch (ClassNotFoundException cnfe) { 63 return null; 64 } catch (InstantiationException ie) { 65 return null; 66 } catch (IllegalAccessException iae) { 67 return null; 68 } 69 return handler; 47 public void setData(Object data) { 48 this.data = data; 70 49 } 71 50 72 public void setBinaryObject(Object binaryObject) { 73 this.binaryObject = binaryObject; 51 /** 52 * Get the data Object 53 * 54 * @return 55 */ 56 public Object getData() { 57 return this.data; 74 58 } 75 59 76 public Object getBinaryObject() { 77 return this.binaryObject; 78 } 79 60 /** 61 * Set the title for this ComplexData 62 * 63 * @param title 64 */ 80 65 public void setTitle(String title) { 81 66 this.title = title; 82 67 } 83 68 69 /** 70 * Get the title for this ComplexData 71 * 72 * @return 73 */ 84 74 public String getTitle() { 85 75 return this.title;