org.apache.pig.scripting.jruby
Class RubyDataByteArray

java.lang.Object
  extended by org.jruby.RubyBasicObject
      extended by org.jruby.RubyObject
          extended by org.apache.pig.scripting.jruby.RubyDataByteArray
All Implemented Interfaces:
Serializable, Cloneable, Comparable<org.jruby.runtime.builtin.IRubyObject>, org.jruby.runtime.builtin.InstanceVariables, org.jruby.runtime.builtin.InternalVariables, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.marshal.CoreObjectType

public class RubyDataByteArray
extends org.jruby.RubyObject

This class presents a native Ruby object for interacting with and manipulating DataByteArray objects. For more information on what the annotations mean, see RubyDataBag.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
org.jruby.RubyObject.Data
 
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
org.jruby.RubyBasicObject.Finalizer
 
Field Summary
 
Fields inherited from class org.jruby.RubyObject
OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
 
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
protected RubyDataByteArray(org.jruby.Ruby ruby, org.jruby.RubyClass rc)
          This constructor encapsulated a null DataByteArray.
protected RubyDataByteArray(org.jruby.Ruby ruby, org.jruby.RubyClass rc, byte[] buf)
          This constructor creates a new DataByteArray with a reference to the provided bytes.
protected RubyDataByteArray(org.jruby.Ruby ruby, org.jruby.RubyClass rc, DataByteArray dba)
          Given a DataByteArray, this constructor creates a new one which copies the underlying bytes.
protected RubyDataByteArray(org.jruby.Ruby ruby, org.jruby.RubyClass rc, DataByteArray dba1, DataByteArray dba2)
          This constructor makes a RubyDataByteArray whose underlying bytes are a concatenation of the given bytes.
 
