📄 jco$record.java
字号:
row_length = 0;
if(JCO.trace_level > 9)
JCO.fireTrace(10, "[JAV-LAYER] Type1Record() [>>> " + ((Object)this).hashCode() + "]");
}
}
protected void finalize()
{
if(JCO.trace_level > 9)
JCO.fireTrace(10, "[JAV-LAYER] Record.finalize() [<<< " + Integer.toHexString(getObjectId()) + "]");
}
public Object clone()
{
JCO$Record obj = (JCO$Record)super.clone();
copyContent(this, obj);
if(JCO.trace_level > 9)
JCO.fireTrace(10, "[JAV-LAYER] Record.clone() [>>> " + Integer.toHexString(obj.getObjectId()) + "]");
return obj;
}
public boolean equals(Object obj)
{
if(!super.equals(obj))
return false;
if(!(obj instanceof JCO$Record))
return false;
JCO$Record rec = (JCO$Record)obj;
if(num_rows != rec.num_rows)
return false;
if(super.num_odata != ((a) (rec)).num_odata)
return false;
if(super.tab_length != ((a) (rec)).tab_length)
return false;
char d1[] = data;
char d2[] = rec.data;
int i = 0;
for(int size = num_rows * row_length; i < size; i++)
if(d1[i] != d2[i])
return false;
int i = 0;
for(int size = num_rows * super.num_odata; i < size; i++)
if(odata[i] != null || rec.odata[i] != null)
{
if(odata[i] == null && rec.odata[i] != null || odata[i] != null && rec.odata[i] == null)
return false;
if((odata[i] instanceof JCO$Record) || (odata[i] instanceof String))
{
if(!odata[i].equals(rec.odata[i]))
return false;
if(odata[i] instanceof byte[])
if(!Arrays.equals((byte[])odata[i], (byte[])rec.odata[i]))
return false;
else
throw new on(108, "JCO_ERROR_INTERNAL", "Unknown object type inside JCO.Record");
}
}
return true;
}
public int hashCode()
{
int hashcode = super.hashCode();
int size = num_rows * row_length;
for(int i = 0; i < size; i++)
hashcode = 31 * hashcode + data[i];
size = num_rows * super.num_odata;
for(int i = 0; i < size; i++)
if(odata[i] != null)
hashcode = 31 * hashcode + odata[i].hashCode();
return hashcode;
}
protected void copyContent(JCO$Record src, JCO$Record dest)
{
dest.rec_type = src.rec_type;
dest.row_length = src.row_length;
dest.num_rows = src.num_rows;
dest.row = src.row;
dest.modified = src.modified;
if(src.type1_record != null)
dest.type1_record = (Type1Record)src.type1_record.clone();
if(src.data != null)
dest.data = (char[])src.data.clone();
if(src.delta != null)
dest.delta = (int[])src.delta.clone();
if(src.opcode != null)
dest.opcode = (byte[])src.opcode.clone();
if(src.odata != null)
{
dest.odata = (Object[])src.odata.clone();
for(int i = 0; i < dest.odata.length; i++)
{
Object o = dest.odata[i];
if(o != null)
if(o instanceof JCO$Record)
o = ((JCO$Record)o).clone();
else
if(o instanceof String)
o = o;
else
if(o instanceof byte[])
o = ((byte[])o).clone();
dest.odata[i] = o;
}
}
}
protected ionException createConversionException(int index, String to_type)
{
return new ionException("Cannot convert field " + super.name[index] + " of type " + JCO.getJCOTypeString(super.type[index]) + " to " + to_type);
}
protected ionException createConversionException(int index, String from_type, String value)
{
if(value != null)
throw new ionException("Cannot convert a value of '" + value + "' from type " + from_type + " to " + JCO.getJCOTypeString(super.type[index]) + " at field " + super.name[index]);
else
throw new ionException("Cannot convert a value from type " + from_type + " to " + JCO.getJCOTypeString(super.type[index]) + " at field " + super.name[index]);
}
public void addInfo(String name, int type, int length, int offset, int decimals, String sdefault, String description,
int flags, Object tab_meta, IExtendedFieldMetaData extended)
{
super.addInfo(name, type, length, offset, decimals, sdefault, description, flags, tab_meta, extended);
if((rec_type & 4) == 0)
{
ensureBufferCapacity();
if(type == 17 && (tab_meta instanceof IMetaData))
super.flags[super.num_fields - 1] |= 8;
else
if(type != 99)
super.flags[super.num_fields - 1] |= 8;
}
}
protected void setModified(int row)
{
modified = true;
}
protected final boolean checkIfInitialized()
{
boolean is_initialized = false;
for(int i = 0; i < super.num_fields; i++)
if(super.type[i] == 17 || super.type[i] == 99 || super.type[i] == 29 || super.type[i] == 30)
if(super.type[i] == 17 && ((re)odata[super.oindex[i]]).checkIfInitialized())
{
super.flags[i] &= 0xf7;
is_initialized = true;
} else
if(super.type[i] == 99)
super.flags[i] &= 0xf7;
for(int i = 0; i < super.num_fields && !is_initialized; i++)
is_initialized = (super.flags[i] & 8) == 0;
return is_initialized;
}
protected void initializeRow(int irow)
{
int row_save = row;
row = irow;
String defval = null;
if((rec_type & 4) != 0 && row < num_rows)
{
System.arraycopy(data, num_rows * row_length, data, row * row_length, row_length);
if(odata != null && odata.length > 0)
{
for(int ifield = 0; ifield < super.num_fields; ifield++)
{
int itype = super.type[ifield];
Object template = odata[num_rows * super.num_odata + super.oindex[ifield]];
if((itype == 17 || itype == 99) && (template instanceof JCO$Record))
odata[row * super.num_odata + super.oindex[ifield]] = ((JCO$Record)template).clone();
else
if(itype == 30 && (template instanceof byte[]))
{
byte cloned[] = new byte[((byte[])template).length];
System.arraycopy((byte[])template, 0, cloned, 0, ((byte[])template).length);
odata[row * super.num_odata + super.oindex[ifield]] = cloned;
} else
if(itype == 29)
odata[row * super.num_odata + super.oindex[ifield]] = template;
}
}
} else
{
for(int ifield = 0; ifield < super.num_fields; ifield++)
{
int itype = super.type[ifield];
if((rec_type & 1) != 0 && irow == 0 && super.defaults != null && super.defaults[ifield] != null)
{
defval = super.defaults[ifield];
if(defval.equalsIgnoreCase("SY-DATUM"))
defval = daterfc.format(new Date());
else
if(defval.equalsIgnoreCase("SY-LANGU"))
defval = "EN";
else
if(defval.equalsIgnoreCase("SPACE"))
defval = null;
else
if(defval.indexOf("'") >= 0 && defval.lastIndexOf("'") > 0)
{
int i1 = defval.indexOf("'") + 1;
int i2 = defval.lastIndexOf("'");
defval = i1 <= 0 || i2 <= i1 ? null : defval.substring(i1, i2);
}
} else
{
defval = null;
}
if(itype == 0 || itype == 17 || itype == 99 || itype == 29 || itype == 30)
{
int istart = super.boffset[ifield] + row * row_length;
int iend = istart + super.blength[ifield];
for(int i = istart; i < iend; i++)
data[i] = ' ';
if(itype == 0 && defval != null)
{
int ioffset = super.boffset[ifield] + row * row_length;
int ilength = Math.min(super.blength[ifield], defval.length());
defval.getChars(0, ilength, data, ioffset);
} else
if(itype == 29 && odata != null)
odata[row * super.num_odata + super.oindex[ifield]] = defval == null ? null : ((Object) (defval));
else
if(itype == 30)
if(defval == null)
odata[row * super.num_odata + super.oindex[ifield]] = null;
else
odata[row * super.num_odata + super.oindex[ifield]] = com.sap.mw.jco.util.Codecs$Hex.decode(defval);
} else
if(itype == 1 || itype == 3 || itype == 6)
{
int istart = super.boffset[ifield] + row * row_length;
int iend = istart + super.blength[ifield];
for(int i = istart; i < iend; i++)
data[i] = '0';
if(defval != null)
{
int ioffset = super.boffset[ifield] + row * row_length;
int ilength = Math.min(super.blength[ifield], defval.length());
defval.getChars(0, ilength, data, ioffset);
}
} else
if(itype == 8 || itype == 9 || itype == 10)
{
if(defval != null)
try
{
encodeINT(Integer.parseInt(defval), ifield, false);
}
catch(on ex) { }
} else
if(itype == 7 && defval != null)
try
{
encodeFLOAT(Double.valueOf(defval).doubleValue(), ifield, false);
}
catch(on ex) { }
else
if(itype == 2)
if(defval != null)
{
try
{
encodeBCD(defval, ifield, false);
}
catch(on ex) { }
} else
{
int ilength = super.length[ifield] * 2 - 1;
data[super.boffset[ifield] + row * row_length + (ilength >> 2)] |= 12 << (3 - (ilength & 3) << 2);
}
if((itype == 17 || itype == 99) && (super.tab_meta[ifield] instanceof IMetaData))
{
int ioffset = super.boffset[ifield] + row * row_length;
int ilength = super.blength[ifield];
String value = ((IMetaData)super.tab_meta[ifield]).getName();
ilength = Math.min(value.length(), ilength);
value.getChars(0, ilength, data, ioffset);
}
if(odata != null && odata.length > 0)
if(itype == 17 && (super.tab_meta[ifield] instanceof IMetaData))
{
re obj = new re((IMetaData)super.tab_meta[ifield]);
odata[row * super.num_odata + super.oindex[ifield]] = obj;
obj.ensureBufferCapacity();
} else
if(itype == 99 && (super.tab_meta[ifield] instanceof IMetaData))
{
JCO$Table obj = new init>((IMetaData)super.tab_meta[ifield]);
odata[row * super.num_odata + super.oindex[ifield]] = obj;
obj.ensureBufferCapacity();
}
}
}
row = row_save;
}
protected void ensureBufferCapacity()
{
Object old_odata[] = null;
char old_data[] = null;
boolean should_init = false;
if(super.num_fields > 0)
row_length = super.boffset[super.num_fields - 1] + super.blength[super.num_fields - 1];
int ocapacity = (Math.max(num_rows, 1) + ((rec_type & 4) == 0 ? 0 : 1)) * super.num_odata;
if(odata == null || odata.length < ocapacity)
should_init = true;
int capacity = (Math.max(num_rows, 1) + ((rec_type & 4) == 0 ? 0 : 1)) * row_length;
if(data == null || data.length < capacity)
should_init = true;
if(should_init)
{
if(data != null && data.length > 0)
old_data = data;
data = new char[capacity];
if(odata != null && odata.length > 0)
old_odata = odata;
odata = new Object[ocapacity];
if((rec_type & 4) == 0)
{
for(int irow = 0; irow < num_rows; irow++)
initializeRow(irow);
}
if(old_data != null && old_data.length > 0)
System.arraycopy(old_data, 0, data, 0, old_data.length);
if(old_odata != null && old_odata.length > 0)
System.arraycopy(((Object) (old_odata)), 0, ((Object) (odata)), 0, old_odata.length);
}
if(opcode == null || opcode.length < num_rows)
{
byte old_opcode[] = opcode;
opcode = new byte[num_rows];
if(old_opcode != null)
System.arraycopy(old_opcode, 0, opcode, 0, old_opcode.length);
}
}
protected final void checkRowCapacity()
{
if((rec_type & 4) != 0 && num_rows == 0)
throw new on(106, "JCO_ERROR_RESOURCE", "Trying to access row values in a table which does not have any rows yet");
else
return;
}
public void clear()
{
initializeRow(0);
for(int i = 0; i < super.num_fields; i++)
if(super.type[i] == 99)
getTable(i).lear();
else
if(super.type[i] == 17)
getStructure(i).clear();
}
public int copyFrom(JCO$Record source)
{
if(source == null || ((a) (source)).num_fields == 0 || source.num_rows == 0)
return 0;
if(((a) (source)).num_fields == super.num_fields)
{
boolean metadata_equals = true;
for(int i = 0; i < ((a) (source)).num_fields; i++)
{
if(((a) (source)).type[i] == super.type[i] && ((a) (source)).name[i] == super.name[i] && ((a) (source)).boffset[i] == super.boffset[i] && ((a) (source)).blength[i] == super.blength[i])
continue;
metadata_equals = false;
break;
}
if(metadata_equals)
{
boolean is_table = (rec_type & 4) != 0;
if(is_table)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -