Java世界

          學習筆記

          常用鏈接

          統計

          積分與排名

          天籟村

          新華網

          雅虎

          最新評論

          海運項目:Exporter類

          package com.sinojava.haiyun;
          import java.io.*;
          import java.util.*;
          import java.util.regex.*;
          import java.util.Properties;
          //給服務器端使用的類
          public class Exporter extends AbstractBL implements Serializable {
          ?? ?//海運中的變量參數
          ?? ?private String shipname;
          ?? ?private String voyage;
          ?? ?private String blno;
          ?? ?private String destination;
          ?? ?private String cnttype;
          ?? ?private int cntsize;
          ?? ?private int cntqnt;
          ?? ?private String cntoperator;
          ?? ?private String remark = "無";
          ?? ?//集合來存放解析出來的對象
          ?? ?ArrayList list = new ArrayList();
          ?? ?//創建Operator的對象op
          ?? ?Operator op = new Operator();
          ?? ?
          ?? ?//獲取與設置
          ?? ?public String getBlno() {
          ?? ??? ?return blno;
          ?? ?}
          ?? ?public void setBlno(String blno) {
          ?? ??? ?this.blno = blno;
          ?? ?}
          ?? ?public String getCntoperator() {
          ?? ??? ?return cntoperator;
          ?? ?}
          ?? ?public void setCntoperator(String cntoperator) {
          ?? ??? ?this.cntoperator = cntoperator;
          ?? ?}
          ?? ?public int getCntqnt() {
          ?? ??? ?return cntqnt;
          ?? ?}
          ?? ?public void setCntqnt(int cntqnt) {
          ?? ??? ?this.cntqnt = cntqnt;
          ?? ?}
          ?? ?public int getCntsize() {
          ?? ??? ?return cntsize;
          ?? ?}
          ?? ?public void setCntsize(int cntsize) {
          ?? ??? ?this.cntsize = cntsize;
          ?? ?}
          ?? ?public String getCnttype() {
          ?? ??? ?return cnttype;
          ?? ?}
          ?? ?public void setCnttype(String cnttype) {
          ?? ??? ?this.cnttype = cnttype;
          ?? ?}
          ?? ?public String getDestination() {
          ?? ??? ?return destination;
          ?? ?}
          ?? ?public void setDestination(String destination) {
          ?? ??? ?this.destination = destination;
          ?? ?}
          ?? ?public String getRemark() {
          ?? ??? ?return remark;
          ?? ?}
          ?? ?public void setRemark(String remark) {
          ?? ??? ?this.remark = remark;
          ?? ?}
          ?? ?public String getShipname() {
          ?? ??? ?return shipname;
          ?? ?}
          ?? ?public void setShipname(String shipname) {
          ?? ??? ?this.shipname = shipname;
          ?? ?}
          ?? ?public String getVoyage() {
          ?? ??? ?return voyage;
          ?? ?}
          ?? ?public void setVoyage(String voyage) {
          ?? ??? ?this.voyage = voyage;
          ?? ?}
          ?? ?
          ?? ?//字符串的解析
          ?? ?public void splitText(String str) {
          ?? ??? ?//解析出一行,換行處代替成空格
          ?? ??? ?String s1[] = str.replace("\n"," ").split("\\#");?? ?
          ?? ??? ?//解析然后放入集合中
          ?? ??? ?for(int i=0;i<s1.length-1;i++) {
          ?? ??? ??? ?//定義一個Exporter的局部對象
          ?? ??? ??? ?Exporter exe2 = new Exporter();
          ?? ??? ??? ?//解析單個字符
          ?? ??? ??? ?String s2[] = s1[i].trim().split(":");
          ??????????? //判斷字符開頭一字母開頭
          ?? ??? ??? ?boolean b = Pattern.matches("[A-Z]*+",s2[0]);
          ?? ??? ??? ?//true時進行單頭操作,false時進行箱子的操作
          ?? ??? ??? ?try {
          ?? ??? ??? ??? ?if(b) {?? ?
          ?? ??? ??? ??? ??? ?exe2.setShipname(s2[0]);
          ?? ??? ??? ??? ??? ?exe2.setVoyage(s2[1]);
          ?? ??? ??? ??? ??? ?exe2.setBlno(s2[2]);
          ?? ??? ??? ??? ??? ?exe2.setDestination(s2[3]);
          ?? ??? ??? ??? ??? ?list.add(exe2);
          ?? ??? ??? ??? ?}
          ?? ??? ??? ??? ?else {
          ?? ??? ??? ??? ??? ?//返回指定位置上的元素
          ?? ??? ??? ??? ??? ?exe2 = (Exporter)list.get(list.size()-1);
          ?? ??? ??? ??? ??? ?//判斷是否單頭處理完
          ?? ??? ??? ??? ??? ?if(exe2.getCntsize()!=0)
          ?? ??? ??? ??? ??? ?{
          ?? ??? ??? ??? ??? ??? ?Exporter old = exe2;
          ?? ??? ??? ??? ??? ??? ?exe2 = new Exporter();
          ?? ??? ??? ??? ??? ??? ?exe2.setShipname(old.getShipname());
          ?? ??? ??? ??? ??? ??? ?exe2.setVoyage(old.getVoyage());
          ?? ??? ??? ??? ??? ??? ?exe2.setBlno(old.getBlno());
          ?? ??? ??? ??? ??? ??? ?exe2.setDestination(old.getDestination());
          ?? ??? ??? ??? ??? ??? ?list.add(exe2);
          ?? ??? ??? ??? ??? ?}
          ?? ??? ??? ??? ??? ?//放入箱子的內容
          ?? ??? ??? ??? ??? ?exe2.setCntsize(Integer.parseInt(s2[0]));
          ?? ??? ??? ??? ??? ?exe2.setCnttype(s2[1]);
          ?? ??? ??? ??? ??? ?exe2.setCntqnt(Integer.parseInt(s2[2]));
          ?? ??? ??? ??? ??? ?exe2.setCntoperator(s2[3]);
          ?? ??? ??? ??? ?}
          ?? ??? ??? ?}catch(Exception e) {
          ?? ??? ??? ??? ?e.printStackTrace();
          ?? ??? ??? ?}
          ?? ??? ?}
          ?? ??? ?
          ?? ?}
          ?? ?
          ?? ?//取單號
          ?? ?public String getIsequence() {
          ?? ??? ?String strBlno = this.getBlno().substring(this.getBlno().indexOf(" "),this.getBlno().length()).trim();
          ?? ??? ?return strBlno;
          ?? ?}
          ?? ?//取單頭
          ?? ?public String getIBlHead() {
          ?? ??? ?String strHead = this.getBlno().substring(0,this.getBlno().indexOf(" ")).trim();
          ?? ??? ?return strHead;
          ?? ?}
          ?? ?
          ?? ?public String toString() {
          ?? ??? ?return "船名:"+"\t"+shipname+
          ?? ??? ?"\n航次:"+"\t"+voyage+
          ?? ??? ?"\n提單號:"+"\t"+blno+
          ?? ??? ?"\n目的港:"+"\t"+destination+
          ?? ??? ?"\n集裝箱尺寸:"+"\t"+cntsize+
          ?? ??? ?"\n箱型:"+"\t"+cnttype+
          ?? ??? ?"\n箱量:"+"\t"+cntqnt+
          ?? ??? ?"\n經紀人:"+"\t"+getAllName()+
          ?? ??? ?"\n備注:"+"\t"+getRRmark()+"\n\n";?? ?
          ?? ?}
          ?? ?//實現輔助功能
          ?? ?public String getRRmark() {?? ??? ?
          ?? ??? ?if(getIBlHead().equals("HUB")) {
          ?? ??? ??? ?setRemark("SOC");
          ?? ??? ?} else if(getIBlHead().equals("SNL")) {
          ?? ??? ??? ?setRemark("SOC");
          ?? ??? ?}
          ?? ??? ?return getRemark();
          ?? ?}
          ?? ?//如果經紀人符合則改變其名字
          ?? ?public String getAllName(){
          ?? ??? ?if (getCntoperator().equals("HUB"))
          ?? ??? ??? ?setCntoperator(op.getNameOne());
          ?? ??? ?if (getCntoperator().equals("SNL"))
          ?? ??? ??? ?setCntoperator(op.getNameTwo());
          ?? ??? ?if (getCntoperator().equals("JL"))
          ?? ??? ??? ?setCntoperator(op.getNameThree());
          ?? ??? ?return getCntoperator();
          ?? ?}
          ?? ?

          }

          posted on 2007-11-16 14:03 Rabbit 閱讀(630) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 若羌县| 买车| 绥化市| 阜康市| 郧西县| 永济市| 万州区| 朔州市| 泸溪县| 阜康市| 若羌县| 洪洞县| 奉贤区| 石阡县| 惠东县| 东阳市| 南阳市| 高青县| 岢岚县| 临洮县| 清远市| 玉山县| 长治市| 仁寿县| 济南市| 同德县| 合川市| 井陉县| 沐川县| 关岭| 宜昌市| 伊金霍洛旗| 赤城县| 庆云县| 黔西| 土默特左旗| 县级市| 清水县| 新竹县| 连云港市| 江门市|