📄 jmvlist.java
字号:
package jm.util;
import java.math.BigDecimal;
import java.util.AbstractList;
import java.util.Collections;
import java.util.List;
import java.util.RandomAccess;
@SuppressWarnings ("unchecked")
public class JMVList extends AbstractList implements List,
RandomAccess,
Cloneable,
java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 8199281616259031347L;
public static final String CLASS_NAME = "JMList";
private JMVector<JMVal> elm = null;
public JMVList () {
// super () ;
elm = new JMVector<JMVal>();
}
/**
* Returns a shallow copy of this <tt>JMVector</tt> instance. (The
* elements themselves are not copied.)
*
* @return a clone of this <tt>JMVector</tt> instance.
*/
public JMVector clone () {
return (JMVector) elm.clone();
}
public boolean equals (Object obj) {
if (JMUtility.compare(obj, this) != 0) {
return false;
}
return true;
}
public boolean contains (Object elem) {
return elm.contains(elem);
}
public JMVector getTypes () {
try {
JMVector<String> type = new JMVector<String>();
for (JMVal val : elm) {
type.add("" + val.getDataType());
}
return type;
} catch (Exception e) {
return new JMVector();
}
}
/**
* Returns the element at the specified position in this list.
*
* @param index index of element to return.
* @return the element at the specified position in this list.
* @todo Implement this java.util.List method
*/
public JMVal get (int i) {
return elm.get(i);
}
public JMVal remove (int i) {
return elm.remove(i);
}
/**
* Returns an array containing all of the elements in this collection. If
* the collection makes any guarantees as to what order its elements are
* returned by its iterator, this method must return the elements in the
* same order. The returned array will be "safe" in that no references to
* it are maintained by the collection. (In other words, this method must
* allocate a new array even if the collection is backed by an Array).
* The caller is thus free to modify the returned array.<p>
*
* This implementation allocates the array to be returned, and iterates
* over the elements in the collection, storing each object reference in
* the next consecutive element of the array, starting with element 0.
*
* @return an array containing all of the elements in this collection.
*/
public Object[] toArray () {
return elm.toArray();
}
/**
* Returns the number of elements in this list.
*
* @return the number of elements in this list.
* @todo Implement this java.util.List method
*/
public int size () {
return elm.size();
}
public void add (JMVal value) {
elm.add(value);
}
/*
儕僗僩偺巜掕偝傟偨埵抲偵偁傞梫慺傪丄巜掕偝傟偨梫慺偱抲偒姺偊傑偡丅
掕媊:
僀儞僞僼僃乕僗 List<E> 撪偺 set
僆乕僶乕儔僀僪:
僋儔僗 AbstractList<E> 撪偺 set
僷儔儊乕僞:
index - 抲姺偝傟傞梫慺偺僀儞僨僢僋僗
element - 巜掕偝傟偨埵抲偵奿擺偝傟傞梫慺
栠傝抣:
巜掕偝傟偨埵抲偵埲慜偁偭偨梫慺
椺奜:
IndexOutOfBoundsException - 僀儞僨僢僋僗偑斖埻奜偺応崌 (index < 0 || index >= size())
*/
public JMVal set (int index,
JMVal element) throws IndexOutOfBoundsException {
try {
return elm.set(index, element);
} catch (IndexOutOfBoundsException e) {
throw e;
}
}
public void synchronizedList () {
try {
List<JMVal> elmnew = new JMVector<JMVal>();
elmnew = Collections.synchronizedList(elm);
elm = (jm.util.JMVector<JMVal>) elmnew;
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* byte 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param ayValue byte 宆崁栚抣
*/
public void add (byte ayValue) {
elm.add(new JMVal(ayValue));
}
/**
* short 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param ahValue short 宆崁栚抣
*/
public void add (short ahValue) {
elm.add(new JMVal(ahValue));
}
/**
* int 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param aiValue int 宆崁栚抣
*/
public void add (int aiValue) {
elm.add(new JMVal(aiValue));
}
/**
* long 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param alValue long 宆崁栚抣
*/
public void add (long alValue) {
elm.add(new JMVal(alValue));
}
/**
* float 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param afValue float 宆崁栚抣
*/
public void add (float afValue) {
elm.add(new JMVal(afValue));
}
/**
* double 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param adValue double 宆崁栚抣
*/
public void add (double adValue) {
elm.add(new JMVal(adValue));
}
/**
* char 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param acValue char 宆崁栚抣
*/
public void add (char acValue) {
elm.add(new JMVal(acValue));
}
/**
* boolean 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param abValue boolean 宆崁栚抣
*/
public void add (boolean abValue) {
elm.add(new JMVal(abValue));
}
/**
* String 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param asValue String 宆崁栚抣
*/
public void add (String asValue) {
elm.add(new JMVal(asValue));
}
/**
* BigDecimal 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param asValue BigDecimal 宆崁栚抣
*/
public void add (BigDecimal asValue) {
elm.add(new JMVal(asValue));
}
/**
* byte[] 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param ayValues byte[] 宆崁栚抣
*/
public void add (byte[] ayValues) {
elm.add(new JMVal(ayValues));
}
/**
* java.util.Date 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param adtValue java.util.Date 宆崁栚抣
*/
public void add (java.util.Date adtValue) {
elm.add(new JMVal(adtValue));
}
/**
* java.sql.Time 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param adtValue java.sql.Time 宆崁栚抣
*/
public void add (java.sql.Time adtValue) {
elm.add(new JMVal(adtValue));
}
/**
* java.sql.Timestamp 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param adtValue java.sql.Timestamp 宆崁栚抣
*/
public void add (java.sql.Timestamp adtValue) {
elm.add(new JMVal(adtValue));
}
/**
* JM2DArray 宆偺崁栚抣傪曐帩偡傞応崌偺僐儞僗僩儔僋僞
* @param aoValue JM2DArray 宆崁栚抣
*/
public void add (JM2DArray aoValue) {
elm.add(new JMVal(aoValue));
}
//////////////////////////////////////////////////////////////////////////
// public 儊僜僢僪
/**
* 曐帩偟偰偄傞崁栚抣偑 null 偐偳偆偐傪曉偡丅
* @return null 抣偺応崌 true丄偦偆偱側偗傟偽 false
*/
public boolean isNull (int i) {
return get(i).isNull();
}
/**
* 曐帩偟偰偄傞崁栚抣偑 null 偐偳偆偐傪曉偡丅
* @return null 抣偺応崌 true丄偦偆偱側偗傟偽 false
*/
public boolean isSame () {
try {
for (JMVal val : this.elm) {
if (get(0).getDataType() != val.getDataType())
return false;
}
return true;
} catch (Exception e) {
return false;
}
}
/**
* 崁栚抣傪 byte 宆偲偟偰曉偡丅
* @return 崁栚抣乮byte 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public byte getByteValue (int i) throws ClassCastException {
return get(i).getByteValue();
}
/**
* 崁栚抣傪 short 宆偲偟偰曉偡丅
* @return 崁栚抣乮short 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public short getShortValue (int i) throws ClassCastException {
return get(i).getShortValue();
}
/**
* 崁栚抣傪 int 宆偲偟偰曉偡丅
* @return 崁栚抣乮int 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public int getIntValue (int i) throws ClassCastException {
return get(i).getIntValue();
}
/**
* 崁栚抣傪 long 宆偲偟偰曉偡丅
* @return 崁栚抣乮long 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public long getLongValue (int i) throws ClassCastException {
return get(i).getLongValue();
}
/**
* 崁栚抣傪 float 宆偲偟偰曉偡丅
* @return 崁栚抣乮float 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public float getFloatValue (int i) throws ClassCastException {
return get(i).getFloatValue();
}
/**
* 崁栚抣傪 double 宆偲偟偰曉偡丅
* @return 崁栚抣乮double 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public double getDoubleValue (int i) throws ClassCastException {
return get(i).getDoubleValue();
}
/**
* 崁栚抣傪 char 宆偲偟偰曉偡丅
* @return 崁栚抣乮char 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public char getCharValue (int i) throws ClassCastException {
return get(i).getCharValue();
}
/**
* 崁栚抣傪 boolean 宆偲偟偰曉偡丅
* @return 崁栚抣乮boolean 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public boolean getBooleanValue (int i) throws ClassCastException {
return get(i).getBooleanValue();
}
/**
* 崁栚抣傪 String 宆偲偟偰曉偡丅
* @return 崁栚抣乮String 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public String getStringValue (int i) throws ClassCastException {
return get(i).getStringValue();
}
/**
* 崁栚抣傪 byte[] 宆偲偟偰曉偡丅
* @return 崁栚抣乮byte[] 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public byte[] getByteArrayValue (int i) throws ClassCastException {
return get(i).getByteArrayValue();
}
/**
* 崁栚抣傪 java.util.Date 宆偲偟偰曉偡丅
* @return 崁栚抣乮java.util.Date 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public java.util.Date getDateValue (int i) throws ClassCastException {
return get(i).getDateValue();
}
/**
* 崁栚抣傪 JM2DArray 宆偲偟偰曉偡丅
* @return 崁栚抣乮JM2DArray 宆乯
* @throws ClassCastException 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌
*/
public JM2DArray getJM2DArrayValue (int i) throws ClassCastException {
return get(i).getJM2DArrayValue();
}
/**
* 僆僽僕僃僋僩偑曐帩偡傞崁栚抣傪捈楍壔偟偰弌椡僗僩儕乕儉偵彂偒崬傓丅
* @param aoStream 弌椡僗僩儕乕儉
* @throws Exception 擖弌椡僄儔乕偑敪惗偟偨応崌丄
* 晄惓側僨乕僞宆曄姺偑巜掕偝傟偨応崌丄
* 僆僽僕僃僋僩忬懺偑晄惓偺応崌
*/
public void serializeTo (JMOutputStream aoStream) throws Exception {
for (int i = 0; i < elm.size(); i++) {
elm.get(i).serializeTo(aoStream);
}
aoStream.flush();
}
/**
* 僆僽僕僃僋僩偺撪梕傪昞尰偡傞暥帤楍傪曉偡丅
* @return 僆僽僕僃僋僩撪梕暥帤楍
*/
public String toString () {
return elm.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -