今天为网友提供的是JAVA源码
源代码在线查看: intershipment.java
package com.power.pipeengine.InputData;
import java.util.*;
import java.io.*;
import com.power.pipeengine.Entity.*;
import com.power.pipe.*;
import com.power.util.Message.*;
public class InterShipment extends InputReader
{
private Hashtable _shipments = null;
private String _fileName = "InterShipment";
private int _shipmentCodeLength = 2;
public InterShipment() {
_shipments = new Hashtable();
}
protected String getFileName() {
return _fileName;
}
public void addShipment( Shipment s, int seqNum ) {
_shipments.put( new Integer(seqNum), s );
}
public Hashtable getShipments() {
return _shipments;
}
private String createKey( Shipment s ) {
char[] key = new char[35];
String from = new Integer( s.getFromFacilityID() ).toString();
String to = new Integer( s.getToFacilityID() ).toString();
int idx = 34;
for( int i=to.length()-1; i>=0; i-- ) {
key[idx] = to.charAt(i);
idx--;
}
idx = 29;
for( int i=from.length()-1; i>=0; i-- ) {
key[idx] = from.charAt(i);
idx--;
}
idx = 24;
String fromProdID = s.getFromProductID();
for( int i=fromProdID.length()-1; i>=0; i-- ) {
key[idx] = fromProdID.charAt(i);
idx--;
}
return new String( key );
}
public void readData() throws Exception {
String token = GlobalConfig.getInstance().getSeparator();
BufferedReader d = super.getReader();
if( null == d ) {
return;
}
String aLine = d.readLine();
int cnt = 0;
Facilities facilities = DataModel.getInstance().getFacilities();
while( aLine != null ) {
if( aLine.length() aLine = d.readLine();
continue;
}
StringTokenizer st = new StringTokenizer( aLine, token );
int fromID = new Integer( st.nextToken() ).intValue();
int toID = new Integer( st.nextToken() ).intValue();
double time = new Double( st.nextToken() ).doubleValue();
String fromProdID = st.nextToken();
String toProdID = st.nextToken();
Facility from = facilities.getFacility( fromID );
if( null == from ) {
reportError( "Facility ID", new Integer( fromID ).toString(), aLine );
aLine = d.readLine();
continue;
}
Facility to = facilities.getFacility( toID );
if( null == to ) {
reportError( "Facility ID", new Integer( toID ).toString(), aLine );
aLine = d.readLine();
continue;
}
Shipment s = new Shipment( fromID, toID, time, fromProdID, toProdID );
from.addDestinationFacility( to, s );
to.addOriginatingFacility( from, s );
addShipment( s, cnt );
aLine = d.readLine();
cnt++;
}
d.close();
super.closeURLConnection();
}
public void print() {
System.out.println( "\n\n\nInterShipment ---------------------" );
Enumeration allShipments = _shipments.elements();
while( allShipments.hasMoreElements() ) {
Shipment s = (Shipment) allShipments.nextElement();
s.print();
}
}
}