本文整理汇总了Java中org.h2.util.StringUtils.convertBytesToHex方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.convertBytesToHex方法的具体用法?Java StringUtils.convertBytesToHex怎么用?Java StringUtils.convertBytesToHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.convertBytesToHex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getString
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision;
try {
if (type == Value.CLOB) {
if (small != null) {
return new String(small, Constants.UTF8);
}
return IOUtils.readStringAndClose(getReader(), len);
}
byte[] buff;
if (small != null) {
buff = small;
} else {
buff = IOUtils.readBytesAndClose(getInputStream(), len);
}
return StringUtils.convertBytesToHex(buff);
} catch (IOException e) {
throw DbException.convertIOException(e, fileName);
}
}
示例2: getString
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision;
try {
if (type == Value.CLOB) {
if (small != null) {
return new String(small, Constants.UTF8);
}
return IOUtils.readStringAndClose(getReader(), len);
}
byte[] buff;
if (small != null) {
buff = small;
} else {
buff = IOUtils.readBytesAndClose(getInputStream(), len);
}
return StringUtils.convertBytesToHex(buff);
} catch (IOException e) {
throw DbException.convertIOException(e, toString());
}
}
示例3: quoteBytes
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* Format a byte array to the Java source code that represents this object.
*
* @param x the byte array to convert
* @return the Java source code
*/
protected static String quoteBytes(byte[] x) {
if (x == null) {
return "null";
}
return "org.h2.util.StringUtils.convertHexToBytes(\"" +
StringUtils.convertBytesToHex(x) + "\")";
}
示例4: getSQL
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getSQL() {
String s;
if (type == Value.CLOB) {
s = getString();
return StringUtils.quoteStringSQL(s);
}
byte[] buff = getBytes();
s = StringUtils.convertBytesToHex(buff);
return "X'" + s + "'";
}
示例5: getSQL
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getSQL() {
// WKT does not hold Z or SRID with JTS 1.13. As getSQL is used to
// export database, it should contains all object attributes. Moreover
// using bytes is faster than converting WKB to Geometry then to WKT.
return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'::Geometry";
}
示例6: dumpLobMaps
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void dumpLobMaps(PrintWriter writer, MVStore mv) {
lobMaps = mv.hasMap("lobData");
if (!lobMaps) {
return;
}
MVMap<Long, byte[]> lobData = mv.openMap("lobData");
StreamStore streamStore = new StreamStore(lobData);
MVMap<Long, Object[]> lobMap = mv.openMap("lobMap");
writer.println("-- LOB");
writer.println("CREATE TABLE IF NOT EXISTS " +
"INFORMATION_SCHEMA.LOB_BLOCKS(" +
"LOB_ID BIGINT, SEQ INT, DATA BINARY, " +
"PRIMARY KEY(LOB_ID, SEQ));");
for (Entry<Long, Object[]> e : lobMap.entrySet()) {
long lobId = e.getKey();
Object[] value = e.getValue();
byte[] streamStoreId = (byte[]) value[0];
InputStream in = streamStore.get(streamStoreId);
int len = 8 * 1024;
byte[] block = new byte[len];
try {
for (int seq = 0;; seq++) {
int l = IOUtils.readFully(in, block, block.length);
String x = StringUtils.convertBytesToHex(block, l);
if (l > 0) {
writer.println("INSERT INTO INFORMATION_SCHEMA.LOB_BLOCKS " +
"VALUES(" + lobId + ", " + seq + ", '" + x + "');");
}
if (l != len) {
break;
}
}
} catch (IOException ex) {
writeError(writer, ex);
}
}
}
示例7: checkCollision
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void checkCollision(String path, long length, byte[] hash) {
if (length < MIN_SIZE) {
return;
}
String s = StringUtils.convertBytesToHex(hash);
String old = hashes.get(s);
if (old != null) {
System.out.println("Collision: " + old + "\n" + path + "\n");
} else {
hashes.put(s, path);
}
}
示例8: testConnectWithHash
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static void testConnectWithHash() throws SQLException {
Connection conn = DriverManager.getConnection(
"jdbc:h2:mem:test", "sa", "sa");
String pwd = StringUtils.convertBytesToHex(
SHA256.getKeyPasswordHash("SA", "sa".toCharArray()));
Connection conn2 = DriverManager.getConnection(
"jdbc:h2:mem:test;PASSWORD_HASH=TRUE", "sa", pwd);
conn.close();
conn2.close();
}
示例9: getHashString
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private String getHashString(byte[] data) {
byte[] result = SHA256.getHash(data, true);
if (data.length > 0) {
assertEquals(0, data[0]);
}
return StringUtils.convertBytesToHex(result);
}
示例10: getSQL
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getSQL() {
return "X'" + StringUtils.convertBytesToHex(getBytesNoCopy()) + "'";
}
示例11: getString
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getString() {
return StringUtils.convertBytesToHex(value);
}
示例12: quoteSQL
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* INTERNAL.
* Convert an object to a String as used in a SQL statement.
*
* @param data the object
* @param type the SQL type
* @return the SQL String
*/
protected static String quoteSQL(Object data, int type) throws SQLException {
if (data == null) {
return "NULL";
}
switch (type) {
case Types.BIT:
case Types.BOOLEAN:
case Types.INTEGER:
case Types.BIGINT:
case Types.DECIMAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.NUMERIC:
case Types.REAL:
case Types.SMALLINT:
case Types.TINYINT:
return data.toString();
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.LONGVARCHAR:
case Types.CHAR:
case Types.VARCHAR:
return quoteString(data.toString());
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.BINARY:
if (data instanceof UUID) {
return "'" + data.toString() + "'";
}
return "'" + StringUtils.convertBytesToHex((byte[]) data) + "'";
case Types.CLOB:
case Types.JAVA_OBJECT:
case Types.OTHER:
case Types.BLOB:
case Types.STRUCT:
case Types.REF:
case Types.NULL:
case Types.ARRAY:
case Types.DATALINK:
case Types.DISTINCT:
throw throwException("Unsupported key data type: " + type);
default:
return "";
}
}
示例13: generateSessionId
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static String generateSessionId() {
byte[] buff = MathUtils.secureRandomBytes(16);
return StringUtils.convertBytesToHex(buff);
}
示例14: setUniqueId
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void setUniqueId() {
byte[] bytes = MathUtils.secureRandomBytes(RANDOM_BYTES);
String random = StringUtils.convertBytesToHex(bytes);
uniqueId = Long.toHexString(System.currentTimeMillis()) + random;
properties.setProperty("id", uniqueId);
}
示例15: printKeystore
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static void printKeystore(KeyStore store, String password)
throws KeyStoreException, NoSuchAlgorithmException,
UnrecoverableKeyException, CertificateEncodingException {
System.out.println("KeyStore store = KeyStore.getInstance(\""
+ store.getType() + "\");");
System.out.println("store.load(null, password.toCharArray());");
// System.out.println("keystore provider=" +
// store.getProvider().getName());
Enumeration<String> en = store.aliases();
while (en.hasMoreElements()) {
String alias = en.nextElement();
Key key = store.getKey(alias, password.toCharArray());
System.out.println(
"KeyFactory keyFactory = KeyFactory.getInstance(\""
+ key.getAlgorithm() + "\");");
System.out.println("store.load(null, password.toCharArray());");
String pkFormat = key.getFormat();
String encoded = StringUtils.convertBytesToHex(key.getEncoded());
System.out.println(
pkFormat + "EncodedKeySpec keySpec = new "
+ pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));");
System.out.println(
"PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = {");
for (Certificate cert : store.getCertificateChain(alias)) {
System.out.println(
" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = StringUtils.convertBytesToHex(cert.getEncoded());
System.out.println(
" generateCertificate(new ByteArrayInputStream(getBytes(\""
+ enc + "\"))),");
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" pubKey algorithm=" +
// pubKey.getAlgorithm());
// System.out.println(" pubKey format=" +
// pubKey.getFormat());
// System.out.println(" pubKey format="+
// Utils.convertBytesToString(pubKey.getEncoded()));
}
System.out.println("};");
System.out.println("store.setKeyEntry(\"" + alias
+ "\", privateKey, password.toCharArray(), certs);");
}
}