|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.ArrayList<Result> org.openmrs.logic.result.Result
public class Result
A result from the logic service. A result can be 0-to-n date-values pairs.
You can treat the result as a list or easily coerce it into a simple value as
needed.
When possible, results carry references to more complex objects so that code
that deals with results and has some prior knowledge of the objects returned
by a particular rule can more easily get to the full-featured objects instead
of the simplified values in the date-value pairs.
TODO: eliminate unnecessary methods (toDatetime(), getDatetime(), and
getDate() should all do the same thing)
TODO: better support/handling of NULL_RESULT
Nested Class Summary | |
---|---|
static class |
Result.Datatype
Core datatypes for a result. |
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
Result()
|
|
Result(java.lang.Boolean valueBoolean)
Builds a boolean result with a result date of today |
|
Result(Concept valueCoded)
Builds a coded result with a result date of today |
|
Result(java.util.Date valueDatetime)
Builds a datetime result with a result date of today |
|
Result(java.util.Date resultDate,
java.lang.Boolean valueBoolean,
java.lang.Object obj)
Builds a boolean result with a specific result date |
|
Result(java.util.Date resultDate,
Concept valueCoded,
java.lang.Object obj)
Builds a coded result with a specific result date |
|
Result(java.util.Date resultDate,
java.util.Date valueDatetime,
java.lang.Object obj)
Builds a datetime result with a specific result date |
|
Result(java.util.Date resultDate,
java.lang.Double valueNumeric,
java.lang.Object obj)
Builds a numeric result with a specific result date |
|
Result(java.util.Date resultDate,
java.lang.Integer valueNumeric,
java.lang.Object obj)
Builds a numeric result with a specific result date |
|
Result(java.util.Date resultDate,
Result.Datatype datatype,
java.lang.Boolean valueBoolean,
Concept valueCoded,
java.util.Date valueDatetime,
java.lang.Double valueNumeric,
java.lang.String valueText,
java.lang.Object object)
Builds a result date with specific (overloaded) values — i.e., instead of simply accepting the default translation of one datatype into another (e.g., a date translated automatically into string format), this contructor allows the various datatype representations of the result to be individually controlled. |
|
Result(java.util.Date resultDate,
java.lang.String valueText,
java.lang.Object obj)
Builds a text result with a specific result date |
|
Result(java.lang.Double valueNumeric)
Builds a numeric result with a result date of today |
|
Result(java.lang.Integer valueNumeric)
Builds a numeric result with a result date of today |
|
Result(java.util.List<Result> list)
Builds a result from a list of results |
|
Result(Obs obs)
Builds a coded result from an observation |
|
Result(Result result)
Builds result upon another result — the first step in create a result that contains a list of other results. |
|
Result(java.lang.String valueText)
Builds a text result with a result date of today |
Method Summary | |
---|---|
boolean |
contains(Concept concept)
|
boolean |
contains(Result result)
|
boolean |
containsConcept(java.lang.Integer conceptId)
|
Result |
earliest()
|
static Result |
emptyResult()
|
boolean |
equals(java.lang.Object obj)
|
boolean |
exists()
|
Result |
get(int index)
|
Result.Datatype |
getDatatype()
Returns the datatype of the result. |
java.util.Date |
getResultDate()
Returns the data of the result (not to be confused with a data value). |
java.lang.Object |
getResultObject()
Get the result object |
Result |
gt(java.lang.Integer value)
|
boolean |
isNull()
|
Result |
latest()
|
static Result |
nullResult()
Deprecated. |
void |
setDatatype(Result.Datatype datatype)
Changes the default datatype of the result |
void |
setResultDate(java.util.Date resultDatetime)
Changes the result date time — not to be confused with a value that is a date. |
void |
setResultObject(java.lang.Object object)
Set the result object |
void |
setValueBoolean(java.lang.Boolean valueBoolean)
Overrides the boolean representation of ths result without changing the default datatype |
void |
setValueCoded(Concept valueCoded)
Overrides the coded representation of ths result without changing the default datatype |
void |
setValueDatetime(java.util.Date valueDatetime)
Overrides the datetime representation of ths result without changing the default datatype |
void |
setValueNumeric(java.lang.Double valueNumeric)
Overrides the numeric representation of ths result without changing the default datatype |
void |
setValueNumeric(java.lang.Integer valueNumeric)
Overrides the numeric representation of ths result without changing the default datatype |
void |
setValueText(java.lang.String valueText)
Overrides the text representation of ths result without changing the default datatype |
java.lang.Boolean |
toBoolean()
|
Concept |
toConcept()
|
java.util.Date |
toDatetime()
|
java.lang.Double |
toNumber()
|
java.lang.Object |
toObject()
|
java.lang.String |
toString()
|
Result |
unique()
|
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Constructor Detail |
---|
public Result()
public Result(Result result)
result
- the result that will be the sole member of the new resultpublic Result(java.util.List<Result> list)
list
- a list of resultspublic Result(java.lang.Boolean valueBoolean)
valueBoolean
- public Result(java.util.Date resultDate, java.lang.Boolean valueBoolean, java.lang.Object obj)
resultDate
- valueBoolean
- public Result(Concept valueCoded)
valueCoded
- public Result(java.util.Date resultDate, Concept valueCoded, java.lang.Object obj)
resultDate
- valueCoded
- public Result(Obs obs)
obs
- public Result(java.util.Date valueDatetime)
valueDatetime
- public Result(java.util.Date resultDate, java.util.Date valueDatetime, java.lang.Object obj)
resultDate
- valueDatetime
- public Result(java.lang.Double valueNumeric)
valueNumeric
- public Result(java.util.Date resultDate, java.lang.Double valueNumeric, java.lang.Object obj)
resultDate
- valueNumeric
- public Result(java.lang.Integer valueNumeric)
valueNumeric
- public Result(java.util.Date resultDate, java.lang.Integer valueNumeric, java.lang.Object obj)
resultDate
- valueNumeric
- public Result(java.lang.String valueText)
valueText
- public Result(java.util.Date resultDate, java.lang.String valueText, java.lang.Object obj)
resultDate
- valueText
- public Result(java.util.Date resultDate, Result.Datatype datatype, java.lang.Boolean valueBoolean, Concept valueCoded, java.util.Date valueDatetime, java.lang.Double valueNumeric, java.lang.String valueText, java.lang.Object object)
Result result = new Result(new Date(), 2.5); assertEqualtes("2.5", result.toString()); Result result = new Result(new Date(), Result.Datatype.NUMERIC, 2.5, null, null, "Two and a half", null); assertEquals("Two and a half", result.toString());
resultDate
- datatype
- valueBoolean
- valueCoded
- valueDatetime
- valueNumeric
- valueText
- object
- Method Detail |
---|
@Deprecated public static final Result nullResult()
public static final Result emptyResult()
public Result.Datatype getDatatype()
public void setResultDate(java.util.Date resultDatetime)
resultDatetime
- public void setDatatype(Result.Datatype datatype)
datatype
- public void setValueBoolean(java.lang.Boolean valueBoolean)
valueBoolean
- public void setValueCoded(Concept valueCoded)
valueCoded
- public void setValueDatetime(java.util.Date valueDatetime)
valueDatetime
- public void setValueNumeric(java.lang.Integer valueNumeric)
valueNumeric
- public void setValueNumeric(java.lang.Double valueNumeric)
valueNumeric
- public void setValueText(java.lang.String valueText)
valueText
- public java.util.Date getResultDate()
toDatetime()
public java.lang.Object getResultObject()
public void setResultObject(java.lang.Object object)
object
- public java.lang.Boolean toBoolean()
Datatype | Returns |
CODED | false for concept FALSE true for all others |
DATETIME | true for any date value false if the date is null |
NUMERIC | true for any non-zero number false for zero |
TEXT | true for any non-blank value false if blank or null |
public Concept toConcept()
public java.util.Date toDatetime()
Datatype | Returns |
BOOLEAN | null |
CODED | null |
NUMERIC | null |
TEXT | If the text can be parsed into a date, then that value is returned; otherwise returns null |
public java.lang.Double toNumber()
Datatype | Returns |
BOOLEAN | 1 for true 0 for false |
CODED | zero (0) |
DATETIME | Number of milliseconds since Java's epoch | TEXT | numeric value of text if it can be parsed into a number otherwise zero (0) |
public java.lang.String toString()
toString
in class java.util.AbstractCollection<Result>
public java.lang.Object toObject()
public boolean isNull()
public boolean exists()
public boolean contains(Concept concept)
public Result gt(java.lang.Integer value)
public boolean containsConcept(java.lang.Integer conceptId)
public boolean contains(Result result)
public Result unique()
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection<Result>
equals
in interface java.util.List<Result>
equals
in class java.util.AbstractList<Result>
Object.equals(java.lang.Object)
public Result get(int index)
get
in interface java.util.List<Result>
get
in class java.util.ArrayList<Result>
List.get(int)
public Result earliest()
public Result latest()
|
OpenMRS-1.7.x | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |