de.hpi.fgis.dude.util.data
Class DuDeObjectPair

java.lang.Object
  extended by de.hpi.fgis.dude.util.Pair<T,T>
      extended by de.hpi.fgis.dude.util.OrderedPair<DuDeObject>
          extended by de.hpi.fgis.dude.util.data.DuDeObjectPair
All Implemented Interfaces:
AutoJsonable, Jsonable

public class DuDeObjectPair
extends OrderedPair<DuDeObject>
implements Jsonable

DuDeObjectPair is an extension of the OrderedPair class, that encapsulates pairs of DuDeObjects.

Author:
Matthias Pohl
See Also:
DuDeObject

Nested Class Summary
static class DuDeObjectPair.DuplicateType
          DuDeObjectPair.DuplicateType declares all possible values for the is-duplicate property.
static class DuDeObjectPair.GeneratedBy
          DuDeObjectPair.GeneratedBy declares the possible values for the lineage property.
 
Field Summary
protected static String DUPLICATE_PROPERTY
          The name of the property that indicates, if the current pair is a duplicate.
static String FIRST_ELEMENT_ATTRIBUTE_NAME
          The first element's Json attribute name.
protected static String LINEAGE_PROPERTY
          The name of the lineage property.
static double NO_SIMILARITY_SET_VALUE
          This value will be returned, if no similarity was set.
static String SECOND_ELEMENT_ATTRIBUTE_NAME
          The second element's Json attribute name.
protected static String SIMILARITY_PROPERTY
          The name of the similarity property.
 
Constructor Summary
DuDeObjectPair(DuDeObject first, DuDeObject second)
          Initializes a pair of DuDeObjects.
DuDeObjectPair(String sourceId1, JsonArray objectId1, String sourceId2, JsonArray objectId2)
          Initializes a DuDeObjectPair that contains no real data.
DuDeObjectPair(String sourceId1, String objectId1, String sourceId2, String objectId2)
          Initializes a DuDeObjectPair that contains no real data and where the object id is given as a single String value.
 
Method Summary
 void clearDuplicateInfo()
          Clears the is-duplicate property.
 void clearLineage()
          Clears the lineage property.
 void clearSimilarity()
          Clears the similarity of this pair.
 boolean equals(Object obj)
           
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
 DuDeObjectPair.DuplicateType getDuplicateInfo()
          Checks whether the current pair represents a duplicate.
 JsonRecord getFirstElementObjectData()
          Returns the data of the first DuDeObject.
 DuDeObjectPair.GeneratedBy getLineage()
          Returns the lineage value of the current pair.
 DuDeObjectPair getReference()
          Returns a DuDeObjectPair that refers to the current pair.
 JsonRecord getSecondElementObjectData()
          Returns the data of the second DuDeObject.
 double getSimilarity()
          Returns the similarity of the DuDeObjectPair or NO_SIMILARITY_SET_VALUE, if the similarity wasn't set.
 boolean hasDuplicateInfo()
          Checks whether the is-duplicate property is set.
 int hashCode()
           
 boolean hasLineage()
          Checks whether a lineage is specified.
 boolean hasSimilarity()
          Checks whether the similarity is set.
 boolean isDuplicate()
          Checks whether the current pair represents a duplicate.
 void setDuplicateInfo(DuDeObjectPair.DuplicateType isDuplicate)
          Sets the is-duplicate property.
 void setLineage(DuDeObjectPair.GeneratedBy generatorType)
          Sets the lineage property.
 void setSimilarity(double val)
          Sets the similarity of this DuDeObjectPair.
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 String toString()
           
 
Methods inherited from class de.hpi.fgis.dude.util.OrderedPair
copyPropertiesFrom, getProperty, hasProperty, setElements, setFirstElement, setProperty, setSecondElement
 
Methods inherited from class de.hpi.fgis.dude.util.Pair
getFirstElement, getSecondElement, isReflexive, isSymmetricTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_SIMILARITY_SET_VALUE

public static final double NO_SIMILARITY_SET_VALUE
This value will be returned, if no similarity was set.

See Also:
Constant Field Values

FIRST_ELEMENT_ATTRIBUTE_NAME

public static final String FIRST_ELEMENT_ATTRIBUTE_NAME
The first element's Json attribute name.

See Also:
Constant Field Values

SECOND_ELEMENT_ATTRIBUTE_NAME

public static final String SECOND_ELEMENT_ATTRIBUTE_NAME
The second element's Json attribute name.

See Also:
Constant Field Values

SIMILARITY_PROPERTY

protected static final String SIMILARITY_PROPERTY
The name of the similarity property.

See Also:
Constant Field Values

LINEAGE_PROPERTY

