in yoko-core/src/main/java/org/apache/yoko/orb/DynamicAny/DynSeqBase_impl.java [489:667]
protected void resize(int len, boolean init) {
if (primitive_ && len > length_) {
switch (contentKind_.value()) {
case org.omg.CORBA.TCKind._tk_short:
case org.omg.CORBA.TCKind._tk_ushort: {
short[] oldBuf = (short[]) buf_;
if (len > 0) {
short[] buf = new short[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_long:
case org.omg.CORBA.TCKind._tk_ulong: {
int[] oldBuf = (int[]) buf_;
if (len > 0) {
int[] buf = new int[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_float: {
float[] oldBuf = (float[]) buf_;
if (len > 0) {
float[] buf = new float[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_double: {
double[] oldBuf = (double[]) buf_;
if (len > 0) {
double[] buf = new double[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_boolean: {
boolean[] oldBuf = (boolean[]) buf_;
if (len > 0) {
boolean[] buf = new boolean[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_char:
case org.omg.CORBA.TCKind._tk_wchar: {
char[] oldBuf = (char[]) buf_;
if (len > 0) {
char[] buf = new char[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_octet: {
byte[] oldBuf = (byte[]) buf_;
if (len > 0) {
byte[] buf = new byte[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_string:
case org.omg.CORBA.TCKind._tk_wstring: {
String[] oldBuf = (String[]) buf_;
if (len > 0) {
String[] buf = new String[len];
if (init) {
if (oldBuf != null) {
System.arraycopy(oldBuf, 0, buf, 0, length_);
for (int i = length_; i < len; i++)
buf[i] = "";
} else {
for (int i = 0; i < len; i++)
buf[i] = "";
}
}
buf_ = buf;
} else
buf_ = null;
break;
}
case org.omg.CORBA.TCKind._tk_longlong:
case org.omg.CORBA.TCKind._tk_ulonglong: {
long[] oldBuf = (long[]) buf_;
if (len > 0) {
long[] buf = new long[len];
if (init && oldBuf != null)
System.arraycopy(oldBuf, 0, buf, 0, length_);
buf_ = buf;
} else
buf_ = null;
break;
}
default:
org.apache.yoko.orb.OB.Assert._OB_assert("Unsupported sequence type");
}
}
//
// Update the components_ sequence. Although we use a separate
// array for primitive types, we still keep the length of the
// components_ sequence consistent. New elements are initialized
// to nil for primitive types.
//
if (len > length_) // increase length
{
org.omg.DynamicAny.DynAny[] components = new org.omg.DynamicAny.DynAny[len];
System.arraycopy(components_, 0, components, 0, length_);
if ((contentKind_.value() == org.omg.CORBA.TCKind._tk_value)
&& (dynValueReader_ != null)) {
for (int i = length_; i < len; i++)
components[i] = null;
} else {
for (int i = length_; i < len; i++) {
if (!primitive_)
components[i] = prepare(contentType_, dynValueReader_,
true);
else
components[i] = null;
}
}
components_ = components;
} else if (len < length_) // decrease length
{
org.omg.DynamicAny.DynAny[] components = new org.omg.DynamicAny.DynAny[len];
System.arraycopy(components_, 0, components, 0, len);
components_ = components;
}
//
// Update the current position, if necessary
//
if (len > length_) // length was increased
{
if (index_ == -1)
index_ = length_; // first newly-added element
} else if (len < length_) // length was decreased
{
if (len == 0 || index_ >= len)
index_ = -1;
}
length_ = len;
}