|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.bo;
/*
*
de:
* Package mit den Klassen für die Serialization
eine Objekts dieser Klasse.
* Serialization ist notwendig um
die Werte des Objektes zwischen einem Java
* Application
Server (JAS) und einem Heavyweight-Client übertragen zu
können.
* en:
* Package with the
classes to serialize an object of this class.
*
Serialization is neccessary to exchange the values of the object
between a
* Java Application Server (JAS) and a
Heavyweight-Client. */import
java.io.Serializable;
/**
*
* @author kurt[at]javascout(dot)biz
* @date
2010-11-02
*
* @description
* de: Klasse
mit einer Liste von Business Object (BO) für die 'Currency'
(Währung). *
en: Class with a list of Business Object (BO) for the 'Currency'.
*
* @change-log
*
when who why
*
--------------------------------------------------------
*
*/public
class
JSBS_Currency_BO_Set
extends
JSBS_BO_Set
implements
Serializable
{
/*
* --------------------
*
de: METHODE zum Kopieren der Werte eines anderen Objekts in dieses
Objekt. *
en: METHOD to copy the values from another object into this object.
*/
public
void
copyFromJSBS_Currency_BO_Set
(JSBS_Currency_BO_Set parmJSBS_Currency_BO_Set) {
/*
*
de:
* Größe des Vectors mit den BO (der in der
geerbten Basisklasse definiert ist) feststellen
* und Index
zum Durchsuchen definieren.
* en: * Determine
the size of the vector containing the BO (defined in the inherited
base-class)
* and define the index to search the
vector. */
int
locintVectorSize =
parmJSBS_Currency_BO_Set.
vecRecordSet
.size();
int
locintVectorIndex;
/*
*
de: Den Vector mit der Liste der BO, der in dieser Klasse definiert
ist, leeren.
* en: Empty the vector with the list of BO
defined within this class.
*/
this
.
vecRecordSet
.removeAllElements();
/*
*
de: Mit einer for-Schleife alle BO des als Parameter übergebenen
Objekts verarbeiten.
* en: Use a for-loop to process
all BO within the object passed as parameter. */
for
(locintVectorIndex = 0; locintVectorIndex < locintVectorSize;
locintVectorIndex++) {
/*
*
de:
* Das durch den Index gewählte BO in eine eigene
Variable übertragen.
* Damit kann es leichter
verarbeitet werden.
* en: * Move
the BO selected by the index to an own variable.
* This
allows an easier processing. */
JSBS_Currency_BO
locstructBO =
(JSBS_Currency_BO)
parmJSBS_Currency_BO_Set.vecRecordSet
.elementAt(locintVectorIndex);
/*
*
de:
* Neues BO 'konstruieren' und die Methode der BO-Klasse
zum Kopieren der Variablen-Werte
* aufrufen.
*
en: * 'Construct'
a new BO and call the method of the BO-class to copy the values of
the variables. */
JSBS_Currency_BO
locstructBO_New = new
JSBS_Currency_BO();
locstructBO_New.copyFromJSBS_Currency_BO(locstructBO);/*
*
de:
* Neues BO in den Vector für das Set einfügen.
*
en: * Insert
new BO into the vector for the set
*/
this
.
vecRecordSet
.addElement(locstructBO_New);
}/*
*
de:
* Status-Code und erklärenden Text in dieses Objekt
übernehmen.
* en: * Transfer
the status-code and the explanatory text into this object.
*/
this
.
StatusCode
= parmJSBS_Currency_BO_Set.
StatusCode
;
this
.
StatusMsg
=
parmJSBS_Currency_BO_Set.
StatusMsg
;
}
/*
* --------------------
*
de:
* METHODE zum Vergleichen der Werte der in der Liste
enthaltenen Business Objects.
* Voraussetzung ist, dass die
Sortier-Reihenfolge innerhalb der beiden Listen gleich ist.
*
Die Methode liefert 'true' zurück wenn mindestens die Werte
einer Variablen in
* einem BO der Liste verschieden sind.
*
en: *
METHOD to compare the values of the Business Objects within the
list.
* Prerequisite is, that the sort-order is the same in
both lists.
* The method returns 'true' if at least the
values of one variables are different
* within on BO of the
list. */
public
boolean
isDifferent(JSBS_Currency_BO_Set
parmJSBS_Currency_BO_Set) {
/*
*
de:
* Wenn der Wert des Parameters 'null' ist dann 'true'
(verschieden) zurück liefern.
* en: *
If the value of the parameter is 'null' then return 'true'
(different). */
if
(parmJSBS_Currency_BO_Set
==
null
)
return
true
;
/*
*
de: Ermitteln der Anzahl der BO in den Vectoren beider
BO-Set-Objekte.
* en: Determine the number of BO within the
vectors of both BO-set-objects. */
int
intThisVectorSize
=
this
.
vecRecordSet
.size();
int
intParmVectorSize
= parmJSBS_Currency_BO_Set.
vecRecordSet
.size();
/*
*
de: Wenn die Anzahl der BO in den Vectoren verschieden ist dann sind
die Sets verschieden.
* en: If the numbers of BO of both
vectors are different then the sets are different. */
if
(intThisVectorSize
!= intParmVectorSize)
return
true
;
/*
*
de: Variablen für die beiden zu vergleichenden BO definieren.
*
en: Define variables for the BO to be compared.
*/
JSBS_Currency_BO
structThisJSBS_Currency_BO;
JSBS_Currency_BO
structParmJSBS_Currency_BO;/*
*
de:
* Mit einer for-Schleife jedes einzelne BO
'herausholen' und die Methode des BO zum
* Vergleichen
aufrufen.
* en:
* Use a for-loop to
access each singular BO and use the method defined with the BO
* for
comparison. */
for
(
int
intVectorIndex
= 0; intVectorIndex < intThisVectorSize; intVectorIndex++) {
/*
*
de:
* 'Herausholen' der beiden BO aus dem Vector und
übertragen auf die dafür vorgesehenen
*
Variablen. Das erlaubt ein einfacheres Verarbeiten.
*
en: * 'Get'
both BO out of the vector and tranfer them to the assigned
variables.
* This allows an easier processing.
*/
structThisJSBS_Currency_BO
=
(JSBS_Currency_BO)
this
.
vecRecordSet
.elementAt(intVectorIndex);
structParmJSBS_Currency_BO
=
(JSBS_Currency_BO)
parmJSBS_Currency_BO_Set.vecRecordSet
.elementAt(intVectorIndex);
/*
*
de:
* Prüfung ob eines oder beide BO 'null' sind; dann
ist ein besonderer Vergleich notwendig.
* en:
*
Verification if one or both BO are 'null'; this needs a special
comparison.
*/
if
(structThisJSBS_Currency_BO
==
null
)
{
/*
*
de:
* Vergleich über die Methode der Klasse ist nicht
möglich (weil Objekt 'null' ist);
*
aber beide BO sind 'verschieden' wenn das zu vergleichende BO
nicht 'null' ist.
* en:
* Comparison using the
method of the class is not possible (as the object is 'null');
*
but both BO are 'different' if the BO to be compared is not
'null'.*/
if
(structParmJSBS_Currency_BO !=
null
)
return
true
;
}
else
{
/*
*
de:
* Methode des BO aufrufen; darin wird auch behandelt
wenn das als Parameter übergebene BO
* 'null' ist. Wenn
die BO verschieden sind dann diese Methode beenden.
* en:
*
Call the method of the BO; the algorithm within that method handles
if the BO passed as
* parameter is 'null'. End this method
if the BO are different. */
if
(structThisJSBS_Currency_BO.isDifferent(structParmJSBS_Currency_BO))
return
true
;
}
}/*
de: Keine Unterschiede gefunden; beide Sets sind identisch.
*
en: No difference found; both sets are identical. */
return
false
;
}
/*
* --------------------
*
de:
* METHODE zum Sortieren der BO innerhalb der Liste.
*
Verwendeter Algorithmus ist ein doppelter Bubble-Sort.
*
en:
*
METHOD to sort the BO within the list.
* Used algorithmen is
a double bubble-sort. */
public
void
sortByLeadingCurrency_ISOCurrencyCode_LanguageCodeForLabelling()
{
/*
*
de:
* Variablen für die beiden zu vergleichenden (und
eventuell zu tauschenden) BOs aus der Liste.
* en:
*
Variables for the BOs from the lists to be compared (and exchanged if
needed). */
JSBS_Currency_BO
struct1JSBS_Currency_BO;
JSBS_Currency_BO
struct2JSBS_Currency_BO;
/*
*
de: Variable für den Index zum Adressieren der BO innerhalb der
Liste.
* en: Variable for the index to address the BO within
the list. */
int
intIndex;
/*
*
de:
* Variable für die 'Grenzen', ausserhalb derer die
'kleinsten' und 'größten'
* BO der Liste schon
sortiert sind.
* Ein Vorteil des Bubble-Sort ist, dass mit
dem ersten Durchgang das 'größte' bzw.
*
'kleinste' BO sicher an die richtige Stelle wandern und nach n
Durchläufen mindestens
* die n 'größten'
bzw. 'kleinsten' BO an der richtigen Stelle sind.
* Dadurch
muss mit jedem weiteren Durchlauf nur mehr eine geringere Anzahl der
BO
* verglichen (und eventuell getauscht) werden.
*
Die beiden Variablen verbessern den Algorithmus, weil sie nach einem
Durchlauf
* erkennen lassen, bis zu welchen Index-Werten
die BOs noch verglichen werden müssen.
* en:
*
Variables for the 'borders' outside of them the 'smallest' and
'largest' BO of the BO
* are already sorted.
* An
advantage of the bubble-sort ist, that the 'largest' or 'smallest' BO
are at
* the right place after the first pass and that after
n passes at least the n 'largest'
* or 'smallest' BO are at
the right place.
* The advantage is, that at each additional
pass a lower number of BO has to be compared -
* and changed
if needed.
* Those two variables enhace the algorithm as
they signal, within which index-values
* the BOs have to be
compared in a pass. */
int
intLowestSortedIndicator
= 0;
int
intHighestSortedIndicator
=
vecRecordSet
.size()
- 1;
/*
*
de: Weitere Variablen mit denen die for-Schleifen gesteuert
werden.
* en: Further variables to control the for-loops.
*/
int
intLowerAlreadySortedIndex
= intLowestSortedIndicator;
int
intUpperAlreadySortedIndex
= intHighestSortedIndicator;
/*
*
de:
* Für den Vergleich von Text wird ein Collator
verwendet;
* dieser sorgt für die passende Reihenfolge
von Umlauten.
* en:
* To compare text, a collator
ist used.
* this takes care for the right order of mutated
wovels (umlauts). */
java.text.Collator
locCollator =
java.text.Collator.getInstance();
locCollator.setStrength(java.text.Collator.TERTIARY
);
/*
*
de:
* In der while-Schleife das Vergleichen der BO so
lange ausführen bis in den
* innenliegenden
for-Schleifen kein Tausch mehr erfolgt ist.
* Eine
noch nicht abgeschlossene Untersuchung wird daran erkannt, dass die
Variablen
* mit den Indizes, wie weit die Liste schon
sortiert ist, noch einen zu untersuchenden
* Bereich
anzeigen.
* en:
* Execute the
comparision of the BO within a while-loop until there was no change
* of BO within the list within the inner
for-loops.
* An incomplete comparision can be
recognized if the variables with the indizes showing
* the
borders of the unsorted area of the list are not equal.
*/
while
(intLowestSortedIndicator
< intHighestSortedIndicator) {
/*
*
de:
* Zuerst wird die Liste mit den BO von 'unten'
(niederster Index) nach 'oben' verarbeitet.
* Dabei
wandern die 'größeren' BO nach oben.
*
en:
* First, the list with the BO is processed
from 'bottom' (lowest Index) to 'top'.
* This causes
the 'larger' BO to move toward the top. *//*
*
de:
* Der Durchlauf in der for-Schleife endet bei
jenem Index, ab dem beim Sortieren von
* 'unten' nach
'oben' kein Tausch der BO mehr erfolgt ist – d.h. alle BO
darüber sind
* schon in der richtigen
Reihenfolge.
* en:
* The pass in the
for-loop end at that index, where during the sort from 'bottom' to
* 'top', no exchange of BOs happened anymore –
i.e. All BO above that index are
* already in the
correct order. */
intUpperAlreadySortedIndex
= intHighestSortedIndicator;
/*
*
de:
* Indikator, bei welchem Index der letzte Tausch
von BO erfolgt ist, auf den Wert
* des untersten
Indikators setzen. Damit wird die while-Schleife beendet wenn
in
* der folgenden for-Schleife kein Tausch mehr
erfolgt.
* en:
* Transfer the value of
the lowest indicator to the indicator of the index, where
* the
last exchange of BO was done. This causes the while-loop to end if in
the
* following for-loop no more exchange of BO is
done. */
intHighestSortedIndicator
= intLowestSortedIndicator;
/*
*
de:
* Der Durchlauf in der for-Schleife wird bei jenem
Index begonnen, ab dem beim Sortieren
* von 'oben' nach
'unten' kein Tausch der BO mehr erfolgt ist – d.h. alle BO
darunter
* sind schon in der richtigen Reihenfolge –
und geht bis zu jenem Index, bei dem beim
* Durchlauf
von 'unten' nach 'oben' kein Tausch mehr erfolgt ist.
*
en:
* The pass within the for-loop starts at that
index where, during sorting from 'top' to
* 'bottom',
no more exchange of BO happened – i.e. all BO below are already
in the
* right sort-order – and continues to
that index where, during sorting from 'bottom'
* to
'top', no more exchange of BO happened. */
for
(intIndex
= intLowestSortedIndicator + 1;
intIndex
<= intUpperAlreadySortedIndex;
intIndex++)
{
/*
*
de:
* 'Herausholen' der beiden zu vergleichenden BO aus dem
Vector und auf die zugeordneten
* Variabeln übertragen.
Damit wird die weitere Verarbeitung einfacher.
* en:
*
'Get' both BO to be compared out of the vector and tranfer them to
the assigned variables.
* This allows an easier
processing. */
struct1JSBS_Currency_BO
=
(JSBS_Currency_BO)
vecRecordSet
.elementAt(intIndex
- 1);
struct2JSBS_Currency_BO
=
(JSBS_Currency_BO)
vecRecordSet
.elementAt(intIndex);
/*
*
de:
* Vergleich der BO: zuerst die Werte für den
LeadCurrencyIndicator;
* innerhalb diesem die Werte für
den ISOCurrencyCode; innerhalb dessen die Werte für
*
LanguageCodeForLabelling.
* en:
* Comparison of the
BO: primarily the values for the LeadCurrencyIndicator;
*
within that the values for the ISOCurrencyCode; within that the
values
* for LanguageCodeForLabelling.
*/
if
(
(locCollator.compare(struct1JSBS_Currency_BO.
LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.
LeadCurrencyIndicator
.trim())
> 0)
|
(
(locCollator.compare(struct1JSBS_Currency_BO.
LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.LeadCurrencyIndicator
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.
ISOCurrencyCode
.trim(),
struct2JSBS_Currency_BO.ISOCurrencyCode
.trim())
> 0))
|
(
(locCollator.compare(struct1JSBS_Currency_BO.
LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.LeadCurrencyIndicator
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.
ISOCurrencyCode
.trim(),
struct2JSBS_Currency_BO.ISOCurrencyCode
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.
LanguageCodeForLabelling
.trim(),
struct2JSBS_Currency_BO.LanguageCodeForLabelling
.trim())
> 0))
)
{
/*
*
de: BO sind in 'falscher' Reihenfolge und müssen vertauscht
werden.
* en: BO are in 'wrong' order and have to be
exchanged.
*/
vecRecordSet
.setElementAt(struct2JSBS_Currency_BO
, intIndex -
1);
vecRecordSet
.setElementAt(struct1JSBS_Currency_BO
, intIndex);
/*
*
de: Indikator,
wie weit die Liste bereits sortiert ist, anpassen.
* en:
Adapt the indicator how far the list is already sorted.
*/
intHighestSortedIndicator
= intIndex;
}
}/*
*
de:
* Jetzt wird die Liste mit den BO von 'oben'
(höchster Index) nach 'unten' verarbeitet.
* Dabei
wandern die 'kleineren' BO nach unten.
* en:
* First,
the list with the BO is processed from 'top' (highest Index) to
'bottom'.
* This causes the 'smaller' BO to move toward
the bottom. *//*
*
de:
* Der Durchlauf in der for-Schleife endet bei
jenem Index, ab dem beim Sortieren von
* 'oben' nach
'unten' kein Tausch der BO mehr erfolgt ist – d.h. alle BO
darunter sind
* schon in der richtigen Reihenfolge.
*
en:
* The pass in the for-loop end at that index,
where during the sort from 'top' to
* 'bottom', no
exchange of BOs happened anymore – i.e. all BO below that index
are
* already in the correct order.
*/
intLowerAlreadySortedIndex
= intLowestSortedIndicator;
/*
*
de:
* Indikator, bei welchem Index der letzte Tausch
von BO erfolgt ist, auf den Wert
* des obersten
Indikators setzen. Damit wird die while-Schleife beendet wenn
in
* der folgenden for-Schleife kein Tausch mehr
erfolgt.
* en:
* Transfer the value of
the highes indicator to the indicator of the index, where
* the
last exchange of BO was done. This causes the while-loop to end if in
the
* following for-loop no more exchange of BO is
done. */
intLowestSortedIndicator
= intHighestSortedIndicator;
/*
*
de:
* Der Durchlauf in der for-Schleife wird bei jenem
Index begonnen, ab dem beim Sortieren
* von 'unten'
nach 'oben' kein Tausch der BO mehr erfolgt ist – d.h. alle BO
darüber
* sind schon in der richtigen Reihenfolge
– und geht bis zu jenem Index, bei dem beim
* Durchlauf
von 'oben' nach 'unten' kein Tausch mehr erfolgt ist.
*
en:
* The pass within the for-loop starts at that
index where, during sorting from 'bottom' to
* 'top',
no more exchange of BO happened – i.e. all BO above are already
in the
* right sort-order – and continues to
that index where, during sorting from 'top'
* to
'bottom', no more exchange of BO happened. */
for
(intIndex
= intHighestSortedIndicator - 1;
intIndex
>= intLowerAlreadySortedIndex;
intIndex--)
{
/*
*
de:
* 'Herausholen' der beiden zu vergleichenden BO aus dem
Vector und auf die zugeordneten
* Variabeln übertragen.
Damit wird die weitere Verarbeitung einfacher.
* en:
*
'Get' both BO to be compared out of the vector and tranfer them to
the assigned variables.
* This allows an easier
processing. */
struct1JSBS_Currency_BO
=
(JSBS_Currency_BO)
vecRecordSet
.elementAt(intIndex);
struct2JSBS_Currency_BO
=
(JSBS_Currency_BO)
vecRecordSet
.elementAt(intIndex
+ 1);
/*
*
de:
* Vergleich der BO wie beim Sortieren von 'unten' nach
'oben'.
* en:
* Comparison of the BO like sorting
from 'bottom' to 'top'.
*/
if
(
(locCollator.compare(struct1JSBS_Currency_BO.
LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.LeadCurrencyIndicator
.trim())
> 0)
|
(
(locCollator.compare(struct1JSBS_Currency_BO.LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.LeadCurrencyIndicator
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.ISOCurrencyCode
.trim(),
struct2JSBS_Currency_BO.ISOCurrencyCode
.trim())
> 0))
|
(
(locCollator.compare(struct1JSBS_Currency_BO.LeadCurrencyIndicator
.trim(),
struct2JSBS_Currency_BO.LeadCurrencyIndicator
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.ISOCurrencyCode
.trim(),
struct2JSBS_Currency_BO.ISOCurrencyCode
.trim())
== 0)
&
(locCollator.compare(struct1JSBS_Currency_BO.LanguageCodeForLabelling
.trim(),
struct2JSBS_Currency_BO.LanguageCodeForLabelling
.trim())
> 0))
)
{/*
*
de: BO sind in 'falscher' Reihenfolge und müssen vertauscht
werden.
* en: BO are in 'wrong' order and have to be
exchanged.
*/
vecRecordSet
.setElementAt(struct2JSBS_Currency_BO
,
intIndex);
vecRecordSet
.setElementAt(struct1JSBS_Currency_BO
, intIndex + 1);
/*
*
de: Indikator,
wie weit die Liste bereits sortiert ist, anpassen.
* en:
Adapt the indicator how far the list is already sorted.
*/
intLowestSortedIndicator
= intIndex;
}
}
}
}
}
xxx
Dokument |
Inhalt |
|
|