Top Description Inners Fields Constructors Methods
org.jboss.marshalling

public final Class Pair<A, B>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@Externalize:Externalizer
Type Parameters
<A>
the first value type
<B>
the second value type
Imports
java.io.ObjectInputStream, .Serializable, .Externalizable, .ObjectOutput, .IOException, .ObjectInput

A serializable pair of values. There is also a specified externalizer as well, to support more efficient I/O.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Pair.Externalizer

An externalizer for Pair instances.

Field Summary

Modifier and TypeField and Description
private final A
a

private final B
b

private final transient int
private static final long
private static final FieldSetter

Constructor Summary

AccessConstructor and Description
public
Pair(final A
the first value
a
,
final B
the second value
b
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public static <
the first value type
A
,
the second value type
B
>
Pair<A, B>

Returns:

the new instance
create
(A
the first value
a
,
B
the second value
b
)

Create a new instance.

public boolean

Returns:

true if they are equal, false otherwise
equals
(final Object
the other pair
other
)

Overrides java.lang.Object.equals.

Determine if this pair equals another.
public boolean

Returns:

true if they are equal, false otherwise
equals
(final Pair<?, ?>
the other pair
other
)

Determine if this pair equals another.

public A

Returns:

the first value
getA
()

Get the first value.

public B

Returns:

the second value
getB
()

Get the second value.

private static int

Returns:

the combined hash code
hashCode
(final Object
the first object
a
,
final Object
the second object
b
)

Calculate the combined hash code of two objects.

public int

Returns:

the combined hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Return the combined hash code of the two argument objects.
private void
readObject(ObjectInputStream
the object input stream
ois
)

Reinitialize the object and set the hash code.

public String

Returns:

the string representation
toString
()

Overrides java.lang.Object.toString.

Get a string representation of this pair.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

aback to summary
private final A a
bback to summary
private final B b
hashCodeback to summary
private final transient int hashCode
Annotations
@SuppressWarnings:InstanceVariableMayNotBeInitializedByReadObject
serialVersionUIDback to summary
private static final long serialVersionUID
setterback to summary
private static final FieldSetter setter

Constructor Detail

Pairback to summary
public Pair(final A a, final B b)

Create a new instance.

Parameters
a:A

the first value

b:B

the second value

Method Detail

createback to summary
public static <A, B> Pair<A, B> create(A a, B b)

Create a new instance.

Parameters
<A>
the first value type
<B>
the second value type
a:A

the first value

b:B

the second value

Returns:Pair<A, B>

the new instance

equalsback to summary
public boolean equals(final Object other)

Overrides java.lang.Object.equals.

Determine if this pair equals another. A pair is equal to another pair if both members are equal.

Parameters
other:Object

the other pair

Returns:boolean

true if they are equal, false otherwise

equalsback to summary
public boolean equals(final Pair<?, ?> other)

Determine if this pair equals another. A pair is equal to another pair if both members are equal.

Parameters
other:Pair<?, ?>

the other pair

Returns:boolean

true if they are equal, false otherwise

getAback to summary
public A getA()

Get the first value.

Returns:A

the first value

getBback to summary
public B getB()

Get the second value.

Returns:B

the second value

hashCodeback to summary
private static int hashCode(final Object a, final Object b)

Calculate the combined hash code of two objects.

Parameters
a:Object

the first object

b:Object

the second object

Returns:int

the combined hash code

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return the combined hash code of the two argument objects.

Returns:int

the combined hash code

readObjectback to summary
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException

Reinitialize the object and set the hash code.

Parameters
ois:ObjectInputStream

the object input stream

Exceptions
IOException:
if an I/O error occurs while reading the default fields
ClassNotFoundException:
if a class isn't found while reading the default fields
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Get a string representation of this pair.

Returns:String

the string representation

org.jboss.marshalling back to summary

public final Class Pair.Externalizer

extends Object
implements Externalizer, Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable, org.jboss.marshalling.Externalizer

An externalizer for Pair instances.

Field Summary

Modifier and TypeField and Description
private static final Pair.Externalizer
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
createExternal(final Class<?>
the type of object to create
subjectType
,
final ObjectInput
the input
input
)

Implements org.jboss.marshalling.Externalizer.createExternal.

Create an instance of a type.
public static Pair.Externalizer

Returns:

the instance
getInstance
()

Get the single instance.

public void
readExternal(final ObjectInput
the stream to read data from in order to restore the object
in
)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
protected Object

Returns:

the instance
readResolve
()

Resolve the object to the single externalizer instance.

public void
writeExternal(final Object
the object to externalize
subject
,
final ObjectOutput
the output
output
)

Implements org.jboss.marshalling.Externalizer.writeExternal.

Write the external representation of an object.
public void
writeExternal(final ObjectOutput
the stream to write the object to
out
)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private static final Pair.Externalizer instance
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Externalizerback to summary
public Externalizer()

Method Detail

createExternalback to summary
public Object createExternal(final Class<?> subjectType, final ObjectInput input) throws IOException, ClassNotFoundException

Implements org.jboss.marshalling.Externalizer.createExternal.

Doc from org.jboss.marshalling.Externalizer.createExternal.

Create an instance of a type. The object may then be initialized from input, or that may be deferred to the readExternal() method. Instances may simply delegate the task to the given Creator. Note that this method is called only on the leaf class, so externalizers for non-final classes that initialize the instance from the stream need to be aware of this.

Parameters
subjectType:Class<?>

the type of object to create

input:ObjectInput

the input

Returns:Object

the new instance

Exceptions
IOException:
if an error occurs
ClassNotFoundException:
if a class could not be found during read
getInstanceback to summary
public static Pair.Externalizer getInstance()

Get the single instance. Though multiple instances can be created using the public constructor, only a single instance need be used in practice since this class maintains no internal state.

Returns:Pair.Externalizer

the instance

readExternalback to summary
public void readExternal(final ObjectInput in)

Implements java.io.Externalizable.readExternal.

Doc from java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters
in:ObjectInput

the stream to read data from in order to restore the object

readResolveback to summary
protected Object readResolve()

Resolve the object to the single externalizer instance.

Returns:Object

the instance

writeExternalback to summary
public void writeExternal(final Object subject, final ObjectOutput output) throws IOException

Implements org.jboss.marshalling.Externalizer.writeExternal.

Doc from org.jboss.marshalling.Externalizer.writeExternal.

Write the external representation of an object. The object's class and the externalizer's class will already have been written.

Parameters
subject:Object

the object to externalize

output:ObjectOutput

the output

Exceptions
IOException:
if an error occurs
writeExternalback to summary
public void writeExternal(final ObjectOutput out)

Implements java.io.Externalizable.writeExternal.

Doc from java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Parameters
out:ObjectOutput

the stream to write the object to