Announcement

Collapse
No announcement yet.

Delphi2java

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delphi2java

    Hi,

    Ich bin ein Delphi Programmierer und brauche dringend den JAVA CODE..Kann mir jemand etwas in Java umprogrammieren???

    FOLGENDES:

    interface

    uses
    SysUtils, Classes,m11,dialogs,math,U_BigInts;

    type
    TIban = class(TComponent)
    private
    { Private declarations }
    fclearingnumber :string;
    fclearingaccountprefix :string;
    fiban :string;
    fm11 :ModElevenTest;
    fresulttext :string;
    fbankcode :string;
    ftestresult :boolean;
    protected
    { Protected declarations }
    public
    { Public declarations }
    published

    property clearingaccountprefix :string read fclearingaccountprefix write fclearingaccountprefix;
    property clearingnumber :string read fclearingnumber write fclearingnumber;
    property bankcode :string read fbankcode write fbankcode;
    property iban :string read fiban write fiban;
    property m11 :ModElevenTest read fm11 write fm11;
    property resulttext :string read fresulttext write fresulttext;
    property testresult :boolean read ftestresult write ftestresult;
    procedure generateIban ;
    procedure validateIban;
    function convertcountrychar(input:string):string;

    { Published declarations }
    end;

    procedure Register;

    implementation

    function tiban.convertcountrychar(input:string):string;
    var i:integer;
    begin
    if length(input)<>1 then
    begin
    result:='00';
    end;

    i:=ord(char(input[1]));
    i:=i-55;
    result:=inttostr(i);
    end;

    procedure tiban.validateIban;
    var s:string;
    f:string;
    bigint:TInteger;
    begin
    f:=fiban;
    if length(fiban)<>24 then
    begin
    fresulttext:='iban account is not 24 bytes in length';
    ftestresult:=false;
    exit;
    end;

    s:=copy(fiban,5,20)+convertcountrychar(copy(fiban, 1,1))+convertcountrychar(copy(fiban,2,1))+copy(fib an,3,2);

    bigint:=TInteger.create;
    bigint.Assign(s);
    bigint.modulo(97);
    s:=bigint.ConvertToDecimalString(false);

    if strtoint(s)=1 then
    begin
    fresulttext :='CZECH IBAN TEST OK!';
    ftestresult :=true;
    end
    else
    begin
    fresulttext :='CZECH IBAN TEST BAD!';
    ftestresult :=false;
    end;

    end;

    procedure tiban.generateIban;
    var
    bigint:TInteger;
    s:string;
    i:integer;
    m11failure:boolean;
    begin
    if not assigned(fm11) then
    begin
    fresulttext:='No modulo 11 checking assigned';
    exit;
    end;

    m11failure:=false;
    //-------------------------
    // fclearingaccountprefix
    //-------------------------

    if length(fclearingaccountprefix)>0 then
    begin
    fm11.Accountnumber:=fclearingaccountprefix;
    if fm11.TestResult =false then
    begin
    fresulttext :='M11 failure in given account prefix';
    ftestresult :=false;
    fiban:='';
    exit;
    end;
    end;

    if 6-length(fclearingaccountprefix)<6 then
    begin
    for i:=1 to 6-length(fclearingaccountprefix) do
    begin
    fclearingaccountprefix:='0'+fclearingaccountprefix ;
    end;
    end;

    //-------------------------
    // fclearingnumber
    //-------------------------
    fm11.Accountnumber:=fclearingnumber;
    if fm11.TestResult =false then
    begin
    fresulttext :='M11 failure in given account prefix';
    ftestresult :=false;
    fiban:='';
    exit;
    end;

    for i:=1 to 10-length(clearingnumber) do
    begin
    clearingnumber:='0'+clearingnumber;
    end;

    s:=fbankcode+fclearingaccountprefix+fclearingnumbe r+'123500';

    bigint:=TInteger.create;
    bigint.Assign(s);
    bigint.modulo(97);
    s:=bigint.ConvertToDecimalString(false);

    i:=strtoint(s);
    i:=98-i;
    if i<10 then s:='0'+inttostr(i) else s:=inttostr(i);

    fiban:='CZ'+s+fbankcode+fclearingaccountprefix+fcl earingnumber;

    bigint.Free;
    validateIban;

    end;

    procedure Register;
    begin
    RegisterComponents('Bobo', [TIban]);
    end;

    end.

    -----------------------------------------------------------------------------

    interface

    uses
    SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
    Forms, Dialogs;

    type
    ModElevenTest = class(TWinControl)
    private
    FOnChange: TNotifyEvent;
    FAccountnumber: String; { implementation details are private }
    FTestResult :Boolean;
    fmodulo :integer;

    Procedure SetAccount(Account:String);
    Function infobox:string;
    published
    property Accountnumber: String read FAccountnumber write SetAccount; { writable! }
    property TestResult: boolean read FTestResult write ftestresult default false; { Readable! }
    property modulo :integer read fmodulo;
    property OnChange: TNotifyEvent read FOnChange write FOnChange;
    property About: String Read infobox ;
    protected
    { Protected declarations }
    public
    { Public declarations }

    end;

    procedure Register;

    implementation

    Function ModElevenTest.infobox:String;
    begin
    infobox:='IBAN TEST. Version 0.51';
    end;

    procedure ModElevenTest.SetAccount(Account:String);
    const
    checkrow:array [1..10] of integer=(6,3,7,9,10,5,8,4,2,1);
    var
    accountstring :string[50];

    i,
    sumofresults,
    temp,
    code :integer;

    begin

    FAccountnumber:=Account;
    fmodulo:=0;

    FTestResult:=False;

    if (length(account)>10) or (length(account)<1) then
    begin
    if Assigned(FOnChange) then FOnChange(Self);
    exit;
    end;

    accountstring:=account;

    for i:=1 to 10-length(accountstring) do
    begin
    insert('0',accountstring,1);
    end;

    sumofresults:=0;

    for i:=1 to 10 do
    begin
    val(accountstring[i],temp,code);
    if code<>0 then
    begin
    if Assigned(FOnChange) then FOnChange(Self);
    exit;
    end;

    inc(sumofresults,checkrow[i]*temp);
    end;

    if sumofresults div 11=sumofresults / 11 then
    begin
    FTestResult:=true;
    fmodulo:= 0;
    end
    else
    begin
    fmodulo:= sumofresults mod 11;
    end;
    if Assigned(FOnChange) then FOnChange(Self);
    end;

    procedure Register;
    begin
    RegisterComponents('TSF', [ModElevenTest]);
    end;

    end.

    THX an ALLE die mir helfen konnten
Working...
X