Method Summary
 void append(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
          This calls to the append function of the underlying DataByteArray.
static org.jruby.RubyFixnum compare(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
          This calls to the static method compare of DataByteArray.
 org.jruby.RubyFixnum compareTo(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
          This calls the compareTo method of the encapsulated DataByteArray.
static org.jruby.RubyClass define(org.jruby.Ruby runtime)
          Registers the DataByteArray class with the Ruby runtime.
 org.jruby.RubyBoolean equals(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
          Overrides equality leveraging DataByteArray's equality.
 DataByteArray getDBA()
           
 org.jruby.runtime.builtin.IRubyObject hash(org.jruby.runtime.ThreadContext context)
          Overrides ruby's hash leveraging DataByteArray's hash.
 RubyDataByteArray initialize()
          This is the default initializer, which returns an empty DataByteArray.
 RubyDataByteArray initialize(org.jruby.runtime.builtin.IRubyObject arg)
          Given a String or a set of bytes[], initializes the encapsulated DataByteArray using DataByteArray.set(byte[]).
 RubyDataByteArray initialize(org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
          Given two RubyDataByteArrays, initializes the encapsulated DataByteArray to be a concatentation of the copied bits of the first and second.
 org.jruby.runtime.builtin.IRubyObject plus(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
          This method accepts as an argument anything that could be passed to set (ie a RubyDataByteArray, RubyString, or byte array).
 void set(org.jruby.runtime.builtin.IRubyObject arg)
          This method calls the set method of the underlying DataByteArray with one exception: if given a RubyDataByteArray, it will set the encapsulated DataByteArray to be equal.
 org.jruby.RubyFixnum size(org.jruby.runtime.ThreadContext context)
           
 org.jruby.runtime.builtin.IRubyObject toString(org.jruby.runtime.ThreadContext context)
           
 
Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, getNativeTypeIndex, hashCode, initialize, op_eqq, puts, specificEval, toString
 
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, getVariableTableForRead, getVariableTableForWrite, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize_copy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RubyDataByteArray

protected RubyDataByteArray(org.jruby.Ruby ruby,
                            org.jruby.RubyClass rc)
This constructor encapsulated a null DataByteArray.

Parameters:
ruby - an instance of the ruby runtime
rc - an instance of the class object with meatadata

RubyDataByteArray

protected RubyDataByteArray(org.jruby.Ruby ruby,
                            org.jruby.RubyClass rc,
                            DataByteArray dba)
Given a DataByteArray, this constructor creates a new one which copies the underlying bytes.

Parameters:
ruby - an instance of the ruby runtime
rc - an instance of the class object with meatadata
dba - a DataByteArray to copy then encapsulate

RubyDataByteArray

protected RubyDataByteArray(org.jruby.Ruby ruby,
                            org.jruby.RubyClass rc,
                            DataByteArray dba1,
                            DataByteArray dba2)
This constructor makes a RubyDataByteArray whose underlying bytes are a concatenation of the given bytes. The new DataByteArray will not point to the original bytes.

Parameters:
ruby - an instance of the ruby runtime
rc - an instance of the class object with meatadata
dba1 - first DataByteArray in the concatentation
dba2 - second DAtaByteArray whose bytes will be concatenated to the first's

RubyDataByteArray

protected RubyDataByteArray(org.jruby.Ruby ruby,
                            org.jruby.RubyClass rc,
                            byte[] buf)
This constructor creates a new DataByteArray with a reference to the provided bytes.

Parameters:
ruby - an instance of the ruby runtime
rc - an instance of the class object with meatadata
buf - a byte array to encapsulate directly
Method Detail

define

public static org.jruby.RubyClass define(org.jruby.Ruby runtime)
Registers the DataByteArray class with the Ruby runtime.

Parameters:
runtime - an instance of the Ruby runtime
Returns:
a RubyClass object with metadata about the registered class

getDBA

public DataByteArray getDBA()

initialize

public RubyDataByteArray initialize()
This is the default initializer, which returns an empty DataByteArray.

Overrides:
initialize in class org.jruby.RubyObject
Returns:
the initialized RubyDataByteArray

initialize

public RubyDataByteArray initialize(org.jruby.runtime.builtin.IRubyObject arg)
Given a String or a set of bytes[], initializes the encapsulated DataByteArray using DataByteArray.set(byte[]). In the case of a DataByteArray, will copy the underlying bytes.

Parameters:
arg - a value to set the encapsulated DataByteArray to. A DataByteArray will be copied, whereas a byte array will be encapsulated directly, and a string's bits will be used per DataByteArray.set(byte[]).
Returns:
the initialized RubyDataByteArray

initialize

public RubyDataByteArray initialize(org.jruby.runtime.builtin.IRubyObject arg1,
                                    org.jruby.runtime.builtin.IRubyObject arg2)
Given two RubyDataByteArrays, initializes the encapsulated DataByteArray to be a concatentation of the copied bits of the first and second.

Parameters:
arg1 - the first RubyDataByteArray whose bits will be used
arg2 - the second RubyDataByteArray whose bits will be concatenated after the first's
Returns:
the initialized RubyDataBytearray

append

public void append(org.jruby.runtime.ThreadContext context,
                   org.jruby.runtime.builtin.IRubyObject arg)
This calls to the append function of the underlying DataByteArray. This accepts the same types that set accepts.

Parameters:
context - the context the method is being executed in
arg - a value to append to the encpasulated DataByteArray. In the case of a RubyDataByteArray, the bytes will be copied and appended; in the case of a String, the bits will be added; in the case of a byte array, the bytes will be appended directly.

compare

public static org.jruby.RubyFixnum compare(org.jruby.runtime.ThreadContext context,
                                           org.jruby.runtime.builtin.IRubyObject self,
                                           org.jruby.runtime.builtin.IRubyObject arg1,
                                           org.jruby.runtime.builtin.IRubyObject arg2)
This calls to the static method compare of DataByteArray. Given two DataByteArrays, it will call it on the underlying bytes.

Parameters:
context - the context the method is being executed in
self - an class which contains metadata on the calling class (required for static Ruby methods)
arg1 - a RubyDataByteArray or byte array to compare
arg2 - a RubyDataByteArray or byte array to compare
Returns:
the Fixnum result of comparing arg1 and arg2's bytes

compareTo

public org.jruby.RubyFixnum compareTo(org.jruby.runtime.ThreadContext context,
                                      org.jruby.runtime.builtin.IRubyObject arg)
This calls the compareTo method of the encapsulated DataByteArray.

Parameters:
context - the context the method is being executed in
arg - a RubyDataByteArray or byte array to compare to the encapsulated DataByteArray
Returns:
the result of compareTo on the encapsulated DataByteArray and arg

equals

public org.jruby.RubyBoolean equals(org.jruby.runtime.ThreadContext context,
                                    org.jruby.runtime.builtin.IRubyObject arg)
Overrides equality leveraging DataByteArray's equality.

Parameters:
context - the context the method is being executed in
arg - a RubyDataByteArray against which to test equality
Returns:
true if they are equal, false otherwise

hash

public org.jruby.runtime.builtin.IRubyObject hash(org.jruby.runtime.ThreadContext context)
Overrides ruby's hash leveraging DataByteArray's hash.

Parameters:
context - the context the method is being executed in
Returns:
the encapsulated DataByteArray's hashCode()

set

public void set(org.jruby.runtime.builtin.IRubyObject arg)
This method calls the set method of the underlying DataByteArray with one exception: if given a RubyDataByteArray, it will set the encapsulated DataByteArray to be equal.

Parameters:
arg - an object to set the encapsulated DataByteArray's bits to. In the case of a RubyString or byte array, the underlying bytes will be sit directly. In the case of a RubyDataByteArray, the encapsulated DataByteArray will be set equal to arg.

size

public org.jruby.RubyFixnum size(org.jruby.runtime.ThreadContext context)
Parameters:
context - the context the method is being executed in
Returns:
the size of the encapsulated DataByteArray

plus

public org.jruby.runtime.builtin.IRubyObject plus(org.jruby.runtime.ThreadContext context,
                                                  org.jruby.runtime.builtin.IRubyObject arg)
This method accepts as an argument anything that could be passed to set (ie a RubyDataByteArray, RubyString, or byte array). It then adds those values together.

Parameters:
context - the context the method is being executed in
arg - any argument that can validly initialize a RubyDataByteArray
Returns:
a new RubyDataByteArray that is the concatentation of the encapsulated DataByteArray and arg

toString

public org.jruby.runtime.builtin.IRubyObject toString(org.jruby.runtime.ThreadContext context)
Parameters:
context - the context the method is being executed in
Returns:
the string representation of the encapsulated DataByteArray


Copyright © 2007-2012 The Apache Software Foundation