| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- package UIB.UIB03.ZBS;
- import java.util.ArrayList;
- import java.util.Stack;
- import org.apache.commons.collections.list.TreeList;
- import sun.reflect.generics.tree.Tree;
- /**
- * @desc 存放数据集合,并按照存入顺序取出数据,主键可重复
- * 每一个DataRowList均为一个钢卷的成分(材质)与卷号、重量、交货状态等信息
- * @author meiguiping
- * @date 2010 7:41:40 PM
- */
- public class DataRowList
- {
- private ArrayList key;//主键。存储钢卷号的字段名、元素名、材质代码信息、温度、位置方向,主键不可重复。
- private ArrayList value;//值。钢卷号、元素值、材质实绩值
- private ArrayList smallName;//小中文名,材质小中文名称
- private ArrayList bigName;//大中文名,材质大中文名称,如屈服、抗拉统称拉力
- private ArrayList extCode;//补充码,扩展码,如冲击的A1,拉力的Rel,Rt0.5
- private int len;//存入数据长度
- public DataRowList()
- {
- len = 0;
- key = new ArrayList(10);
- value = new ArrayList(10);
- smallName = new ArrayList(10);
- bigName = new ArrayList(10);
- extCode = new ArrayList();
- }
-
- /**
- * @desc 获取录入数据长度
- * @return
- */
- public int size()
- {
- return len;
- }
-
- public void put(Object key , Object value)
- {
- try
- {
- if(null == key)
- {
- throw new Exception("DataRowList主键不可为null,请检查。");
- }
- else if("".equals(key.toString().trim()))
- {
- throw new Exception("DataRowList主键不可为空,清检查。");
- }
- else if(keyExist(key))
- {
- throw new Exception("DataRowList主键重复,请检查。");
- }
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- return;
- }
- this.key.add(key);
- this.value.add(value==null?"":value);
- this.smallName.add("");
- this.bigName.add("");
- this.extCode.add("");
- len++;
- }
-
- public void put(Object key , Object value , Object extCode)
- {
- try
- {
- if(keyExist(key))
- {
- throw new Exception("DataRowList主键重复,请检查");
- }
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- return;
- }
- this.key.add(key);
- this.value.add(value);
- this.smallName.add("");
- this.bigName.add("");
- this.extCode.add(extCode);
- len++;
- }
-
- public void put(Object key , Object value , Object smallName , Object bigName , Object extCode)
- {
- try
- {
- if(keyExist(key))
- {
- throw new Exception("DataRowList主键重复增加,请检查。");
- }
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- return;
- }
- this.key.add(key);
- this.value.add(value);
- this.smallName.add(smallName);
- this.bigName.add(bigName);
- this.extCode.add(extCode);
- len++;
- }
-
- /**
- * @desc 修改制定位置主键所对应的其它所有值
- * @param key
- * @param value
- * @param smallName
- * @param bigName
- * @param extCode
- */
- public void set(Object key , Object value , Object smallName , Object bigName , Object extCode)
- {
- int keyIndex = -1;
- for(int index = 0; index < len ; index++)
- {
- if(this.key.get(index).equals(key))
- {
- keyIndex = index;
- break;
- }
- }
-
- if(keyIndex != -1)//若主键存在,则修改value、smallName、bigName、extCode的值
- {
- this.value.set(keyIndex, value);
- this.smallName.set(keyIndex, smallName);
- this.bigName.set(keyIndex, bigName);
- this.extCode.set(keyIndex, extCode);
- }
- }
-
- /**
- * @desc 在指定位置增加
- * @param index
- * @param key
- * @param value
- * @param smallName
- * @param bigName
- * @param extCode
- */
- public void add(int index , Object key , Object value , Object smallName , Object bigName , Object extCode)
- {
- try
- {
- if(keyExist(key))
- {
- throw new Exception("DataRowList主键重复增加,请检查。");
- }
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- return;
- }
- this.key.add(index, key);
- this.value.add(index, value);
- this.smallName.add(index, smallName);
- this.bigName.add(index, bigName);
- this.extCode.add(index, extCode);
- len++;
- }
-
- /**
- * @desc 判断主键是否重复
- * @param key
- * @return
- */
- public boolean keyExist(Object key)
- {
- boolean flag = false;
- for(int i = 0 ; i < len ; i++)
- {
- if( this.key.get(i).equals(key) )
- {
- flag = true;
- break;
- }
- }
- return flag;
- }
-
- public Object getKey(int index)
- {
- Object o = null;
- try
- {
- if(index >= len )
- throw new Exception("DataRowList数组越界!");
- o = key.get(index);
- }catch(Exception ex)
- {
- ex.printStackTrace();
- }
-
- return o;
- }
-
- public Object getValue(int index)
- {
- Object o = null;
- o = value.get(index);
- return o;
- }
-
- public Object getSmallName(int index)
- {
- Object o = null;
- o = smallName.get(index);
- return o;
- }
-
- public Object getBigName(int index)
- {
- Object o = null;
- o = bigName.get(index);
- return o;
- }
-
- public Object getExtCode(int index)
- {
- Object o = null;
- o = extCode.get(index);
- return o;
- }
-
- public Object getValue(Object key)
- {
- Object o = null;
- for(int index =0; index < len ; index++)
- {
- if(key.equals(this.key.get(index)))
- {
- o = value.get(index);
- break;
- }
- }
- return o;
- }
-
- public Object getSmallName(Object key)
- {
- Object o = null;
- for(int index =0; index < len ; index++)
- {
- if(key.equals(this.key.get(index)))
- {
- o = smallName.get(index);
- break;
- }
- }
- return o;
- }
-
- public Object getBigName(Object key)
- {
- Object o = null;
- for(int index =0; index < len ; index++)
- {
- if(key.equals(this.key.get(index)))
- {
- o = bigName.get(index);
- break;
- }
- }
- return o;
- }
-
- public Object getExtCode(Object key)
- {
- Object o = null;
- for(int index =0; index < len ; index++)
- {
- if(key.equals(this.key.get(index)))
- {
- o = extCode.get(index);
- break;
- }
- }
- return o;
- }
-
-
- public void print()
- {
- for(int i = 0; i < len ; i++)
- {
- System.out.println("key="+key.get(i)+" value="+value.get(i)+" smallName="+smallName.get(i)+" bigName="+bigName.get(i)+" extCode="+extCode.get(i));
- }
- }
- }
|