|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.data.DuDeObject
public class DuDeObject
DuDeObject
encapsulates the data of the original object and two ids (for the source and a local one) for identifying each
DuDeObject
.
AbstractDataSource
Field Summary | |
---|---|
static String |
OBJECT_DATA_ATTRIBUTE_NAME
The attribute name of the object data within the DuDeObject's Json representation. |
static String |
OBJECT_IDENTIFIER_ATTRIBUTE_NAME
The attribute name of the object identifier within the DuDeObject's Json representation. |
Constructor Summary | |
---|---|
DuDeObject(JsonRecord data,
String srcId,
JsonArray objectId)
Initializes a DuDeObject with the passed ids and the given data. |
|
DuDeObject(JsonRecord data,
String sourceId,
String objectId)
Initializes a DuDeObject using the given ids. |
|
DuDeObject(String sourceId,
JsonArray objectId)
Creates a DuDeObject reference. |
|
DuDeObject(String sourceId,
String objectId)
Creates a DuDeObject reference. |
Method Summary | |
---|---|
void |
addIdentifier(DuDeObjectId id)
Adds an identifier to this DuDeObject . |
int |
compareTo(DuDeObject other)
|
boolean |
equals(Object otherObj)
Two objects are equal, if both have the same ids. |
boolean |
equalsID(DuDeObject otherDuDeObject)
Two objects are equal, if both have the same ids. |
void |
fromJson(DuDeJsonParser<?> jsonParser)
Initializes the current instance using the passed DuDeJsonParser . |
JsonValue |
getAttributeValue(String name)
Returns the first value of the given attribute. |
JsonValue |
getAttributeValue(String name,
int index)
Returns the concrete value of the given attribute at the passed position. |
JsonValue |
getAttributeValues(String attributeName)
Looks within the current DuDeObject for the given attribute. |
JsonValue |
getAttributeValuesByPath(String... path)
Traverses the passed path and returns the corresponding attribute value or null , if the passed path is invalid. |
JsonRecord |
getData()
Returns the data that describes the real-world object of which this instance is the representation. |
DuDeObjectId |
getIdentifier()
Returns the first identifier of this DuDeObject . |
Iterable<DuDeObjectId> |
getIdentifiers()
Returns all identifiers of this DuDeObject . |
int |
getMergeCount()
Returns the number of objects this DuDeObject was merged from. |
JsonArray |
getObjectId()
Returns the object identifier of this object. |
String |
getSourceId()
Returns the source identifier of this object. |
boolean |
hasData()
Checks whether the current DuDeObject contains real data. |
int |
hashCode()
|
boolean |
isMerged()
Checks, if this DuDeObject is a merged object. |
void |
toJson(DuDeJsonGenerator jsonGenerator)
Generates the Json code using the passed DuDeJsonGenerator . |
String |
toString()
Converts the DuDeObject to its Json representation. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String OBJECT_DATA_ATTRIBUTE_NAME
DuDeObject's
Json representation.
public static final String OBJECT_IDENTIFIER_ATTRIBUTE_NAME
DuDeObject's
Json representation.
Constructor Detail |
---|
public DuDeObject(JsonRecord data, String srcId, JsonArray objectId)
DuDeObject
with the passed ids and the given data.
data
- The data that describes the real-world object of which this instance is the representation.srcId
- The identifier of the source where this data comes from.objectId
- The identifier of the object within the source where this data comes from.
NullPointerException
- If null
was passed through srcId
or objId
.public DuDeObject(String sourceId, JsonArray objectId)
DuDeObject
reference.
sourceId
- The source identifier.objectId
- The object identifier.
NullPointerException
- If null
was passed through sourceId
or objectId
.public DuDeObject(JsonRecord data, String sourceId, String objectId)
DuDeObject
using the given ids. objectId
will be embedded into a JsonArray
.
data
- The data that describes the real-world object of which this instance is the representation.objectId
- The object identifier as String Value. It only consists of values of one column.sourceId
- The source identifier.public DuDeObject(String sourceId, String objectId)
DuDeObject
reference.
sourceId
- The source identifier.objectId
- The object identifier as a String
value.
NullPointerException
- If null
was passed through sourceId
or objectId
.Method Detail |
---|
public boolean equals(Object otherObj)
equals
in class Object
true
, if both objects have the same ids; otherwise false
Object.equals(Object)
public int hashCode()
hashCode
in class Object
public boolean equalsID(DuDeObject otherDuDeObject)
otherDuDeObject
- The DuDeObject
that shall be compared with the current instance.
true
, if both objects have the same ids; otherwise false
.public DuDeObjectId getIdentifier()
DuDeObject
.
DuDeObjectId
which contains both, the source id as well as the object id.public void addIdentifier(DuDeObjectId id)
DuDeObject
.
id
- The DuDeObjectId
, which shall be added.public Iterable<DuDeObjectId> getIdentifiers()
DuDeObject
.
Iterable
that contains all DuDeObjectId
s of this DuDeObject
.public boolean isMerged()
DuDeObject
is a merged object.
true
, if it is a merged object, false
otherwisepublic int getMergeCount()
DuDeObject
was merged from.
DuDeObjects
that were the source for this merged object.
If this object is not a merged one, the return value is 1.public String getSourceId()
public JsonArray getObjectId()
public JsonRecord getData()
null
, if the DuDeObject
has no data.public JsonValue getAttributeValuesByPath(String... path)
null
, if the passed path is invalid.
path
- The path which specifies the attribute whose value(s) shall be returned.
null
, if the path is invalid.public JsonValue getAttributeValues(String attributeName)
DuDeObject
for the given attribute. If this attribute is found, the corresponding value is returned. If
this attribute does not exist, null
will be returned.
attributeName
- The name of the attribute whose value is requested.
JsonArray
(since all attribute values are stored in arrays) or null
, if this attribute does not
exist.public JsonValue getAttributeValue(String name, int index)
name
- The name of the attribute whose value shall be returned.index
- The index of the value within the attribute value list. If this parameter is negative, the corresponding JsonArray
will be
accessed in reverse order (e.g.: -1
returns the last element).
null
, if the attribute does not exist, or no value was found at the given position.public JsonValue getAttributeValue(String name)
name
- The attribute whose value shall be returned.
null
, if the attribute does not exist or it has no value.public String toString()
DuDeObject
to its Json representation.
toString
in class Object
DuDeObject
.public boolean hasData()
DuDeObject
contains real data.
true
, if it contains data; otherwise false
.public int compareTo(DuDeObject other)
compareTo
in interface Comparable<DuDeObject>
public void toJson(DuDeJsonGenerator jsonGenerator) throws org.codehaus.jackson.JsonGenerationException, IOException
Jsonable
DuDeJsonGenerator
.
toJson
in interface Jsonable
jsonGenerator
- The DuDeJsonGenerator
that is used internally.
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while writing to the output.public void fromJson(DuDeJsonParser<?> jsonParser) throws org.codehaus.jackson.JsonParseException, IOException
Jsonable
DuDeJsonParser
.
fromJson
in interface Jsonable
jsonParser
- The parser that is used for extracting the data out of the Json.
org.codehaus.jackson.JsonParseException
- If an error occurs while parsing the Json.
IOException
- If an error occurs while reading from the stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |