private void appendKeyCondition(StatementBuilder buff) { buff.append(" WHERE "); buff.resetCount(); for (String k : key) { buff.appendExceptFirst(" AND "); buff.append(StringUtils.quoteIdentifier(k)).append("=?"); } }
/** * Check if the file password hash is correct. * * @param testCipher the cipher algorithm * @param testHash the hash code * @return true if the cipher algorithm and the password match */ boolean validateFilePasswordHash(String testCipher, byte[] testHash) { if (!StringUtils.equals(testCipher, dbSettings.cipher)) { return false; } return Utils.compareSecure(testHash, dbSettings.filePasswordHash); }
@Override public String getSQL(boolean isDistributed) { if (table == null) { return "*"; } return StringUtils.quoteIdentifier(table) + ".*"; }
@Override public void call() throws IOException { IOUtils.copy(in, out); } }.execute();
static long getFilePos(int offset) { long filePos = offset + CHUNK_HEADER_SIZE; if (filePos < 0) { throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT, "Negative position {0}", filePos); } return filePos; }
/** * Constructs an instance of the given class, which must have a no-arg or default constructor. * @param classname Fully qualified classname. * @param readable Descriptive noun for the role the class plays. * @throws ConfigException If the class cannot be found. */ public static <T> T construct(String classname, String readable) throws ConfigException { Class<T> cls = Utils.classForName(classname, readable); return construct(cls, classname, readable); }
/** * In a string, replace block comment marks with /++ .. ++/. * * @param sql the string * @return the resulting string */ public static String quoteRemarkSQL(String sql) { sql = replaceAll(sql, "*/", "++/"); return replaceAll(sql, "/*", "/++"); }
@Override public Object getObject() { if (javaObject == null) { javaObject = Utils.deserialize(value); } return javaObject; }
@Override public SmallLRUCache<String, String[]> getLobFileListCache() { if (lobFileListCache == null) { lobFileListCache = SmallLRUCache.newInstance(128); } return lobFileListCache; }
/** * 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.lealone.util.StringUtils.convertHexToBytes(\"" + StringUtils.convertBytesToHex(x) + "\")"; }
/** * Creates an XML attribute of the form name="value". * A single space is prepended to the name, * so that multiple attributes can be concatenated. * @param name the attribute name * @param value the attribute value * @return the attribute */ public static String xmlAttr(String name, String value) { return " " + name + "=\"" + xmlText(value) + "\""; }
/** * Create an XML node with optional attributes and content. * The data is indented with 4 spaces if it contains a newline character. * * @param name the element name * @param attributes the attributes (may be null) * @param content the content (may be null) * @return the node */ public static String xmlNode(String name, String attributes, String content) { return xmlNode(name, attributes, content, true); }
/** * To underscore from camel case using digits compressed true and force upper case false. */ public static String toUnderscoreFromCamel(String camelCase) { return toUnderscoreFromCamel(camelCase, true, false); }
@Override public byte[] getBytesNoCopy() { if (value == null) { value = Utils.serialize(javaObject); } return value; }
@Override protected int compareSecure(Value o, CompareMode mode) { if (o == this) { return 0; } ValueUuid v = (ValueUuid) o; if (high == v.high) { return MathUtils.compareLong(low, v.low); } return high > v.high ? 1 : -1; }
/** * Automatically delete the file once it is no longer in use. */ public void autoDelete() { if (autoDeleteReference == null) { autoDeleteReference = tempFileDeleter.addFile(name, this); } }
/** * Copy all data from the input stream to the output stream. Both streams * are kept open. * * @param in the input stream * @param out the output stream (null if writing is not required) * @return the number of bytes copied */ public static long copy(InputStream in, OutputStream out) throws IOException { return copy(in, out, Long.MAX_VALUE); }
private void checkOpen() { if (closed) { throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED, "This storage is closed", panicException); } }