Top Description Fields Constructors Methods
org.osgi.service.dal

public abstract Class FunctionData

extends Object
implements Comparable<Object>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.lang.reflect.Array, java.util.IdentityHashMap, .Map

Abstract Function data wrapper. A subclass must be used for an access to the property values by all functions. It takes care about the timestamp and additional metadata. The subclasses are responsible to provide concrete value and unit if required.

Field Summary

Modifier and TypeField and Description
public static final String
DESCRIPTION

Metadata key, which value represents the data description.

public static final String
FIELD_METADATA

Represents the metadata field name.

public static final String
FIELD_TIMESTAMP

Represents the timestamp field name.

private final Map<String, ?>
private final long

Constructor Summary

AccessConstructor and Description
public
FunctionData(Map<String, ?>
Contains the new FunctionData instance field values.
fields
)

Constructs new FunctionData instance with the specified field values.

public
FunctionData(long
The data timestamp optional field.
timestamp
,
Map<String, ?>
The data metadata optional field.
metadata
)

Constructs new FunctionData instance with the specified arguments.

Method Summary

Modifier and TypeMethod and Description
private static int
private static int
private static int
private static int
private static int
compare(int thisValue, int otherValue)

private static int
compareArraysDeep(Object thisArray, Object otherArray, IdentityHashMap<Object, Object> thisUsedContainers)

private static int
compareMaps(Map<?, ?> thisMap, Map<?, ?> otherMap)

private static int
compareMapsDeep(Map<?, ?> thisMap, Map<?, ?> otherMap, IdentityHashMap<Object, Object> thisUsedContainers)

public int

Returns:

-1, 0 or 1 depending on the comparison rules.
compareTo
(Object
FunctionData to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this FunctionData instance with the given argument.

private static int
compareValuesDeep(Object thisValue, Object otherValue, IdentityHashMap<Object, Object> thisUsedContainers)

public boolean

Returns:

true if this instance and argument have equivalent metadata and timestamp, false otherwise.
equals
(Object
The other instance to compare. It must be of FunctionData type.
other
)

Overrides java.lang.Object.equals.

Two FunctionData instances are equal if their metadata and timestamp are equivalent.

public Map<String, ?>

Returns:

FunctionData metadata or null is there is no metadata.
getMetadata
()

Returns FunctionData metadata.

public long

Returns:

FunctionData timestamp.
getTimestamp
()

Returns FunctionData timestamp.

public int

Returns:

FunctionData hash code.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code of this FunctionData.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

DESCRIPTIONback to summary
public static final String DESCRIPTION

Metadata key, which value represents the data description. The property value type is java.lang.String.

FIELD_METADATAback to summary
public static final String FIELD_METADATA

Represents the metadata field name. The field value is available with getMetadata(). The field type is Map. The constant can be used as a key to FunctionData(Map).

FIELD_TIMESTAMPback to summary
public static final String FIELD_TIMESTAMP

Represents the timestamp field name. The field value is available with getTimestamp(). The field type is long. The constant can be used as a key to FunctionData(Map).

metadataback to summary
private final Map<String, ?> metadata
timestampback to summary
private final long timestamp

Constructor Detail

FunctionDataback to summary
public FunctionData(Map<String, ?> fields)

Constructs new FunctionData instance with the specified field values. The map keys must match to the field names. The map values will be assigned to the appropriate class fields. For example, the maps can be: {"timestamp"=Long(1384440775495)}. That map will initialize the FIELD_TIMESTAMP field with 1384440775495. If timestamp is missing, Long#MIN_VALUE is used.

Parameters
fields:Map<String, ?>

Contains the new FunctionData instance field values.

Annotations
@SuppressWarnings:unchecked
Exceptions
ClassCastException:
If the field value types are not expected.
NullPointerException:
If the fields map is null.
FunctionDataback to summary
public FunctionData(long timestamp, Map<String, ?> metadata)

Constructs new FunctionData instance with the specified arguments.

Parameters
timestamp:long

The data timestamp optional field.

metadata:Map<String, ?>

The data metadata optional field.

Method Detail

calculateArrayHashCodeDeepback to summary
private static int calculateArrayHashCodeDeep(Object array, IdentityHashMap<Object, Object> usedContainers)
calculateMapHashCodeback to summary
private static int calculateMapHashCode(Map<?, ?> map)
calculateMapHashCodeDeepback to summary
private static int calculateMapHashCodeDeep(Map<?, ?> map, IdentityHashMap<Object, Object> usedContainers)
calculateValueHashCodeDeepback to summary
private static int calculateValueHashCodeDeep(Object value, IdentityHashMap<Object, Object> usedContainers)
compareback to summary
private static int compare(int thisValue, int otherValue)
compareArraysDeepback to summary
private static int compareArraysDeep(Object thisArray, Object otherArray, IdentityHashMap<Object, Object> thisUsedContainers)
compareMapsback to summary
private static int compareMaps(Map<?, ?> thisMap, Map<?, ?> otherMap)
compareMapsDeepback to summary
private static int compareMapsDeep(Map<?, ?> thisMap, Map<?, ?> otherMap, IdentityHashMap<Object, Object> thisUsedContainers)
compareToback to summary
public int compareTo(Object o)

Implements java.lang.Comparable.compareTo.

Compares this FunctionData instance with the given argument. If the argument is not FunctionData, it throws ClassCastException. Otherwise, this method returns:

  • -1 if this instance timestamp is less than the argument timestamp. If they are equivalent, it can be the result of the metadata map deep comparison.
  • 0 if all fields are equivalent.
  • 1 if this instance timestamp is greater than the argument timestamp. If they are equivalent, it can be the result of the metadata map deep comparison.
Metadata map deep comparison compares the elements of all nested java.util.Map and array instances. null is less than any other non-null instance.
Parameters
o:Object

FunctionData to be compared.

Returns:int

-1, 0 or 1 depending on the comparison rules.

Annotations
@Override
Exceptions
ClassCastException:
If the method argument is not of type FunctionData or metadata maps contain values of different types for the same key.
NullPointerException:
If the method argument is null.
See Also
java.lang.Comparable#compareTo(java.lang.Object)
compareValuesDeepback to summary
private static int compareValuesDeep(Object thisValue, Object otherValue, IdentityHashMap<Object, Object> thisUsedContainers)
Annotations
@SuppressWarnings:unchecked
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Two FunctionData instances are equal if their metadata and timestamp are equivalent.

Parameters
other:Object

The other instance to compare. It must be of FunctionData type.

Returns:boolean

true if this instance and argument have equivalent metadata and timestamp, false otherwise.

Annotations
@Override
See Also
java.lang.Object#equals(java.lang.Object)
getMetadataback to summary
public Map<String, ?> getMetadata()

Returns FunctionData metadata. It's dynamic metadata related only to this specific value. Possible keys:

Returns:Map<String, ?>

FunctionData metadata or null is there is no metadata.

getTimestampback to summary
public long getTimestamp()

Returns FunctionData timestamp. The timestamp is the difference between the value collecting time and midnight, January 1, 1970 UTC. It's measured in milliseconds. The device driver is responsible to generate that value when the value is received from the device. java.lang.Long#MIN_VALUE value means no timestamp.

Returns:long

FunctionData timestamp.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code of this FunctionData.

Returns:int

FunctionData hash code.

Annotations
@Override
See Also
java.lang.Object#hashCode()