Java Code Examples for com.google.zxing.FormatException#getFormatInstance()

The following examples show how to use com.google.zxing.FormatException#getFormatInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecodedBitStreamParser.java    From ScreenCapture with MIT License 6 votes vote down vote up
private static int parseECIValue(BitSource bits) throws FormatException {
  int firstByte = bits.readBits(8);
  if ((firstByte & 0x80) == 0) {
    // just one byte
    return firstByte & 0x7F;
  }
  if ((firstByte & 0xC0) == 0x80) {
    // two bytes
    int secondByte = bits.readBits(8);
    return ((firstByte & 0x3F) << 8) | secondByte;
  }
  if ((firstByte & 0xE0) == 0xC0) {
    // three bytes
    int secondThirdBytes = bits.readBits(16);
    return ((firstByte & 0x1F) << 16) | secondThirdBytes;
  }
  throw FormatException.getFormatInstance();
}
 
Example 2
Source File: DecodedBitStreamParser.java    From ScreenCapture with MIT License 5 votes vote down vote up
/**
 * See specification GBT 18284-2000
 */
private static void decodeHanziSegment(BitSource bits,
                                       StringBuilder result,
                                       int count) throws FormatException {
  // Don't crash trying to read more bits than we have available.
  if (count * 13 > bits.available()) {
    throw FormatException.getFormatInstance();
  }

  // Each character will require 2 bytes. Read the characters as 2-byte pairs
  // and decode as GB2312 afterwards
  byte[] buffer = new byte[2 * count];
  int offset = 0;
  while (count > 0) {
    // Each 13 bits encodes a 2-byte character
    int twoBytes = bits.readBits(13);
    int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
    if (assembledTwoBytes < 0x003BF) {
      // In the 0xA1A1 to 0xAAFE range
      assembledTwoBytes += 0x0A1A1;
    } else {
      // In the 0xB0A1 to 0xFAFE range
      assembledTwoBytes += 0x0A6A1;
    }
    buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF);
    buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF);
    offset += 2;
    count--;
  }

  try {
    result.append(new String(buffer, StringUtils.GB2312));
  } catch (UnsupportedEncodingException ignored) {
    throw FormatException.getFormatInstance();
  }
}
 
Example 3
Source File: DecodedNumeric.java    From ScreenCapture with MIT License 5 votes vote down vote up
DecodedNumeric(int newPosition, int firstDigit, int secondDigit) throws FormatException {
  super(newPosition);

  if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) {
    throw FormatException.getFormatInstance();
  }

  this.firstDigit  = firstDigit;
  this.secondDigit = secondDigit;
}
 
Example 4
Source File: DecodedNumeric.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
DecodedNumeric(int newPosition, int firstDigit, int secondDigit) throws FormatException {
  super(newPosition);

  if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) {
    throw FormatException.getFormatInstance();
  }

  this.firstDigit  = firstDigit;
  this.secondDigit = secondDigit;
}
 
Example 5
Source File: UPCAReader.java    From ScreenCapture with MIT License 5 votes vote down vote up
private static Result maybeReturnResult(Result result) throws FormatException {
  String text = result.getText();
  if (text.charAt(0) == '0') {
    return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
  } else {
    throw FormatException.getFormatInstance();
  }
}
 
Example 6
Source File: BitMatrixParser.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
/**
 * @param bitMatrix {@link BitMatrix} to parse
 * @throws FormatException if dimension is not >= 21 and 1 mod 4
 */
BitMatrixParser(BitMatrix bitMatrix) throws FormatException {
  int dimension = bitMatrix.getHeight();
  if (dimension < 21 || (dimension & 0x03) != 1) {
    throw FormatException.getFormatInstance();
  }
  this.bitMatrix = bitMatrix;
}
 
Example 7
Source File: BitMatrixParser.java    From ScreenCapture with MIT License 5 votes vote down vote up
/**
 * <p>Reads format information from one of its two locations within the QR Code.</p>
 *
 * @return {@link FormatInformation} encapsulating the QR Code's format info
 * @throws FormatException if both format information locations cannot be parsed as
 * the valid encoding of format information
 */
FormatInformation readFormatInformation() throws FormatException {

  if (parsedFormatInfo != null) {
    return parsedFormatInfo;
  }

  // Read top-left format info bits
  int formatInfoBits1 = 0;
  for (int i = 0; i < 6; i++) {
    formatInfoBits1 = copyBit(i, 8, formatInfoBits1);
  }
  // .. and skip a bit in the timing pattern ...
  formatInfoBits1 = copyBit(7, 8, formatInfoBits1);
  formatInfoBits1 = copyBit(8, 8, formatInfoBits1);
  formatInfoBits1 = copyBit(8, 7, formatInfoBits1);
  // .. and skip a bit in the timing pattern ...
  for (int j = 5; j >= 0; j--) {
    formatInfoBits1 = copyBit(8, j, formatInfoBits1);
  }

  // Read the top-right/bottom-left pattern too
  int dimension = bitMatrix.getHeight();
  int formatInfoBits2 = 0;
  int jMin = dimension - 7;
  for (int j = dimension - 1; j >= jMin; j--) {
    formatInfoBits2 = copyBit(8, j, formatInfoBits2);
  }
  for (int i = dimension - 8; i < dimension; i++) {
    formatInfoBits2 = copyBit(i, 8, formatInfoBits2);
  }

  parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2);
  if (parsedFormatInfo != null) {
    return parsedFormatInfo;
  }
  throw FormatException.getFormatInstance();
}
 
Example 8
Source File: BitMatrixParser.java    From ScreenCapture with MIT License 5 votes vote down vote up
/**
 * @param bitMatrix {@link BitMatrix} to parse
 * @throws FormatException if dimension is not >= 21 and 1 mod 4
 */
BitMatrixParser(BitMatrix bitMatrix) throws FormatException {
  int dimension = bitMatrix.getHeight();
  if (dimension < 21 || (dimension & 0x03) != 1) {
    throw FormatException.getFormatInstance();
  }
  this.bitMatrix = bitMatrix;
}
 
Example 9
Source File: Version.java    From ScreenCapture with MIT License 5 votes vote down vote up
/**
 * <p>Deduces version information purely from QR Code dimensions.</p>
 *
 * @param dimension dimension in modules
 * @return Version for a QR Code of that dimension
 * @throws FormatException if dimension is not 1 mod 4
 */
public static Version getProvisionalVersionForDimension(int dimension) throws FormatException {
  if (dimension % 4 != 1) {
    throw FormatException.getFormatInstance();
  }
  try {
    return getVersionForNumber((dimension - 17) / 4);
  } catch (IllegalArgumentException ignored) {
    throw FormatException.getFormatInstance();
  }
}
 
Example 10
Source File: DecodedBitStreamParser.java    From ScreenCapture with MIT License 5 votes vote down vote up
private static void decodeAlphanumericSegment(BitSource bits,
                                              StringBuilder result,
                                              int count,
                                              boolean fc1InEffect) throws FormatException {
  // Read two characters at a time
  int start = result.length();
  while (count > 1) {
    if (bits.available() < 11) {
      throw FormatException.getFormatInstance();
    }
    int nextTwoCharsBits = bits.readBits(11);
    result.append(toAlphaNumericChar(nextTwoCharsBits / 45));
    result.append(toAlphaNumericChar(nextTwoCharsBits % 45));
    count -= 2;
  }
  if (count == 1) {
    // special case: one character left
    if (bits.available() < 6) {
      throw FormatException.getFormatInstance();
    }
    result.append(toAlphaNumericChar(bits.readBits(6)));
  }
  // See section 6.4.8.1, 6.4.8.2
  if (fc1InEffect) {
    // We need to massage the result a bit if in an FNC1 mode:
    for (int i = start; i < result.length(); i++) {
      if (result.charAt(i) == '%') {
        if (i < result.length() - 1 && result.charAt(i + 1) == '%') {
          // %% is rendered as %
          result.deleteCharAt(i + 1);
        } else {
          // In alpha mode, % should be converted to FNC1 separator 0x1D
          result.setCharAt(i, (char) 0x1D);
        }
      }
    }
  }
}
 
Example 11
Source File: DecodedBitStreamParser.java    From ScreenCapture with MIT License 5 votes vote down vote up
private static void decodeByteSegment(BitSource bits,
                                      StringBuilder result,
                                      int count,
                                      CharacterSetECI currentCharacterSetECI,
                                      Collection<byte[]> byteSegments,
                                      Map<DecodeHintType,?> hints) throws FormatException {
  // Don't crash trying to read more bits than we have available.
  if (8 * count > bits.available()) {
    throw FormatException.getFormatInstance();
  }

  byte[] readBytes = new byte[count];
  for (int i = 0; i < count; i++) {
    readBytes[i] = (byte) bits.readBits(8);
  }
  String encoding;
  if (currentCharacterSetECI == null) {
    // The spec isn't clear on this mode; see
    // section 6.4.5: t does not say which encoding to assuming
    // upon decoding. I have seen ISO-8859-1 used as well as
    // Shift_JIS -- without anything like an ECI designator to
    // give a hint.
    encoding = StringUtils.guessEncoding(readBytes, hints);
  } else {
    encoding = currentCharacterSetECI.name();
  }
  try {
    result.append(new String(readBytes, encoding));
  } catch (UnsupportedEncodingException ignored) {
    throw FormatException.getFormatInstance();
  }
  byteSegments.add(readBytes);
}
 
Example 12
Source File: DecodedBitStreamParser.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
private static void decodeAlphanumericSegment(BitSource bits,
                                              StringBuilder result,
                                              int count,
                                              boolean fc1InEffect) throws FormatException {
  // Read two characters at a time
  int start = result.length();
  while (count > 1) {
    if (bits.available() < 11) {
      throw FormatException.getFormatInstance();
    }
    int nextTwoCharsBits = bits.readBits(11);
    result.append(toAlphaNumericChar(nextTwoCharsBits / 45));
    result.append(toAlphaNumericChar(nextTwoCharsBits % 45));
    count -= 2;
  }
  if (count == 1) {
    // special case: one character left
    if (bits.available() < 6) {
      throw FormatException.getFormatInstance();
    }
    result.append(toAlphaNumericChar(bits.readBits(6)));
  }
  // See section 6.4.8.1, 6.4.8.2
  if (fc1InEffect) {
    // We need to massage the result a bit if in an FNC1 mode:
    for (int i = start; i < result.length(); i++) {
      if (result.charAt(i) == '%') {
        if (i < result.length() - 1 && result.charAt(i + 1) == '%') {
          // %% is rendered as %
          result.deleteCharAt(i + 1);
        } else {
          // In alpha mode, % should be converted to FNC1 separator 0x1D
          result.setCharAt(i, (char) 0x1D);
        }
      }
    }
  }
}
 
Example 13
Source File: BitMatrixParser.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Reads format information from one of its two locations within the QR Code.</p>
 *
 * @return {@link FormatInformation} encapsulating the QR Code's format info
 * @throws FormatException if both format information locations cannot be parsed as
 * the valid encoding of format information
 */
FormatInformation readFormatInformation() throws FormatException {

  if (parsedFormatInfo != null) {
    return parsedFormatInfo;
  }

  // Read top-left format info bits
  int formatInfoBits1 = 0;
  for (int i = 0; i < 6; i++) {
    formatInfoBits1 = copyBit(i, 8, formatInfoBits1);
  }
  // .. and skip a bit in the timing pattern ...
  formatInfoBits1 = copyBit(7, 8, formatInfoBits1);
  formatInfoBits1 = copyBit(8, 8, formatInfoBits1);
  formatInfoBits1 = copyBit(8, 7, formatInfoBits1);
  // .. and skip a bit in the timing pattern ...
  for (int j = 5; j >= 0; j--) {
    formatInfoBits1 = copyBit(8, j, formatInfoBits1);
  }

  // Read the top-right/bottom-left pattern too
  int dimension = bitMatrix.getHeight();
  int formatInfoBits2 = 0;
  int jMin = dimension - 7;
  for (int j = dimension - 1; j >= jMin; j--) {
    formatInfoBits2 = copyBit(8, j, formatInfoBits2);
  }
  for (int i = dimension - 8; i < dimension; i++) {
    formatInfoBits2 = copyBit(i, 8, formatInfoBits2);
  }

  parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2);
  if (parsedFormatInfo != null) {
    return parsedFormatInfo;
  }
  throw FormatException.getFormatInstance();
}
 
Example 14
Source File: Code93Reader.java    From Tesseract-OCR-Scanner with Apache License 2.0 4 votes vote down vote up
private static String decodeExtended(CharSequence encoded) throws FormatException {
  int length = encoded.length();
  StringBuilder decoded = new StringBuilder(length);
  for (int i = 0; i < length; i++) {
    char c = encoded.charAt(i);
    if (c >= 'a' && c <= 'd') {
      if (i >= length - 1) {
        throw FormatException.getFormatInstance();
      }
      char next = encoded.charAt(i + 1);
      char decodedChar = '\0';
      switch (c) {
        case 'd':
          // +A to +Z map to a to z
          if (next >= 'A' && next <= 'Z') {
            decodedChar = (char) (next + 32);
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case 'a':
          // $A to $Z map to control codes SH to SB
          if (next >= 'A' && next <= 'Z') {
            decodedChar = (char) (next - 64);
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case 'b':
          if (next >= 'A' && next <= 'E') {
            // %A to %E map to control codes ESC to USep
            decodedChar = (char) (next - 38);
          } else if (next >= 'F' && next <= 'J') {
            // %F to %J map to ; < = > ?
            decodedChar = (char) (next - 11);
          } else if (next >= 'K' && next <= 'O') {
            // %K to %O map to [ \ ] ^ _
            decodedChar = (char) (next + 16);
          } else if (next >= 'P' && next <= 'S') {
            // %P to %S map to { | } ~
            decodedChar = (char) (next + 43);
          } else if (next >= 'T' && next <= 'Z') {
            // %T to %Z all map to DEL (127)
            decodedChar = 127;
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case 'c':
          // /A to /O map to ! to , and /Z maps to :
          if (next >= 'A' && next <= 'O') {
            decodedChar = (char) (next - 32);
          } else if (next == 'Z') {
            decodedChar = ':';
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
      }
      decoded.append(decodedChar);
      // bump up i again since we read two characters
      i++;
    } else {
      decoded.append(c);
    }
  }
  return decoded.toString();
}
 
Example 15
Source File: BitMatrixParser.java    From ScreenCapture with MIT License 4 votes vote down vote up
/**
 * <p>Reads version information from one of its two locations within the QR Code.</p>
 *
 * @return {@link Version} encapsulating the QR Code's version
 * @throws FormatException if both version information locations cannot be parsed as
 * the valid encoding of version information
 */
Version readVersion() throws FormatException {

  if (parsedVersion != null) {
    return parsedVersion;
  }

  int dimension = bitMatrix.getHeight();

  int provisionalVersion = (dimension - 17) / 4;
  if (provisionalVersion <= 6) {
    return Version.getVersionForNumber(provisionalVersion);
  }

  // Read top-right version info: 3 wide by 6 tall
  int versionBits = 0;
  int ijMin = dimension - 11;
  for (int j = 5; j >= 0; j--) {
    for (int i = dimension - 9; i >= ijMin; i--) {
      versionBits = copyBit(i, j, versionBits);
    }
  }

  Version theParsedVersion = Version.decodeVersionInformation(versionBits);
  if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) {
    parsedVersion = theParsedVersion;
    return theParsedVersion;
  }

  // Hmm, failed. Try bottom left: 6 wide by 3 tall
  versionBits = 0;
  for (int i = 5; i >= 0; i--) {
    for (int j = dimension - 9; j >= ijMin; j--) {
      versionBits = copyBit(i, j, versionBits);
    }
  }

  theParsedVersion = Version.decodeVersionInformation(versionBits);
  if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) {
    parsedVersion = theParsedVersion;
    return theParsedVersion;
  }
  throw FormatException.getFormatInstance();
}
 
Example 16
Source File: GeneralAppIdDecoder.java    From Tesseract-OCR-Scanner with Apache License 2.0 4 votes vote down vote up
private DecodedChar decodeIsoIec646(int pos) throws FormatException {
  int fiveBitValue = extractNumericValueFromBitArray(pos, 5);
  if (fiveBitValue == 15) {
    return new DecodedChar(pos + 5, DecodedChar.FNC1);
  }

  if (fiveBitValue >= 5 && fiveBitValue < 15) {
    return new DecodedChar(pos + 5, (char) ('0' + fiveBitValue - 5));
  }

  int sevenBitValue = extractNumericValueFromBitArray(pos, 7);

  if (sevenBitValue >= 64 && sevenBitValue < 90) {
    return new DecodedChar(pos + 7, (char) (sevenBitValue + 1));
  }

  if (sevenBitValue >= 90 && sevenBitValue < 116) {
    return new DecodedChar(pos + 7, (char) (sevenBitValue + 7));
  }

  int eightBitValue = extractNumericValueFromBitArray(pos, 8);
  char c;
  switch (eightBitValue) {
    case 232:
      c = '!';
      break;
    case 233:
      c = '"';
      break;
    case 234:
      c = '%';
      break;
    case 235:
      c = '&';
      break;
    case 236:
      c = '\'';
      break;
    case 237:
      c = '(';
      break;
    case 238:
      c = ')';
      break;
    case 239:
      c = '*';
      break;
    case 240:
      c = '+';
      break;
    case 241:
      c = ',';
      break;
    case 242:
      c = '-';
      break;
    case 243:
      c = '.';
      break;
    case 244:
      c = '/';
      break;
    case 245:
      c = ':';
      break;
    case 246:
      c = ';';
      break;
    case 247:
      c = '<';
      break;
    case 248:
      c = '=';
      break;
    case 249:
      c = '>';
      break;
    case 250:
      c = '?';
      break;
    case 251:
      c = '_';
      break;
    case 252:
      c = ' ';
      break;
    default:
      throw FormatException.getFormatInstance();
  }
  return new DecodedChar(pos + 8, c);
}
 
Example 17
Source File: ITFReader.java    From Tesseract-OCR-Scanner with Apache License 2.0 4 votes vote down vote up
@Override
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
    throws FormatException, NotFoundException {

  // Find out where the Middle section (payload) starts & ends
  int[] startRange = decodeStart(row);
  int[] endRange = decodeEnd(row);

  StringBuilder result = new StringBuilder(20);
  decodeMiddle(row, startRange[1], endRange[0], result);
  String resultString = result.toString();

  int[] allowedLengths = null;
  if (hints != null) {
    allowedLengths = (int[]) hints.get(DecodeHintType.ALLOWED_LENGTHS);

  }
  if (allowedLengths == null) {
    allowedLengths = DEFAULT_ALLOWED_LENGTHS;
  }

  // To avoid false positives with 2D barcodes (and other patterns), make
  // an assumption that the decoded string must be a 'standard' length if it's short
  int length = resultString.length();
  boolean lengthOK = false;
  int maxAllowedLength = 0;
  for (int allowedLength : allowedLengths) {
    if (length == allowedLength) {
      lengthOK = true;
      break;
    }
    if (allowedLength > maxAllowedLength) {
      maxAllowedLength = allowedLength;
    }
  }
  if (!lengthOK && length > maxAllowedLength) {
    lengthOK = true;
  }
  if (!lengthOK) {
    throw FormatException.getFormatInstance();
  }

  return new Result(
      resultString,
      null, // no natural byte representation for these barcodes
      new ResultPoint[] {new ResultPoint(startRange[1], rowNumber),
                         new ResultPoint(endRange[0], rowNumber)},
      BarcodeFormat.ITF);
}
 
Example 18
Source File: Code39Reader.java    From Tesseract-OCR-Scanner with Apache License 2.0 4 votes vote down vote up
private static String decodeExtended(CharSequence encoded) throws FormatException {
  int length = encoded.length();
  StringBuilder decoded = new StringBuilder(length);
  for (int i = 0; i < length; i++) {
    char c = encoded.charAt(i);
    if (c == '+' || c == '$' || c == '%' || c == '/') {
      char next = encoded.charAt(i + 1);
      char decodedChar = '\0';
      switch (c) {
        case '+':
          // +A to +Z map to a to z
          if (next >= 'A' && next <= 'Z') {
            decodedChar = (char) (next + 32);
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case '$':
          // $A to $Z map to control codes SH to SB
          if (next >= 'A' && next <= 'Z') {
            decodedChar = (char) (next - 64);
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case '%':
          // %A to %E map to control codes ESC to US
          if (next >= 'A' && next <= 'E') {
            decodedChar = (char) (next - 38);
          } else if (next >= 'F' && next <= 'W') {
            decodedChar = (char) (next - 11);
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
        case '/':
          // /A to /O map to ! to , and /Z maps to :
          if (next >= 'A' && next <= 'O') {
            decodedChar = (char) (next - 32);
          } else if (next == 'Z') {
            decodedChar = ':';
          } else {
            throw FormatException.getFormatInstance();
          }
          break;
      }
      decoded.append(decodedChar);
      // bump up i again since we read two characters
      i++;
    } else {
      decoded.append(c);
    }
  }
  return decoded.toString();
}
 
Example 19
Source File: DecodedBitStreamParser.java    From ScreenCapture with MIT License 4 votes vote down vote up
private static char toAlphaNumericChar(int value) throws FormatException {
  if (value >= ALPHANUMERIC_CHARS.length) {
    throw FormatException.getFormatInstance();
  }
  return ALPHANUMERIC_CHARS[value];
}
 
Example 20
Source File: BitMatrixParser.java    From Tesseract-OCR-Scanner with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Reads version information from one of its two locations within the QR Code.</p>
 *
 * @return {@link Version} encapsulating the QR Code's version
 * @throws FormatException if both version information locations cannot be parsed as
 * the valid encoding of version information
 */
Version readVersion() throws FormatException {

  if (parsedVersion != null) {
    return parsedVersion;
  }

  int dimension = bitMatrix.getHeight();

  int provisionalVersion = (dimension - 17) / 4;
  if (provisionalVersion <= 6) {
    return Version.getVersionForNumber(provisionalVersion);
  }

  // Read top-right version info: 3 wide by 6 tall
  int versionBits = 0;
  int ijMin = dimension - 11;
  for (int j = 5; j >= 0; j--) {
    for (int i = dimension - 9; i >= ijMin; i--) {
      versionBits = copyBit(i, j, versionBits);
    }
  }

  Version theParsedVersion = Version.decodeVersionInformation(versionBits);
  if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) {
    parsedVersion = theParsedVersion;
    return theParsedVersion;
  }

  // Hmm, failed. Try bottom left: 6 wide by 3 tall
  versionBits = 0;
  for (int i = 5; i >= 0; i--) {
    for (int j = dimension - 9; j >= ijMin; j--) {
      versionBits = copyBit(i, j, versionBits);
    }
  }

  theParsedVersion = Version.decodeVersionInformation(versionBits);
  if (theParsedVersion != null && theParsedVersion.getDimensionForVersion() == dimension) {
    parsedVersion = theParsedVersion;
    return theParsedVersion;
  }
  throw FormatException.getFormatInstance();
}