今天为网友提供的是JAVA源码
源代码在线查看: productbounds.java
package com.power.pipeengine.InputData;
import java.util.*;
import java.io.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;
public class ProductBounds extends InputReader
{
private Hashtable _productBounds = new Hashtable();
private String _fileName = "ProductBounds";
public ProductBounds() {
}
private void addProductBound( int fID,
String prodID,
int bucketID,
String bndType,
double qty,
double cost ) {
String key = createKey( fID, prodID );
ProductBound pb = (ProductBound) _productBounds.get( key );
if( null == pb ) {
pb = new ProductBound( fID, prodID );
_productBounds.put( key, pb );
}
pb.addBound( bucketID, bndType, qty, cost );
}
private String createKey( int fID, String prodID ) {
char[] key = new char[105];
String facility = new Integer( fID ).toString();
int idx = 104;
for( int i=facility.length()-1; i>=0; i-- ) {
key[idx] = facility.charAt(i);
idx--;
}
idx = 99;
for( int i=prodID.length()-1; i>=0; i-- ) {
key[idx] = prodID.charAt(i);
idx--;
}
return new String( key );
}
public Hashtable getProductBounds() {
return _productBounds;
}
protected String getFileName() {
return _fileName;
}
public void readData() throws Exception {
BufferedReader d = super.getReader();
if( null == d ) {
return;
}
String token = GlobalConfig.getInstance().getSeparator();
String aLine = d.readLine();
Facilities facilities = DataModel.getInstance().getFacilities();
while( aLine != null ) {
if( aLine.length() aLine = d.readLine();
continue;
}
StringTokenizer st = new StringTokenizer( aLine, token );
int facilityID = new Integer( st.nextToken() ).intValue();
String productID = st.nextToken();
int effectiveBucket = new Integer( st.nextToken() ).intValue();
String bndType = st.nextToken();
double qty = new Double( st.nextToken() ).doubleValue();
double cost = new Double( st.nextToken() ).doubleValue();
Facility aFacility = facilities.getFacility( facilityID );
if( null == aFacility ) {
reportError( "Facility ID", new Integer( facilityID ).toString(), aLine );
aLine = d.readLine();
continue;
}
Product p = DataModel.getInstance().getProducts().getProduct( facilityID, productID );
if( null == p ) {
reportError( "Product ID", productID, aLine );
aLine = d.readLine();
continue;
}
addProductBound( facilityID,
productID,
effectiveBucket,
bndType,
qty,
cost );
aLine = d.readLine();
}
d.close();
super.closeURLConnection();
}
public void print() {
System.out.println( "\n\n\nProductBound ---------------------" );
Enumeration allBnds = _productBounds.elements();
while( allBnds.hasMoreElements() ) {
ProductBound prodBnd = (ProductBound) allBnds.nextElement();
prodBnd.print();
}
}
}