Package org.intermine.client.results
Class Item
- java.lang.Object
-
- org.intermine.client.results.Item
-
public class Item extends java.lang.Object
A representation of an individual result from the web-services. These results are backed by maps returned by the QueryService for each row, and used to represent members of lists. Unlike the backing maps, these objects contain more information and assumptions about the represented objects, in particular the fact that every object has an id and a type.
-
-
Constructor Summary
Constructors Constructor Description Item(ServiceFactory factory, java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> properties)
Construct an Item.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Determine whether this object is equal to the other.java.lang.Boolean
getBoolean(java.lang.String key)
Get a property known to be an boolean.java.util.Set<Item>
getCollection(java.lang.String key)
Get a set of items representing the elements in a collection field on an item.java.lang.Double
getDouble(java.lang.String key)
Get a property known to be a double.java.lang.Float
getFloat(java.lang.String key)
Get a property known to be an float.int
getId()
Get the internal database id of the object.java.lang.Integer
getInt(java.lang.String key)
Get a property known to be an integer.java.util.Map<java.lang.String,java.lang.Object>
getProperties()
Return a view of the properties in this row.Item
getReference(java.lang.String key)
Get in Item representing the record referenced by a reference field.java.lang.String
getString(java.lang.String key)
Get a property known to be a string.java.lang.String
getType()
Get the type of this object.int
hashCode()
boolean
isa(java.lang.String type)
Determine whether this item belongs to the class of objects of the named type.java.lang.String
toString()
-
-
-
Constructor Detail
-
Item
public Item(ServiceFactory factory, java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> properties)
Construct an Item.- Parameters:
factory
- The service this item comes from.type
- The type of this class.properties
- The backing properties.
-
-
Method Detail
-
getType
public java.lang.String getType()
Get the type of this object. This is the class requested in the query from which the rows originated, and the object may also belong to a more specific type.- Returns:
- The class in the data model this object belongs to.
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Return a view of the properties in this row. Changes to this object will not be reflected in the Item.- Returns:
- A new map containing the same information as the backing map.
-
getString
public java.lang.String getString(java.lang.String key)
Get a property known to be a string.- Parameters:
key
- The name of the property (eg: "symbol")- Returns:
- The property's value.
-
getInt
public java.lang.Integer getInt(java.lang.String key)
Get a property known to be an integer.- Parameters:
key
- The name of the property (eg: "length")- Returns:
- The property's value.
-
getDouble
public java.lang.Double getDouble(java.lang.String key)
Get a property known to be a double.- Parameters:
key
- The name of the property (eg: "score")- Returns:
- the propery's value
-
getFloat
public java.lang.Float getFloat(java.lang.String key)
Get a property known to be an float.- Parameters:
key
- The name of the property (eg: "score")- Returns:
- The property's value.
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.String key)
Get a property known to be an boolean.- Parameters:
key
- The name of the property (eg: "active")- Returns:
- The property's value.
-
getId
public int getId()
Get the internal database id of the object. This value guarantees object identity.- Returns:
- The id of the object.
-
equals
public boolean equals(java.lang.Object other)
Determine whether this object is equal to the other.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- The object to compare to.- Returns:
- Whether they are the same object in the database on the server.
-
getReference
public Item getReference(java.lang.String key)
Get in Item representing the record referenced by a reference field. For example, forgene.getItem("organism")
the return value will be an Item representing the organism, or null, if the reference is unset.- Parameters:
key
- The name of the reference.- Returns:
- The Item representing the referenced object.
-
getCollection
public java.util.Set<Item> getCollection(java.lang.String key)
Get a set of items representing the elements in a collection field on an item. For example, a call togene.getCollection("proteins")
will return a set of Items that each represent a protein in the genes "proteins" collection.- Parameters:
key
- The name of the collection.- Returns:
- A Set of Item objects.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isa
public boolean isa(java.lang.String type)
Determine whether this item belongs to the class of objects of the named type.- Parameters:
type
- The name of the class this object might belong to.- Returns:
- Whether or not this object is an object of the given type.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-