当前位置: 首页>>代码示例>>Java>>正文


Java Mode.BYTE属性代码示例

本文整理汇总了Java中com.google.zxing.qrcode.decoder.Mode.BYTE属性的典型用法代码示例。如果您正苦于以下问题:Java Mode.BYTE属性的具体用法?Java Mode.BYTE怎么用?Java Mode.BYTE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.zxing.qrcode.decoder.Mode的用法示例。


在下文中一共展示了Mode.BYTE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
 * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
  if ("Shift_JIS".equals(encoding) && isOnlyDoubleByteKanji(content)) {
    // Choose Kanji mode if all input are double-byte characters
    return Mode.KANJI;
  }
  boolean hasNumeric = false;
  boolean hasAlphanumeric = false;
  for (int i = 0; i < content.length(); ++i) {
    char c = content.charAt(i);
    if (c >= '0' && c <= '9') {
      hasNumeric = true;
    } else if (getAlphanumericCode(c) != -1) {
      hasAlphanumeric = true;
    } else {
      return Mode.BYTE;
    }
  }
  if (hasAlphanumeric) {
    return Mode.ALPHANUMERIC;
  }
  if (hasNumeric) {
    return Mode.NUMERIC;
  }
  return Mode.BYTE;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:29,代码来源:Encoder.java

示例2: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
 * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
  if ("Shift_JIS".equals(encoding)) {
    // Choose Kanji mode if all input are double-byte characters
    return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
  }
  boolean hasNumeric = false;
  boolean hasAlphanumeric = false;
  for (int i = 0; i < content.length(); ++i) {
    char c = content.charAt(i);
    if (c >= '0' && c <= '9') {
      hasNumeric = true;
    } else if (getAlphanumericCode(c) != -1) {
      hasAlphanumeric = true;
    } else {
      return Mode.BYTE;
    }
  }
  if (hasAlphanumeric) {
    return Mode.ALPHANUMERIC;
  }
  if (hasNumeric) {
    return Mode.NUMERIC;
  }
  return Mode.BYTE;
}
 
开发者ID:SudarAbisheck,项目名称:ZXing-Orient,代码行数:29,代码来源:Encoder.java

示例3: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
 * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
    if ("Shift_JIS".equals(encoding)) {
        // Choose Kanji mode if all input are double-byte characters
        return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
    }
    boolean hasNumeric = false;
    boolean hasAlphanumeric = false;
    for (int i = 0; i < content.length(); ++i) {
        char c = content.charAt(i);
        if (c >= '0' && c <= '9') {
            hasNumeric = true;
        } else if (getAlphanumericCode(c) != -1) {
            hasAlphanumeric = true;
        } else {
            return Mode.BYTE;
        }
    }
    if (hasAlphanumeric) {
        return Mode.ALPHANUMERIC;
    }
    if (hasNumeric) {
        return Mode.NUMERIC;
    }
    return Mode.BYTE;
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:29,代码来源:Encoder.java

示例4: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
 * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link com.google.zxing.qrcode.decoder.Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
  if ("Shift_JIS".equals(encoding)) {
    // Choose Kanji mode if all input are double-byte characters
    return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
  }
  boolean hasNumeric = false;
  boolean hasAlphanumeric = false;
  for (int i = 0; i < content.length(); ++i) {
    char c = content.charAt(i);
    if (c >= '0' && c <= '9') {
      hasNumeric = true;
    } else if (getAlphanumericCode(c) != -1) {
      hasAlphanumeric = true;
    } else {
      return Mode.BYTE;
    }
  }
  if (hasAlphanumeric) {
    return Mode.ALPHANUMERIC;
  }
  if (hasNumeric) {
    return Mode.NUMERIC;
  }
  return Mode.BYTE;
}
 
开发者ID:bushidowallet,项目名称:bushido-android-app,代码行数:29,代码来源:Encoder.java

示例5: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is
 * used as a hint; if it is Shift_JIS, and the input is only double-byte
 * Kanji, then we return {@link Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
	if ("Shift_JIS".equals(encoding)) {
		// Choose Kanji mode if all input are double-byte characters
		return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
	}
	boolean hasNumeric = false;
	boolean hasAlphanumeric = false;
	for (int i = 0; i < content.length(); ++i) {
		char c = content.charAt(i);
		if (c >= '0' && c <= '9') {
			hasNumeric = true;
		} else if (getAlphanumericCode(c) != -1) {
			hasAlphanumeric = true;
		} else {
			return Mode.BYTE;
		}
	}
	if (hasAlphanumeric) {
		return Mode.ALPHANUMERIC;
	}
	if (hasNumeric) {
		return Mode.NUMERIC;
	}
	return Mode.BYTE;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:30,代码来源:Encoder.java

示例6: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;
 * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.
 */
public static Mode chooseMode(String content, String encoding) {
  if ("Shift_JIS".equals(encoding)) {
    // Choose Kanji mode if all input are double-byte characters
    return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
  }
  boolean hasNumeric = false;
  boolean hasAlphanumeric = false;
  for (int i = 0; i < content.length(); ++i) {
    char c = content.charAt(i);
    if (c >= '0' && c <= '9') {
      hasNumeric = true;
    } else if (getAlphanumericCode(c) != -1) {
      hasAlphanumeric = true;
    } else {
      return Mode.BYTE;
    }
  }
  if (hasAlphanumeric) {
    return Mode.ALPHANUMERIC;
  } else if (hasNumeric) {
    return Mode.NUMERIC;
  }
  return Mode.BYTE;
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:28,代码来源:Encoder.java

示例7: chooseMode

/**
 * Choose the best mode by examining the content. Note that 'encoding' is
 * used as a hint; if it is Shift_JIS, and the input is only double-byte
 * Kanji, then we return {@link com.google.zxing.qrcode.decoder.Mode#KANJI}.
 */
private static Mode chooseMode(String content, String encoding) {
	if ("Shift_JIS".equals(encoding)) {
		// Choose Kanji mode if all input are double-byte characters
		return isOnlyDoubleByteKanji(content) ? Mode.KANJI : Mode.BYTE;
	}
	boolean hasNumeric = false;
	boolean hasAlphanumeric = false;
	for (int i = 0; i < content.length(); ++i) {
		char c = content.charAt(i);
		if (c >= '0' && c <= '9') {
			hasNumeric = true;
		} else if (getAlphanumericCode(c) != -1) {
			hasAlphanumeric = true;
		} else {
			return Mode.BYTE;
		}
	}
	if (hasAlphanumeric) {
		return Mode.ALPHANUMERIC;
	}
	if (hasNumeric) {
		return Mode.NUMERIC;
	}
	return Mode.BYTE;
}
 
开发者ID:Tinker-S,项目名称:FaceBarCodeDemo,代码行数:30,代码来源:Encoder.java

示例8: chooseMode

private static Mode chooseMode(String content, String encoding) {
    if (!"Shift_JIS".equals(encoding)) {
        boolean hasNumeric = false;
        boolean hasAlphanumeric = false;
        for (int i = 0; i < content.length(); i++) {
            char c = content.charAt(i);
            if (c >= '0' && c <= '9') {
                hasNumeric = true;
            } else if (getAlphanumericCode(c) == -1) {
                return Mode.BYTE;
            } else {
                hasAlphanumeric = true;
            }
        }
        if (hasAlphanumeric) {
            return Mode.ALPHANUMERIC;
        }
        if (hasNumeric) {
            return Mode.NUMERIC;
        }
        return Mode.BYTE;
    } else if (isOnlyDoubleByteKanji(content)) {
        return Mode.KANJI;
    } else {
        return Mode.BYTE;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:Encoder.java

示例9: encode

public static QRCode encode(String content, ErrorCorrectionLevel ecLevel, Map<EncodeHintType,
        ?> hints) throws WriterException {
    String encoding;
    if (hints == null) {
        encoding = null;
    } else {
        encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
    }
    if (encoding == null) {
        encoding = DEFAULT_BYTE_MODE_ENCODING;
    }
    Mode mode = chooseMode(content, encoding);
    BitArray headerBits = new BitArray();
    if (mode == Mode.BYTE && !DEFAULT_BYTE_MODE_ENCODING.equals(encoding)) {
        CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
        if (eci != null) {
            appendECI(eci, headerBits);
        }
    }
    appendModeInfo(mode, headerBits);
    BitArray dataBits = new BitArray();
    appendBytes(content, mode, dataBits, encoding);
    Version version = chooseVersion((headerBits.getSize() + mode.getCharacterCountBits
            (chooseVersion((headerBits.getSize() + mode.getCharacterCountBits(Version
                    .getVersionForNumber(1))) + dataBits.getSize(), ecLevel))) + dataBits
            .getSize(), ecLevel);
    BitArray headerAndDataBits = new BitArray();
    headerAndDataBits.appendBitArray(headerBits);
    appendLengthInfo(mode == Mode.BYTE ? dataBits.getSizeInBytes() : content.length(),
            version, mode, headerAndDataBits);
    headerAndDataBits.appendBitArray(dataBits);
    ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
    int numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();
    terminateBits(numDataBytes, headerAndDataBits);
    BitArray finalBits = interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords()
            , numDataBytes, ecBlocks.getNumBlocks());
    QRCode qrCode = new QRCode();
    qrCode.setECLevel(ecLevel);
    qrCode.setMode(mode);
    qrCode.setVersion(version);
    int dimension = version.getDimensionForVersion();
    ByteMatrix matrix = new ByteMatrix(dimension, dimension);
    int maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix);
    qrCode.setMaskPattern(maskPattern);
    MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix);
    qrCode.setMatrix(matrix);
    return qrCode;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:48,代码来源:Encoder.java

示例10: a

private static Mode a(String s, String s1)
{
    int i = 0;
    if ("Shift_JIS".equals(s1))
    {
        if (a(s))
        {
            return Mode.KANJI;
        } else
        {
            return Mode.BYTE;
        }
    }
    boolean flag = false;
    boolean flag1 = false;
    while (i < s.length()) 
    {
        char c1 = s.charAt(i);
        if (c1 >= '0' && c1 <= '9')
        {
            flag1 = true;
        } else
        if (a(c1) != -1)
        {
            flag = true;
        } else
        {
            return Mode.BYTE;
        }
        i++;
    }
    if (flag)
    {
        return Mode.ALPHANUMERIC;
    }
    if (flag1)
    {
        return Mode.NUMERIC;
    } else
    {
        return Mode.BYTE;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:43,代码来源:Encoder.java

示例11: encode

public static void encode(String s, ErrorCorrectionLevel errorcorrectionlevel, Map map, QRCode qrcode)
{
    String s1;
    Mode mode;
    BitArray bitarray;
    BitArray bitarray1;
    int i;
    BitArray bitarray2;
    ByteMatrix bytematrix;
    if (map == null)
    {
        s1 = null;
    } else
    {
        s1 = (String)map.get(EncodeHintType.CHARACTER_SET);
    }
    if (s1 == null)
    {
        s1 = "ISO-8859-1";
    }
    mode = a(s, s1);
    bitarray = new BitArray();
    a(s, mode, bitarray, s1);
    a(bitarray.getSize(), errorcorrectionlevel, mode, qrcode);
    bitarray1 = new BitArray();
    if (mode == Mode.BYTE && !"ISO-8859-1".equals(s1))
    {
        CharacterSetECI characterseteci = CharacterSetECI.getCharacterSetECIByName(s1);
        if (characterseteci != null)
        {
            a(characterseteci, bitarray1);
        }
    }
    a(mode, bitarray1);
    if (mode == Mode.BYTE)
    {
        i = bitarray.getSizeInBytes();
    } else
    {
        i = s.length();
    }
    a(i, qrcode.getVersion(), mode, bitarray1);
    bitarray1.appendBitArray(bitarray);
    a(qrcode.getNumDataBytes(), bitarray1);
    bitarray2 = new BitArray();
    a(bitarray1, qrcode.getNumTotalBytes(), qrcode.getNumDataBytes(), qrcode.getNumRSBlocks(), bitarray2);
    bytematrix = new ByteMatrix(qrcode.getMatrixWidth(), qrcode.getMatrixWidth());
    qrcode.setMaskPattern(a(bitarray2, errorcorrectionlevel, qrcode.getVersion(), bytematrix));
    d.a(bitarray2, errorcorrectionlevel, qrcode.getVersion(), qrcode.getMaskPattern(), bytematrix);
    qrcode.setMatrix(bytematrix);
    if (!qrcode.isValid())
    {
        throw new WriterException((new StringBuilder()).append("Invalid QR code: ").append(qrcode.toString()).toString());
    } else
    {
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:58,代码来源:Encoder.java

示例12: encode

public static void encode(String content, ErrorCorrectionLevel ecLevel, Hashtable hints,
    QRCode qrCode) throws WriterException {

  String encoding = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);
  if (encoding == null) {
    encoding = DEFAULT_BYTE_MODE_ENCODING;
  }

  // Step 1: Choose the mode (encoding).
  Mode mode = chooseMode(content, encoding);

  // Step 2: Append "bytes" into "dataBits" in appropriate encoding.
  BitArray dataBits = new BitArray();
  appendBytes(content, mode, dataBits, encoding);
  // Step 3: Initialize QR code that can contain "dataBits".
  int numInputBytes = dataBits.getSizeInBytes();
  initQRCode(numInputBytes, ecLevel, mode, qrCode);

  // Step 4: Build another bit vector that contains header and data.
  BitArray headerAndDataBits = new BitArray();

  // Step 4.5: Append ECI message if applicable
  if (mode == Mode.BYTE && !DEFAULT_BYTE_MODE_ENCODING.equals(encoding)) {
    CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
    if (eci != null) {
      appendECI(eci, headerAndDataBits);
    }
  }

  appendModeInfo(mode, headerAndDataBits);

  int numLetters = mode.equals(Mode.BYTE) ? dataBits.getSizeInBytes() : content.length();
  appendLengthInfo(numLetters, qrCode.getVersion(), mode, headerAndDataBits);
  headerAndDataBits.appendBitArray(dataBits);

  // Step 5: Terminate the bits properly.
  terminateBits(qrCode.getNumDataBytes(), headerAndDataBits);

  // Step 6: Interleave data bits with error correction code.
  BitArray finalBits = new BitArray();
  interleaveWithECBytes(headerAndDataBits, qrCode.getNumTotalBytes(), qrCode.getNumDataBytes(),
      qrCode.getNumRSBlocks(), finalBits);

  // Step 7: Choose the mask pattern and set to "qrCode".
  ByteMatrix matrix = new ByteMatrix(qrCode.getMatrixWidth(), qrCode.getMatrixWidth());
  qrCode.setMaskPattern(chooseMaskPattern(finalBits, qrCode.getECLevel(), qrCode.getVersion(),
      matrix));

  // Step 8.  Build the matrix and set it to "qrCode".
  MatrixUtil.buildMatrix(finalBits, qrCode.getECLevel(), qrCode.getVersion(),
      qrCode.getMaskPattern(), matrix);
  qrCode.setMatrix(matrix);
  // Step 9.  Make sure we have a valid QR Code.
  if (!qrCode.isValid()) {
    throw new WriterException("Invalid QR code: " + qrCode.toString());
  }
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:57,代码来源:Encoder.java


注:本文中的com.google.zxing.qrcode.decoder.Mode.BYTE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。