kernpruefung.bnz.util
Class CheckMethods

java.lang.Object
  extended by kernpruefung.bnz.util.CheckMethods

public class CheckMethods
extends java.lang.Object

The class CheckMethods contains all (static) methods to check the rules from the specifications.

This class is a static class without a public c'tor.

Version:
1.0
Author:
Frank Zimmermann (LSV Spitzenverband)

Field Summary
static int BETRIEBSNUMMER
           
static int STICHJAHR
           
static int ZAHLSTELLENNUMMER
           
static int ZAHLSTELLENNUMMER0
           
 
Method Summary
static boolean hasCorrectAtChar(java.lang.String testString)
          Checks if exactly one @ or § is in testString and whether it is not in first or last position.
static boolean hasForeignLDKZ(java.lang.String testLDKZ)
          Checks if testLDKZ is a valid LDKZ (see DEÜV Anlage 8) CheckMethods.hasForeignLDKZ( "" ) == false CheckMethods.hasForeignLDKZ( " " ) == false CheckMethods.hasForeignLDKZ( "BHT" ) == true CheckMethods.hasForeignLDKZ( "IRL" ) == true CheckMethods.hasForeignLDKZ( "xxx" ) == false CheckMethods.hasForeignLDKZ( " L " ) == false
static boolean hasHomePLZ(java.lang.String testPLZ)
          Checks if testPLZ is a valid home PLZ between 01000 ... 99999 CheckMethods.hasHomePLZ( "" ) == false CheckMethods.hasHomePLZ( " " ) == false CheckMethods.hasHomePLZ( "01000 " ) == true CheckMethods.hasHomePLZ( "44866 " ) == true CheckMethods.hasHomePLZ( "00010 " ) == false CheckMethods.hasHomePLZ( " 44866 " ) == false
static boolean hasPLZCharsItl(java.lang.String testPLZ)
          Checks if testPLZ has valid Itl PLZ chars
static boolean hasValidEmailCharacters(java.lang.String testString)
          Checks if testString contains only valid email characters.
static boolean isANDefaultValue(java.lang.String testString)
          Checks if testString has only the defaultValue (string field: all spaces)
static boolean isCheckDigit(java.lang.String testString, int p)
          Checks if the testString is a valid Zahlstellennummer or Betriebsnummer.
static boolean isConstantString(java.lang.String testString, java.lang.String constant)
          Checks if first argument (testString) is equal to the second argument (the constant) and if testString is not NULL or empty.
static boolean isDate(java.lang.String testDate)
          Checks if testDate is a valid date.
static boolean isDate0000(java.lang.String testDate)
          Checks if testDate is a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000".
static boolean isDate1LaterDate2(java.lang.String testDate1, java.lang.String testDate2)
          Checks if testDate1 is later than testDate2.
static boolean isDate1NotLaterDate2PlusXMonths(java.lang.String testDate1, java.lang.String testDate2, int months)
          Checks if testDate1 is not later than end of month from testDate2 plus months.
static boolean isDateNotLaterToday(java.lang.String testDate)
          Checks if testDate is not later than current date.
static boolean isEmptyOrNull(java.lang.String testString)
          Checks if testString contains only spaces or is NULL or is an empty string.
static boolean isInCharSet(char testChar, java.lang.String charSet)
          Checks if ch is member of the charSet given as a string charSet
static boolean isNDefaultValue(java.lang.String testString)
          Checks if testString has only the defaultValue (numeric field: all Zeros)
static boolean isNumeric(java.lang.String testString)
          Checks if testString contains only digits.
static boolean isTime(java.lang.String testTime)
          Checks if testTime is a valid time value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZAHLSTELLENNUMMER0

public static final int ZAHLSTELLENNUMMER0
See Also:
Constant Field Values

ZAHLSTELLENNUMMER

public static final int ZAHLSTELLENNUMMER
See Also:
Constant Field Values

BETRIEBSNUMMER

public static final int BETRIEBSNUMMER
See Also:
Constant Field Values

STICHJAHR

public static final int STICHJAHR
See Also:
Constant Field Values
Method Detail

isEmptyOrNull

