📄 servermodel.java
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2004-2-20 9:17:09
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: ServerModel.java
package utility.HWCacheTable;
import java.util.*;
import javax.swing.SwingUtilities;
// Referenced classes of package utility.HWCacheTable:
// SortedID, CacheTableModel
public abstract class ServerModel
{
class CompImp
implements Comparator
{
public boolean equals(Object obj)
{
return false;
}
public int compare(Object obj, Object obj1)
{
try
{
SortedID sortedid = (SortedID)obj;
SortedID sortedid1 = (SortedID)obj1;
if(sortedid.getSN() == sortedid1.getSN())
return 0;
return sortedid.getSN() >= sortedid1.getSN() ? 1 : -1;
}
catch(Exception exception)
{
return -1;
}
}
CompImp()
{
}
}
public ServerModel(Vector vector)
{
allIDList = null;
_iCount = -1;
_tableModel = null;
_blThrow = false;
setIDList(vector);
}
public ServerModel()
{
allIDList = null;
_iCount = -1;
_tableModel = null;
_blThrow = false;
}
public void setIDList(Vector vector)
{
if(vector != null)
{
_iCount = vector.size();
allIDList = new TreeMap(new CompImp());
for(int i = 0; i < vector.size(); i++)
{
SortedID sortedid = new SortedID(vector.elementAt(i), i);
allIDList.put(sortedid, sortedid);
}
} else
{
allIDList = null;
_iCount = -1;
}
}
public void setTableModel(CacheTableModel cachetablemodel)
{
_tableModel = cachetablemodel;
}
public final int getSize()
{
if(allIDList != null)
return allIDList.size();
else
return 0;
}
public void setThrowFlag(boolean flag)
{
_blThrow = flag;
}
public final synchronized Vector getPage(int i, int j, boolean flag)
{
_blThrow = !flag;
Vector vector = getSortedIdScope(i, j);
Vector vector1 = getPageData(vector);
if(vector != null && vector.size() != 0)
{
for(int k = 0; k < vector.size(); k++)
{
Object obj = vector.elementAt(k);
allIDList.remove(obj);
}
refresh(!_blThrow);
}
return vector1;
}
public synchronized void refresh(final boolean blRefreshTable)
{
Runnable runnable = new Runnable() {
public void run()
{
try
{
if(blRefreshTable)
_tableModel.refresh();
}
catch(Exception exception) { }
}
};
SwingUtilities.invokeLater(runnable);
}
public Vector getSortedIdScope(int i, int j)
{
Vector vector = new Vector();
if(allIDList == null)
return null;
if(allIDList.size() < j)
return null;
if(vector == null || i < 0 || i > j)
return null;
Object aobj[] = allIDList.keySet().toArray();
for(int k = i; k <= j; k++)
vector.add(allIDList.get(aobj[k]));
return vector;
}
public final Vector getScope(int i, int j)
{
Vector vector = new Vector();
getScope(vector, i, j);
return vector;
}
public void getScope(Vector vector, int i, int j)
{
if(allIDList == null)
return;
if(allIDList.size() < j)
return;
if(vector == null || i < 0 || i > j)
return;
Object aobj[] = allIDList.keySet().toArray();
for(int k = i; k <= j; k++)
{
SortedID sortedid = (SortedID)allIDList.get(aobj[k]);
vector.add(sortedid.getID());
}
}
public final void getScope(Vector vector, int ai[])
{
if(allIDList == null || ai == null || vector == null)
return;
if(allIDList.size() <= 0 || ai.length <= 0)
return;
Object aobj[] = allIDList.keySet().toArray();
int i = aobj.length;
for(int j = 0; j < ai.length; j++)
{
int k = ai[j];
if(k >= 0 && k < i)
{
SortedID sortedid = (SortedID)allIDList.get(aobj[k]);
vector.add(sortedid.getID());
}
}
}
public final void getScopeEx(Vector vector, int ai[])
{
if(allIDList == null || ai == null || vector == null)
return;
if(allIDList.size() <= 0 || ai.length <= 0)
return;
Object aobj[] = allIDList.keySet().toArray();
int i = aobj.length;
for(int j = 0; j < ai.length; j++)
{
int k = ai[j];
if(k >= 0 && k < i)
{
SortedID sortedid = (SortedID)allIDList.get(aobj[k]);
vector.add(sortedid);
}
}
}
public void insertRow(int i, Object obj)
{
if(obj == null)
return;
i = i >= 0 ? i : 0;
Object aobj[] = allIDList.keySet().toArray();
for(int j = i; j < aobj.length; j++)
{
SortedID sortedid = (SortedID)aobj[j];
sortedid.increaseSN();
}
SortedID sortedid1 = new SortedID(obj, i);
allIDList.put(sortedid1, sortedid1);
if(_tableModel != null && _tableModel.isRowDataInCache(i))
_tableModel.refresh();
else
_tableModel.updateSize();
}
public void removeRows(int ai[])
{
if(ai == null || ai.length == 0)
return;
Arrays.sort(ai);
Object aobj[] = allIDList.keySet().toArray();
for(int i = ai.length - 1; i >= 0; i--)
if(aobj.length > ai[i])
{
Object obj = aobj[ai[i]];
allIDList.remove(obj);
}
_iCount = allIDList.size();
}
public int getIndexById(Object obj)
{
if(obj == null || allIDList == null || allIDList.size() <= 0)
return -1;
Object aobj[] = allIDList.keySet().toArray();
int i = aobj.length;
int j = _tableModel.getFrom();
int k = _tableModel.getTo();
int l = 0;
for(l = j; l < k; l++)
{
SortedID sortedid = (SortedID)allIDList.get(aobj[l]);
if(obj.equals(sortedid.getID()))
break;
}
if(l < i)
return l;
else
return -1;
}
public void release()
{
if(allIDList != null)
allIDList.clear();
allIDList = null;
_tableModel = null;
}
public void applyModification(Vector vector)
{
}
public abstract void setDomain(Object obj);
public abstract Vector getPageData(Vector vector);
public abstract Object translate(Object obj, int i, int j);
private TreeMap allIDList;
private int _iCount;
private CacheTableModel _tableModel;
private boolean _blThrow;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -