/** * <p>Calculates the <i>weighted</i> value of a charcter in the * code at a specified position.</p> * * <p>For Luhn (from right to left) <b>odd</b> digits are weighted * with a factor of <b>one</b> and <b>even</b> digits with a factor * of <b>two</b>. Weighted values > 9, have 9 subtracted</p> * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from left to right * @param rightPos The positionof the character in the code, counting from right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int weight = POSITION_WEIGHT[rightPos % 2]; int weightedValue = (charValue * weight); return ModulusCheckDigit.sumDigits(weightedValue); } }
/** * Calculates the <i>weighted</i> value of a character in the code at a * specified position. * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from * left to right * @param rightPos The position of the character in the code, counting from * right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int pos = useRightPos ? rightPos : leftPos; int weight = postitionWeight[(pos - 1) % postitionWeight.length]; int weightedValue = charValue * weight; if (sumWeightedDigits) { weightedValue = ModulusCheckDigit.sumDigits(weightedValue); } return weightedValue; }
/** * <p>Calculates the <i>weighted</i> value of a charcter in the * code at a specified position.</p> * * <p>For CUSIP (from right to left) <b>odd</b> digits are weighted * with a factor of <b>one</b> and <b>even</b> digits with a factor * of <b>two</b>. Weighted values > 9, have 9 subtracted</p> * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from left to right * @param rightPos The positionof the character in the code, counting from right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int weight = POSITION_WEIGHT[rightPos % 2]; int weightedValue = (charValue * weight); return ModulusCheckDigit.sumDigits(weightedValue); } }
/** * <p>Calculates the <i>weighted</i> value of a charcter in the * code at a specified position.</p> * * <p>For Luhn (from right to left) <b>odd</b> digits are weighted * with a factor of <b>one</b> and <b>even</b> digits with a factor * of <b>two</b>. Weighted values > 9, have 9 subtracted</p> * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from left to right * @param rightPos The positionof the character in the code, counting from right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int weight = POSITION_WEIGHT[rightPos % 2]; int weightedValue = (charValue * weight); return ModulusCheckDigit.sumDigits(weightedValue); } }
/** * <p>Calculates the <i>weighted</i> value of a charcter in the * code at a specified position.</p> * * <p>For CUSIP (from right to left) <b>odd</b> digits are weighted * with a factor of <b>one</b> and <b>even</b> digits with a factor * of <b>two</b>. Weighted values > 9, have 9 subtracted</p> * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from left to right * @param rightPos The positionof the character in the code, counting from right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int weight = POSITION_WEIGHT[rightPos % 2]; int weightedValue = (charValue * weight); return ModulusCheckDigit.sumDigits(weightedValue); } }
/** * Calculates the <i>weighted</i> value of a character in the code at a * specified position. * * @param charValue The numeric value of the character. * @param leftPos The position of the character in the code, counting from * left to right * @param rightPos The position of the character in the code, counting from * right to left * @return The weighted value of the character. */ @Override protected int weightedValue(int charValue, int leftPos, int rightPos) { int pos = useRightPos ? rightPos : leftPos; int weight = postitionWeight[(pos - 1) % postitionWeight.length]; int weightedValue = charValue * weight; if (sumWeightedDigits) { weightedValue = ModulusCheckDigit.sumDigits(weightedValue); } return weightedValue; }