You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.6 KiB

1 year ago
package com.zky.pub;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Vector;
/**
*
* @author dy
*
*/
public class HashFmlBuf implements Serializable {
private Hashtable hm = new Hashtable();
private String Key = "";
private String Value = "";
private int RowCount = -1;
private int ResultRowCount = -1;//最终结果行数,自己手工设置
public Vector keys(int row) {
Enumeration tmp;
String tk = "";
Vector res = new Vector();
if (row > RowCount || row <= 0)
return null;
tmp = hm.keys();
while (tmp.hasMoreElements()) {
tk = (String) tmp.nextElement();
int p = tk.indexOf("_" + String.valueOf(row));
if (p != -1) {
res.add(tk.substring(0, p));
}
}
return res;
}
private void fdel(String field, int pos) {
Key = new StringBuffer(field.trim()).append("_").append(
Integer.toString(pos)).toString();
hm.remove(Key);
}
/**
* tuxedo FML Fchg
*
* @param field
* @param pos
* @param value
*/
public void fchg(String field, int pos, String value) {
Key = new StringBuffer((field.toUpperCase()).trim()).append("_")
.append(Integer.toString(pos)).toString();
hm.put(Key, Common.convertNull(value));
if (pos >= RowCount) {
RowCount = pos + 1;
}
}
/**
* tuxedo FML Fget
*
* @param field
* @param pos
* @return String
* @throws FieldNotFoundException
*/
public String fget(String field, int pos) /* throws FieldNotFoundException */{
Key = new StringBuffer((field.toUpperCase()).trim()).append("_")
.append(Integer.toString(pos)).toString();
Value = (String) hm.get(Key);
return Value;
}
/**
* tuxedo FML Finit
*
*/
public void finit() {
hm.clear();
}
/**
*
*
* @param field
* @param value
* @return -1
*/
public int find(String field, String value) {
int i;
field = field.toUpperCase();
for (i = 0; i < RowCount; i++) {
Key = new StringBuffer(field.trim()).append("_").append(
Integer.toString(i)).toString();
Value = (String) hm.get(Key);
if (Value == null) {
continue;
}
if (Value.equals(value)) {
return i;
}
}
return -1;
}
public int find(String field) {
int i;
int ret = 0;
for (i = 0; i < RowCount; i++) {
Key = new StringBuffer(field.trim()).append("_").append(
Integer.toString(i)).toString();
Value = (String) hm.get(Key);
if (Value == null) {
ret = 0;
continue;
}
ret = 1;
}
return ret;
}
public void setRowCount(int rc) {
this.RowCount = rc;
}
public int getRowCount() {
return RowCount;
}
public void setResultRowCount(int rc) {
this.ResultRowCount = rc;
}
public int getResultRowCount() {
return ResultRowCount;
}
public void add(String train_address, Object query) {
}
}