public static boolean isEmptyOrNull(java.lang.String testString)
Checks if testString contains only spaces or is NULL or is an empty string.
 CheckMethods.isEmptyOrNull( null    ) == true 
 CheckMethods.isEmptyOrNull( ""      ) == true 
 CheckMethods.isEmptyOrNull( " "     ) == true
 CheckMethods.isEmptyOrNull( "     " ) == true
 CheckMethods.isEmptyOrNull( " x a " ) == false
 CheckMethods.isEmptyOrNull( "abc "  ) == false
 

Parameters:
testString - string that is checked
Returns:
true if testString contains only spaces or is NULL or is an empty string and false otherwise.

isNumeric

public static boolean isNumeric(java.lang.String testString)
Checks if testString contains only digits.
 CheckMethods.isNumeric( null    ) == false
 CheckMethods.isNumeric( ""      ) == false
 CheckMethods.isNumeric( "   "   ) == false
 CheckMethods.isNumeric( "12345" ) == true
 CheckMethods.isNumeric( "1x2a5" ) == false
 CheckMethods.isNumeric( "1 234" ) == false
 

Parameters:
testString - string that is checked
Returns:
true if testString contains only digits, false otherwise.

isDate

public static boolean isDate(java.lang.String testDate)
Checks if testDate is a valid date.

Parameters:
testDate - string that is checked (format: jhjjmmtt)
Returns:
true if testDate is a valid date, false otherwise.

isDate0000

public static boolean isDate0000(java.lang.String testDate)
Checks if testDate is a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000".

Parameters:
testDate - string that is checked (format: jhjjmmtt)
Returns:
true if testDate is a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000", false otherwise.

isDateNotLaterToday

public static boolean isDateNotLaterToday(java.lang.String testDate)
Checks if testDate is not later than current date.

Parameters:
testDate - string that is checked (format: jhjjmmtt)
Returns:
true if testDate is not later than current date.

isTime

public static boolean isTime(java.lang.String testTime)
Checks if testTime is a valid time value.
         hh >= 00 and hh <= 23
         mm >= 00 and mm <= 59
         ss >= 00 and ss <= 59
 

Parameters:
testTime - string that is checked (format: hhmmss)
Returns:
true if testTime is a valid time value, false otherwise.

hasValidEmailCharacters

public static boolean hasValidEmailCharacters(java.lang.String testString)
Checks if testString contains only valid email characters.

Parameters:
testString - string that is checked
Returns:
true if testString contains only valid email characters.

hasCorrectAtChar

public static boolean hasCorrectAtChar(java.lang.String testString)
Checks if exactly one @ or § is in testString and whether it is not in first or last position.

Parameters:
testString - string that is checked
Returns:
true if exactly one @ or § is in testString and is not in first or last position, false otherwise.

isCheckDigit

public static boolean isCheckDigit(java.lang.String testString,
                                   int p)
Checks if the testString is a valid Zahlstellennummer or Betriebsnummer.
The format of the testString must be 8 digits followed by 7 spaces and hence sums up to a total of 15 characters.

An obligate parameter specifies the check:

 param=ZAHLSTELLENNUMMER : Checks if the first 3 positions are resp. 106, 107 or 108 and 
                           if the 8. digit is a valid check digit following spec DEÜV 1.3.2.2 .
 param=BETRIEBSNUMMER    : Checks if the first 3 positions are in the range 001 to 099 or greater 
                           than 110 and if the 8. digit is a valid check digit following spec 
                           DEÜV 1.3.2.2 .
 
The check digit is specified as followed (1.3.2.2 of DEÜV):
An alternative check digit is the original check digit plus 5. If this alternative check digit is greater than 9 the last digit is the alternative check digit.
 Example: 87661207    ==>  pos      :   1  2  3  4  5  6  7  8  (pos 8 = check digit)
 ========
                              Digit :   8  7  6  6  1  2  0  7
                          factor 1-7:   1  2  1  2  1  2  1
  +--Calculation--------------------------------------------------------+
  !                     weighted sum:   8 14  6 12  1  4  0             !
  !                    sum of digits:   8  5  6  3  1  4  0             !
  !                              sum:   27                              !
  !    remainder from division by 10:   7  <--check digit               !
  !alternative check digit:                                             !
  !                  check digit + 5:   12                              !
  !                       last digit:   2  <--alternative check digit   !
  !                                                                     ! 
  !    result: valid check digit is : 7 or 2                              !                 
  +---------------------------------------------------------------------+
 

