本文整理汇总了Java中com.helger.commons.string.StringHelper.getHexValue方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.getHexValue方法的具体用法?Java StringHelper.getHexValue怎么用?Java StringHelper.getHexValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.string.StringHelper
的用法示例。
在下文中一共展示了StringHelper.getHexValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _getHexValue
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
* @param c
* character
* @return The int representation of the read hex char (0-9, a-f)
* @throws JsonParseException
* In case a non hex char was encountered
*/
private int _getHexValue (@Nonnull final IJsonParsePosition aStartPos, final int c) throws JsonParseException
{
final int ret = StringHelper.getHexValue ((char) c);
if (ret == -1)
throw _parseEx (aStartPos, "Invalid hex character " + _getPrintableChar (c) + " provided!");
return ret;
}
示例2: _hexval
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
private static int _hexval (final char c)
{
final int ret = StringHelper.getHexValue (c);
if (ret < 0)
throw new IllegalArgumentException ("Illegal hex char '" + c + "'");
return ret;
}
示例3: decode
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
public void decode (@Nullable final byte [] aEncodedBuffer,
@Nonnegative final int nOfs,
@Nonnegative final int nLen,
@Nonnull @WillNotClose final OutputStream aOS)
{
if (aEncodedBuffer == null || nLen == 0)
return;
try
{
boolean bFirstByte = true;
int nFirstByte = 0;
for (int i = 0; i < nLen; ++i)
{
final byte nEncByte = aEncodedBuffer[nOfs + i];
if (nEncByte == '>')
break;
// Ignore whitespaces
if (Character.isWhitespace (nEncByte))
continue;
final byte nDecByte = (byte) StringHelper.getHexValue ((char) nEncByte);
if (nDecByte == CGlobal.ILLEGAL_UINT)
throw new DecodeException ("Failed to convert byte '" +
nEncByte +
"/" +
((char) nEncByte) +
"' to hex value in ASCIIHexDecode");
if (bFirstByte)
nFirstByte = nDecByte;
else
aOS.write ((byte) (nFirstByte << 4 | nDecByte));
bFirstByte = !bFirstByte;
}
// Write trailing byte
if (!bFirstByte)
aOS.write ((byte) (nFirstByte << 4));
}
catch (final IOException ex)
{
throw new DecodeException ("Failed to decode ASCII Hex", ex);
}
}