com.nhncorp.neptune.common.io
Class NObjectWritable

java.lang.Object
  extended by com.nhncorp.neptune.common.io.NObjectWritable
All Implemented Interfaces:
NConfigurable, NWritable

public class NObjectWritable
extends java.lang.Object
implements NWritable, NConfigurable

A polymorphic Writable that writes an instance with it's class name. Handles arrays, strings and primitive types without a Writable wrapper.


Field Summary
static org.apache.commons.logging.Log LOG
           
static short TYPE_DIFF
           
static short TYPE_SAME
           
 
Constructor Summary
NObjectWritable()
           
NObjectWritable(java.lang.Class declaredClass, java.lang.Object instance)
           
NObjectWritable(java.lang.Object instance)
           
 
Method Summary
 java.lang.Object get()
          Return the instance, or null if none.
 NConfiguration getConf()
          Return the configuration used by this object.
 java.lang.Class getDeclaredClass()
          Return the class this is meant to be.
static void main(java.lang.String[] args)
           
 void readFields(java.io.DataInput in)
          Reads the fields of this object from in.
static java.lang.Object readObject(java.io.DataInput in, NConfiguration conf)
          Read a NWritable, String, primitive type, or an array of the preceding.
static java.lang.Object readObject(java.io.DataInput in, NObjectWritable objectWritable, NConfiguration conf)
           
static java.lang.Object readObject(java.io.DataInput in, NObjectWritable objectWritable, NConfiguration conf, boolean arrayComponent, java.lang.Class componentClass)
          Read a NWritable, String, primitive type, or an array of the preceding.
 void set(java.lang.Object instance)
          Reset the instance.
 void setConf(NConfiguration conf)
          Set the configuration to be used by this object.
static java.lang.Object test(java.lang.Object instance, java.lang.Class instanceClass)
           
static void testString()
           
 java.lang.String toString()
           
 void write(java.io.DataOutput out)
          Writes the fields of this object to out.
static void writeObject(java.io.DataOutput out, java.lang.Object instance, java.lang.Class declaredClass, NConfiguration conf)
           
static void writeObject(java.io.DataOutput out, java.lang.Object instance, java.lang.Class declaredClass, NConfiguration conf, boolean arrayComponent)
          Write a NWritable, String, primitive type, or an array of the preceding.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

TYPE_SAME

public static final short TYPE_SAME
See Also:
Constant Field Values

TYPE_DIFF

public static final short TYPE_DIFF
See Also:
Constant Field Values
Constructor Detail

NObjectWritable

public NObjectWritable()

NObjectWritable

public NObjectWritable(java.lang.Object instance)

NObjectWritable

public NObjectWritable(java.lang.Class declaredClass,
                       java.lang.Object instance)
Method Detail

get

public java.lang.Object get()
Return the instance, or null if none.


getDeclaredClass

public java.lang.Class getDeclaredClass()
Return the class this is meant to be.


set

public void set(java.lang.Object instance)
Reset the instance.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Description copied from interface: NWritable
Reads the fields of this object from in. For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface NWritable
Throws:
java.io.IOException

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Description copied from interface: NWritable
Writes the fields of this object to out.

Specified by:
write in interface NWritable
Throws:
java.io.IOException

writeObject

public static void writeObject(java.io.DataOutput out,
                               java.lang.Object instance,
                               java.lang.Class declaredClass,
                               NConfiguration conf)
                        throws java.io.IOException
Throws:
java.io.IOException

writeObject

public static void writeObject(java.io.DataOutput out,
                               java.lang.Object instance,
                               java.lang.Class declaredClass,
                               NConfiguration conf,
                               boolean arrayComponent)
                        throws java.io.IOException
Write a NWritable, String, primitive type, or an array of the preceding.

Throws:
java.io.IOException

readObject

public static java.lang.Object readObject(java.io.DataInput in,
                                          NConfiguration conf)
                                   throws java.io.IOException
Read a NWritable, String, primitive type, or an array of the preceding.

Throws:
java.io.IOException

readObject

public static java.lang.Object readObject(java.io.DataInput in,
                                          NObjectWritable objectWritable,
                                          NConfiguration conf)
                                   throws java.io.IOException
Throws:
java.io.IOException

readObject

public static java.lang.Object readObject(java.io.DataInput in,
                                          NObjectWritable objectWritable,
                                          NConfiguration conf,
                                          boolean arrayComponent,
                                          java.lang.Class componentClass)
                                   throws java.io.IOException
Read a NWritable, String, primitive type, or an array of the preceding.

Throws:
java.io.IOException

setConf

public void setConf(NConfiguration conf)
Description copied from interface: NConfigurable
Set the configuration to be used by this object.

Specified by:
setConf in interface NConfigurable

getConf

public NConfiguration getConf()
Description copied from interface: NConfigurable
Return the configuration used by this object.

Specified by:
getConf in interface NConfigurable

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

test

public static java.lang.Object test(java.lang.Object instance,
                                    java.lang.Class instanceClass)
                             throws java.lang.Exception
Throws:
java.lang.Exception

testString

public static void testString()
                       throws java.lang.Exception
Throws:
java.lang.Exception