Parameters:
testString - testString
p - specifies the test variant
Returns:
true if testString is a valid Betriebsnummer or Zahlstellennummer

isConstantString

public static boolean isConstantString(java.lang.String testString,
                                       java.lang.String constant)
Checks if first argument (testString) is equal to the second argument (the constant) and if testString is not NULL or empty.

Parameters:
testString - test string that is compared with constant
constant - the constant for that the check is performed
Returns:
true if testString is equal to the constant, otherwise false

isInCharSet

public static boolean isInCharSet(char testChar,
                                  java.lang.String charSet)
Checks if ch is member of the charSet given as a string charSet

Parameters:
testChar -
charSet -
Returns:
true if charSet contains the testChar, false otherwise

isDate1LaterDate2

public static boolean isDate1LaterDate2(java.lang.String testDate1,
                                        java.lang.String testDate2)
Checks if testDate1 is later than testDate2. If testDate1 or testDate2 is NULL it is replaced with current Date

Parameters:
testDate1 - (Format: jhjjmmtt)
testDate2 - (Format: jhjjmmtt)
Returns:
true if testDate1 is later than testDate2, otherwise false

isDate1NotLaterDate2PlusXMonths

public static boolean isDate1NotLaterDate2PlusXMonths(java.lang.String testDate1,
                                                      java.lang.String testDate2,
                                                      int months)
Checks if testDate1 is not later than end of month from testDate2 plus months. If testDate1 or testDate2 is NULL it is replaced with current Date

Parameters:
testDate1 - (Format: jhjjmmtt)
testDate2 - (Format: jhjjmmtt)
Returns:
true if testDate1 is not later than end of month from testDate2 plus months, otherwise false

isNDefaultValue

public static boolean isNDefaultValue(java.lang.String testString)
Checks if testString has only the defaultValue (numeric field: all Zeros)

Parameters:
testString -
Returns:
true if testString has only the defaultValue (numeric field:all Zeros), otherwise false

isANDefaultValue

public static boolean isANDefaultValue(java.lang.String testString)
Checks if testString has only the defaultValue (string field: all spaces)

Parameters:
testString -
Returns:
true if testString has only the defaultValue (string field: all spaces), otherwise false

hasForeignLDKZ

public static boolean hasForeignLDKZ(java.lang.String testLDKZ)
Checks if testLDKZ is a valid LDKZ (see DEÜV Anlage 8)
 CheckMethods.hasForeignLDKZ( ""    ) == false
 CheckMethods.hasForeignLDKZ( "   " ) == false
 CheckMethods.hasForeignLDKZ( "BHT" ) == true 
 CheckMethods.hasForeignLDKZ( "IRL" ) == true 
 CheckMethods.hasForeignLDKZ( "xxx" ) == false 
 CheckMethods.hasForeignLDKZ( " L " ) == false 
 

Parameters:
testLDKZ -
Returns:
true if testLDKZ is a valid LDKZ, false otherwise

hasHomePLZ

public static boolean hasHomePLZ(java.lang.String testPLZ)
Checks if testPLZ is a valid home PLZ between 01000 ... 99999
 CheckMethods.hasHomePLZ( ""           ) == false
 CheckMethods.hasHomePLZ( "          " ) == false                                       
 CheckMethods.hasHomePLZ( "01000     " ) == true 
 CheckMethods.hasHomePLZ( "44866     " ) == true 
 CheckMethods.hasHomePLZ( "00010     " ) == false 
 CheckMethods.hasHomePLZ( "   44866  " ) == false 
 

Parameters:
testPLZ -
Returns:
true if testPLZ is a valid home PLZ, false otherwise

hasPLZCharsItl

public static boolean hasPLZCharsItl(java.lang.String testPLZ)
Checks if testPLZ has valid Itl PLZ chars

Parameters:
testPLZ -
Returns:
true if testPLZ has valid Itl PLZ chars, false otherwise