protected static final String LINEAGE_PROPERTY
The name of the lineage property.

See Also:
Constant Field Values

DUPLICATE_PROPERTY

protected static final String DUPLICATE_PROPERTY
The name of the property that indicates, if the current pair is a duplicate.

See Also:
Constant Field Values
Constructor Detail

DuDeObjectPair

public DuDeObjectPair(DuDeObject first,
                      DuDeObject second)
Initializes a pair of DuDeObjects.

Parameters:
first - The first DuDeObject.
second - The second DuDeObject.

DuDeObjectPair

public DuDeObjectPair(String sourceId1,
                      JsonArray objectId1,
                      String sourceId2,
                      JsonArray objectId2)
Initializes a DuDeObjectPair that contains no real data. This constructor can be used for referring to actual DuDeObjectPairs.

Parameters:
sourceId1 - The source id of the first object.
objectId1 - The object id of the first object.
sourceId2 - The source id of the second object.
objectId2 - The object id of the second object.

DuDeObjectPair

public DuDeObjectPair(String sourceId1,
                      String objectId1,
                      String sourceId2,
                      String objectId2)
Initializes a DuDeObjectPair that contains no real data and where the object id is given as a single String value. This constructor can be used for referring to actual DuDeObjectPairs.

Parameters:
sourceId1 - The source id of the first object.
objectId1 - The object id of the first object as a single String value.
sourceId2 - The source id of the second object.
objectId2 - The object id of the second object as a single String value.
Method Detail

getFirstElementObjectData

public JsonRecord getFirstElementObjectData()
Returns the data of the first DuDeObject.

Returns:
A JsonRecord that stores all the data that describes the real-world object which is represented by the first element.

getSecondElementObjectData

public JsonRecord getSecondElementObjectData()
Returns the data of the second DuDeObject.

Returns:
A JsonRecord that stores all the data that describes the real-world object which is represented by the second element.

getReference

public DuDeObjectPair getReference()
Returns a DuDeObjectPair that refers to the current pair.

Returns:
A reference to the current DuDeObjectPair.

toString

public String toString()
Overrides:
toString in class Pair<DuDeObject,DuDeObject>

equals

public boolean equals(Object obj)
Overrides:
equals in class Pair<DuDeObject,DuDeObject>
See Also:
Object.equals(Object)

hasSimilarity

public boolean hasSimilarity()
Checks whether the similarity is set.

Returns:
true, if the similarity was set; otherwise false.

clearSimilarity

public void clearSimilarity()
Clears the similarity of this pair.


setSimilarity

public void setSimilarity(double val)
Sets the similarity of this DuDeObjectPair. The passed value needs to be within the range [0;1]. Larger values will lead to a similarity of 1.0. Smaller values will lead to a similarity of 0.0.

Parameters:
val - The value which shall be set as a similarity.

getSimilarity

public double getSimilarity()
Returns the similarity of the DuDeObjectPair or NO_SIMILARITY_SET_VALUE, if the similarity wasn't set.

Returns:
The similarity of the pair or NO_SIMILARITY_SET_VALUE, if it was not set.

hasLineage

public boolean hasLineage()
Checks whether a lineage is specified.

Returns:
true, if the property is set and unequal to DuDeObjectPair.GeneratedBy.NotDefined; otherwise false.

clearLineage

public void clearLineage()
Clears the lineage property.


setLineage

public void setLineage(DuDeObjectPair.GeneratedBy generatorType)
Sets the lineage property.

Parameters:
generatorType - The type of lineage that shall be set.

getLineage

public DuDeObjectPair.GeneratedBy getLineage()
Returns the lineage value of the current pair.

Returns:
The value of the lineage property.

hasDuplicateInfo

public boolean hasDuplicateInfo()
Checks whether the is-duplicate property is set.

Returns:
true, if this property is set; otherwise false.

clearDuplicateInfo

public void clearDuplicateInfo()
Clears the is-duplicate property.


setDuplicateInfo

public void setDuplicateInfo(DuDeObjectPair.DuplicateType isDuplicate)
Sets the is-duplicate property. null unsets this property.

Parameters:
isDuplicate - The new value of the is-duplicate property.

getDuplicateInfo

public DuDeObjectPair.DuplicateType getDuplicateInfo()
Checks whether the current pair represents a duplicate.

Returns:
The value of the is-duplicate property.

isDuplicate

public boolean isDuplicate()
Checks whether the current pair represents a duplicate.

Returns:
false, if the pair does not represent a duplicate or was not defined as a duplicate, yet; otherwise false .

hashCode

public int hashCode()
Overrides:
hashCode in class Pair<DuDeObject,DuDeObject>

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.