diff --git a/modules/org.jkiss.utils/.classpath b/modules/org.jkiss.utils/.classpath
deleted file mode 100644
index b1dabee38291b97f08cc3a18bee4e65b1e550530..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/modules/org.jkiss.utils/.project b/modules/org.jkiss.utils/.project
deleted file mode 100644
index 6e1e2aff8644d947dfa46ba49d3b359c5dc0f836..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.jkiss.utils
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/modules/org.jkiss.utils/.settings/org.eclipse.jdt.core.prefs b/modules/org.jkiss.utils/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index ace45ceefb456b3fa957d31f9c54df016ce54e53..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/modules/org.jkiss.utils/META-INF/MANIFEST.MF b/modules/org.jkiss.utils/META-INF/MANIFEST.MF
deleted file mode 100644
index 4536d4460a1cfd6c665a1456cc8bd8bd8d0575f8..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,12 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name
-Bundle-SymbolicName: org.jkiss.utils
-Bundle-Version: 2.1.51
-Bundle-Release-Date: 20171030
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.jkiss.code,
- org.jkiss.utils,
- org.jkiss.utils.time,
- org.jkiss.utils.xml
-Bundle-Vendor: %Bundle-Vendor
diff --git a/modules/org.jkiss.utils/OSGI-INF/l10n/bundle.properties b/modules/org.jkiss.utils/OSGI-INF/l10n/bundle.properties
deleted file mode 100644
index c48d0cb4e99faff49ee414d5a86a82bfe355d51c..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/OSGI-INF/l10n/bundle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Properties file for org.jkiss.utils
-Bundle-Vendor = JKISS
-Bundle-Name = JKISS Utils
diff --git a/modules/org.jkiss.utils/build.properties b/modules/org.jkiss.utils/build.properties
deleted file mode 100644
index c58ea2178c3c8c54dccccca56ad435a7b073b474..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- OSGI-INF/
diff --git a/modules/org.jkiss.utils/pom.xml b/modules/org.jkiss.utils/pom.xml
deleted file mode 100644
index 3e46c069ff112d3a96e6b26691abd36a373a1cf3..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/pom.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- 4.0.0
-
- org.jkiss.dbeaver
- dbeaver
- 1.0.0
- ../../
-
- org.jkiss.utils
- 2.1.51
- eclipse-plugin
-
diff --git a/modules/org.jkiss.utils/src/org/jkiss/code/NotNull.java b/modules/org.jkiss.utils/src/org/jkiss/code/NotNull.java
deleted file mode 100644
index 6659992fc302c938024e0f7b076b7a002dc27986..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/code/NotNull.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.code;
-
-/**
- * NotNull annotation
- */
-public @interface NotNull {
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/code/Nullable.java b/modules/org.jkiss.utils/src/org/jkiss/code/Nullable.java
deleted file mode 100644
index b41c31e6e3d41a22f1135b73b4819579c6d9ee55..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/code/Nullable.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.code;
-
-/**
- * Nullable annotation
- */
-public @interface Nullable {
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/ArgumentTokenizer.java b/modules/org.jkiss.utils/src/org/jkiss/utils/ArgumentTokenizer.java
deleted file mode 100644
index 46e12bd0d03d7d590b26124c969a9a34a32fa4f7..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/ArgumentTokenizer.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software is Open Source Initiative approved Open Source Software.
- * Open Source Initative Approved is a trademark of the Open Source Initiative.
- *
- * This file is part of DrJava. Download the current version of this project
- * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
- */
-
-package org.jkiss.utils;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Utility class which can tokenize a String into a list of String arguments,
- * with behavior similar to parsing command line arguments to a program.
- * Quoted Strings are treated as single arguments, and escaped characters
- * are translated so that the tokenized arguments have the same meaning.
- * Since all methods are static, the class is declared abstract to prevent
- * instantiation.
- *
- * @version $Id$
- */
-public abstract class ArgumentTokenizer {
- private static final int NO_TOKEN_STATE = 0;
- private static final int NORMAL_TOKEN_STATE = 1;
- private static final int SINGLE_QUOTE_STATE = 2;
- private static final int DOUBLE_QUOTE_STATE = 3;
-
- /**
- * Tokenizes the given String into String tokens
- *
- * @param arguments A String containing one or more command-line style arguments to be tokenized.
- * @return A list of parsed and properly escaped arguments.
- */
- public static List tokenize(String arguments) {
- return tokenize(arguments, false);
- }
-
- /**
- * Tokenizes the given String into String tokens.
- *
- * @param arguments A String containing one or more command-line style arguments to be tokenized.
- * @param stringify whether or not to include escape special characters
- * @return A list of parsed and properly escaped arguments.
- */
- public static List tokenize(String arguments, boolean stringify) {
-
- LinkedList argList = new LinkedList();
- StringBuilder currArg = new StringBuilder();
- boolean escaped = false;
- int state = NO_TOKEN_STATE; // start in the NO_TOKEN_STATE
- int len = arguments.length();
-
- // Loop over each character in the string
- for (int i = 0; i < len; i++) {
- char c = arguments.charAt(i);
- if (escaped) {
- // Escaped state: just append the next character to the current arg.
- escaped = false;
- if (c != 'n' && c != 't' && c != '\\') {
- // This was just a regular slash
- currArg.append('\\');
- }
- currArg.append(c);
- } else {
- switch (state) {
- case SINGLE_QUOTE_STATE:
- if (c == '\'') {
- // Seen the close quote; continue this arg until whitespace is seen
- state = NORMAL_TOKEN_STATE;
- } else {
- currArg.append(c);
- }
- break;
- case DOUBLE_QUOTE_STATE:
- if (c == '"') {
- // Seen the close quote; continue this arg until whitespace is seen
- state = NORMAL_TOKEN_STATE;
- } else if (c == '\\') {
- // Look ahead, and only escape quotes or backslashes
- i++;
- char next = arguments.charAt(i);
- if (next == '"' || next == '\\') {
- currArg.append(next);
- } else {
- currArg.append(c);
- currArg.append(next);
- }
- } else {
- currArg.append(c);
- }
- break;
-// case NORMAL_TOKEN_STATE:
-// if (Character.isWhitespace(c)) {
-// // Whitespace ends the token; start a new one
-// argList.add(currArg.toString());
-// currArg = new StringBuffer();
-// state = NO_TOKEN_STATE;
-// }
-// else if (c == '\\') {
-// // Backslash in a normal token: escape the next character
-// escaped = true;
-// }
-// else if (c == '\'') {
-// state = SINGLE_QUOTE_STATE;
-// }
-// else if (c == '"') {
-// state = DOUBLE_QUOTE_STATE;
-// }
-// else {
-// currArg.append(c);
-// }
-// break;
- case NO_TOKEN_STATE:
- case NORMAL_TOKEN_STATE:
- switch (c) {
- case '\\':
- escaped = true;
- state = NORMAL_TOKEN_STATE;
- break;
- case '\'':
- state = SINGLE_QUOTE_STATE;
- break;
- case '"':
- state = DOUBLE_QUOTE_STATE;
- break;
- default:
- if (!Character.isWhitespace(c)) {
- currArg.append(c);
- state = NORMAL_TOKEN_STATE;
- } else if (state == NORMAL_TOKEN_STATE) {
- // Whitespace ends the token; start a new one
- argList.add(currArg.toString());
- currArg = new StringBuilder();
- state = NO_TOKEN_STATE;
- }
- }
- break;
- default:
- throw new IllegalStateException("ArgumentTokenizer state " + state + " is invalid!");
- }
- }
- }
-
- // If we're still escaped, put in the backslash
- if (escaped) {
- currArg.append('\\');
- argList.add(currArg.toString());
- }
- // Close the last argument if we haven't yet
- else if (state != NO_TOKEN_STATE) {
- argList.add(currArg.toString());
- }
- // Format each argument if we've been told to stringify them
- if (stringify) {
- for (int i = 0; i < argList.size(); i++) {
- argList.set(i, "\"" + _escapeQuotesAndBackslashes(argList.get(i)) + "\"");
- }
- }
- return argList;
- }
-
- /**
- * Inserts backslashes before any occurrences of a backslash or
- * quote in the given string. Also converts any special characters
- * appropriately.
- */
- protected static String _escapeQuotesAndBackslashes(String s) {
- final StringBuilder buf = new StringBuilder(s);
-
- // Walk backwards, looking for quotes or backslashes.
- // If we see any, insert an extra backslash into the buffer at
- // the same index. (By walking backwards, the index into the buffer
- // will remain correct as we change the buffer.)
- for (int i = s.length() - 1; i >= 0; i--) {
- char c = s.charAt(i);
- if ((c == '\\') || (c == '"')) {
- buf.insert(i, '\\');
- }
- // Replace any special characters with escaped versions
- else if (c == '\n') {
- buf.deleteCharAt(i);
- buf.insert(i, "\\n");
- } else if (c == '\t') {
- buf.deleteCharAt(i);
- buf.insert(i, "\\t");
- } else if (c == '\r') {
- buf.deleteCharAt(i);
- buf.insert(i, "\\r");
- } else if (c == '\b') {
- buf.deleteCharAt(i);
- buf.insert(i, "\\b");
- } else if (c == '\f') {
- buf.deleteCharAt(i);
- buf.insert(i, "\\f");
- }
- }
- return buf.toString();
- }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/ArrayUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/ArrayUtils.java
deleted file mode 100644
index 97cf6eb8618448aa2d37eefa052835d4d1bfae71..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/ArrayUtils.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils;
-
-import org.jkiss.code.NotNull;
-import org.jkiss.code.Nullable;
-
-import java.lang.reflect.Array;
-import java.util.*;
-
-/**
- * Common utils
- */
-public class ArrayUtils {
-
-
- public static boolean isEmpty(@Nullable Object[] arr)
- {
- return arr == null || arr.length == 0;
- }
-
- public static boolean isEmpty(@Nullable short[] array)
- {
- return array == null || array.length == 0;
- }
-
- public static boolean contains(@Nullable short[] array, short value)
- {
- if (array == null)
- return false;
- for (int i = 0, arrayLength = array.length; i < arrayLength; i++) {
- if (array[i] == value)
- return true;
- }
- return false;
- }
-
- public static boolean contains(@Nullable char[] array, char value)
- {
- if (array == null || array.length == 0)
- return false;
- for (int i = 0, arrayLength = array.length; i < arrayLength; i++) {
- if (array[i] == value)
- return true;
- }
- return false;
- }
-
- public static boolean isEmpty(@Nullable int[] array)
- {
- return array == null || array.length == 0;
- }
-
- public static boolean contains(@Nullable int[] array, int value)
- {
- if (array == null)
- return false;
- for (int v : array) {
- if (v == value)
- return true;
- }
- return false;
- }
-
- public static boolean isEmpty(@Nullable long[] array)
- {
- return array == null || array.length == 0;
- }
-
- public static boolean contains(@Nullable long[] array, long value)
- {
- if (array == null)
- return false;
- for (long v : array) {
- if (v == value)
- return true;
- }
- return false;
- }
-
- public static boolean contains(OBJECT_TYPE[] array, OBJECT_TYPE value)
- {
- if (isEmpty(array))
- return false;
- for (int i = 0; i < array.length; i++) {
- if (CommonUtils.equalObjects(value, array[i]))
- return true;
- }
- return false;
- }
-
- public static boolean containsIgnoreCase(String[] array, String value)
- {
- if (isEmpty(array) || value == null)
- return false;
- for (int i = 0; i < array.length; i++) {
- if (value.equalsIgnoreCase(array[i]))
- return true;
- }
- return false;
- }
-
- public static boolean containsRef(@NotNull OBJECT_TYPE[] array, @Nullable OBJECT_TYPE value)
- {
- final int length = array.length;
- for (int i = 0; i < length; i++) {
- if (value == array[i])
- return true;
- }
- return false;
- }
-
- @SafeVarargs
- public static boolean contains(OBJECT_TYPE[] array, OBJECT_TYPE... values)
- {
- if (isEmpty(array))
- return false;
- for (int i = 0; i < array.length; i++) {
- for (int k = 0; k < values.length; k++) {
- if (CommonUtils.equalObjects(array[i], values[k]))
- return true;
- }
- }
- return false;
- }
-
- @NotNull
- public static T[] concatArrays(@NotNull T[] first, @NotNull T[] second)
- {
- T[] result = Arrays.copyOf(first, first.length + second.length);
- System.arraycopy(second, 0, result, first.length, second.length);
- return result;
- }
-
- @NotNull
- public static List safeArray(@Nullable T[] array)
- {
- if (array == null) {
- return Collections.emptyList();
- } else {
- return Arrays.asList(array);
- }
- }
-
- public static int indexOf(T[] array, T element) {
- for (int i = 0; i < array.length; i++) {
- if (CommonUtils.equalObjects(array[i], element)) {
- return i;
- }
- }
- return -1;
- }
-
- public static int indexOf(byte[] array, int offset, byte element) {
- for (int i = offset; i < array.length; i++) {
- if (array[i] == element) {
- return i;
- }
- }
- return -1;
- }
-
- @SuppressWarnings("unchecked")
- public static T[] deleteArea(Class type, T[] elements, int from, int to) {
- int delCount = to - from + 1;
- T[] newArray = (T[]) Array.newInstance(type, elements.length - delCount);
- System.arraycopy(elements, 0, newArray, 0, from);
- if (to < elements.length - 1) {
- System.arraycopy(elements, to + 1, newArray, from, elements.length - from - delCount);
- }
-
- return newArray;
- }
-
- @SuppressWarnings("unchecked")
- public static T[] insertArea(Class type, Object[] elements, int pos, Object[] add) {
- T[] newArray = (T[]) Array.newInstance(type, elements.length + add.length);
- System.arraycopy(elements, 0, newArray, 0, pos);
- System.arraycopy(add, 0, newArray, pos, add.length);
- System.arraycopy(elements, pos, newArray, pos + add.length, elements.length - pos);
- return newArray;
- }
-
- @SuppressWarnings("unchecked")
- public static T[] add(Class type, T[] elements, T add) {
- T[] newArray = (T[]) Array.newInstance(type, elements.length + 1);
- System.arraycopy(elements, 0, newArray, 0, elements.length);
- newArray[elements.length] = add;
- return newArray;
- }
-
- @SuppressWarnings("unchecked")
- public static T[] remove(Class type, T[] elements, int index) {
- T[] newArray = (T[]) Array.newInstance(type, elements.length - 1);
- System.arraycopy(elements, 0, newArray, 0, index);
- if (index < elements.length - 1) {
- System.arraycopy(elements, index + 1, newArray, index, elements.length - index - 1);
- }
- return newArray;
- }
-
- public static T[] remove(Class type, T[] elements, T element) {
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] == element) {
- return remove(type, elements, i);
- }
- }
- return elements;
- }
-
- public static void main(String[] args) {
- String[] arr = new String[0];
-
- for (int i = 0; i < 100; i++) {
- arr = add(String.class, arr, String.valueOf(i));
- }
- System.out.println(Arrays.toString(arr));
- for (int i = 0; i < 100; i++) {
- arr = remove(String.class, arr, 0);
- }
- System.out.println(Arrays.toString(arr));
- }
-
- @SuppressWarnings("unchecked")
- public static T[] toArray(Class type, Collection extends T> list) {
- return list.toArray((T[]) Array.newInstance(type, list.size()));
- }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/Base64.java b/modules/org.jkiss.utils/src/org/jkiss/utils/Base64.java
deleted file mode 100644
index baf04638b5548ae647269f11097d3236fd692291..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/Base64.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-
-public final class Base64 {
-
- private static final char[] S_BASE64CHAR = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
- 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', '/'
- };
-
- private static final char S_BASE64PAD = '=';
-
- private static final byte[] S_DECODETABLE = new byte[128];
-
- static {
- for (int i = 0; i < S_DECODETABLE.length; i ++)
- S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
- for (int i = 0; i < S_BASE64CHAR.length; i ++) // 0 to 63
- S_DECODETABLE[S_BASE64CHAR[i]] = (byte)i;
- }
-
- private static int decode0(char[] ibuf, byte[] obuf, int wp) {
- int outlen = 3;
- if (ibuf[3] == S_BASE64PAD) outlen = 2;
- if (ibuf[2] == S_BASE64PAD) outlen = 1;
- int b0 = S_DECODETABLE[ibuf[0]];
- int b1 = S_DECODETABLE[ibuf[1]];
- int b2 = S_DECODETABLE[ibuf[2]];
- int b3 = S_DECODETABLE[ibuf[3]];
- switch (outlen) {
- case 1:
- obuf[wp] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- return 1;
- case 2:
- obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- return 2;
- case 3:
- default:
- obuf[wp++] = (byte)(b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp++] = (byte)(b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- obuf[wp] = (byte)(b2 << 6 & 0xc0 | b3 & 0x3f);
- return 3;
- }
- }
-
- /**
- *
- */
- public static byte[] decode(char[] data, int off, int len) {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[len/4*3+3];
- int obufcount = 0;
- for (int i = off; i < off+len; i ++) {
- char ch = data[i];
- if (ch == S_BASE64PAD
- || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- obufcount += decode0(ibuf, obuf, obufcount);
- }
- }
- }
- if (obufcount == obuf.length)
- return obuf;
- byte[] ret = new byte[obufcount];
- System.arraycopy(obuf, 0, ret, 0, obufcount);
- return ret;
- }
-
- /**
- *
- */
- public static byte[] decode(String data) {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[data.length()/4*3+3];
- int obufcount = 0;
- for (int i = 0; i < data.length(); i ++) {
- char ch = data.charAt(i);
- if (ch == S_BASE64PAD
- || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- obufcount += decode0(ibuf, obuf, obufcount);
- }
- }
- }
- if (obufcount == obuf.length)
- return obuf;
- byte[] ret = new byte[obufcount];
- System.arraycopy(obuf, 0, ret, 0, obufcount);
- return ret;
- }
-
- /**
- *
- */
- public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[3];
- for (int i = off; i < off+len; i ++) {
- char ch = data[i];
- if (ch == S_BASE64PAD
- || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- int obufcount = decode0(ibuf, obuf, 0);
- ostream.write(obuf, 0, obufcount);
- }
- }
- }
- }
-
- /**
- *
- */
- public static void decode(String data, OutputStream ostream) throws IOException {
- char[] ibuf = new char[4];
- int ibufcount = 0;
- byte[] obuf = new byte[3];
- for (int i = 0; i < data.length(); i ++) {
- char ch = data.charAt(i);
- if (ch == S_BASE64PAD
- || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
- ibuf[ibufcount++] = ch;
- if (ibufcount == ibuf.length) {
- ibufcount = 0;
- int obufcount = decode0(ibuf, obuf, 0);
- ostream.write(obuf, 0, obufcount);
- }
- }
- }
- }
-
- /**
- * Returns base64 representation of specified byte array.
- */
- public static String encode(byte[] data) {
- return encode(data, 0, data.length);
- }
-
- public static String splitLines(String bigString, int lineLength) {
- return bigString.replaceAll("(.{" + lineLength + "})", "$1\n");
- }
-
- /**
- * Returns base64 representation of specified byte array.
- */
- public static String encode(byte[] data, int off, int len)
- {
- if (len <= 0) return "";
- char[] out = new char[len/3*4+4];
- int rindex = off;
- int windex = 0;
- int rest = len-off;
- while (rest >= 3) {
- int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
- out[windex++] = S_BASE64CHAR[i>>18];
- out[windex++] = S_BASE64CHAR[(i>>12)&0x3f];
- out[windex++] = S_BASE64CHAR[(i>>6)&0x3f];
- out[windex++] = S_BASE64CHAR[i&0x3f];
- rindex += 3;
- rest -= 3;
- }
- if (rest == 1) {
- int i = data[rindex]&0xff;
- out[windex++] = S_BASE64CHAR[i>>2];
- out[windex++] = S_BASE64CHAR[(i<<4)&0x3f];
- out[windex++] = S_BASE64PAD;
- out[windex++] = S_BASE64PAD;
- } else if (rest == 2) {
- int i = ((data[rindex]&0xff)<<8)+(data[rindex+1]&0xff);
- out[windex++] = S_BASE64CHAR[i>>10];
- out[windex++] = S_BASE64CHAR[(i>>4)&0x3f];
- out[windex++] = S_BASE64CHAR[(i<<2)&0x3f];
- out[windex++] = S_BASE64PAD;
- }
- return new String(out, 0, windex);
- }
-
- /**
- * Outputs base64 representation of the specified byte array to a byte stream.
- */
- public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
- if (len <= 0) return;
- byte[] out = new byte[4];
- int rindex = off;
- int rest = len-off;
- while (rest >= 3) {
- int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
- out[0] = (byte)S_BASE64CHAR[i>>18];
- out[1] = (byte)S_BASE64CHAR[(i>>12)&0x3f];
- out[2] = (byte)S_BASE64CHAR[(i>>6)&0x3f];
- out[3] = (byte)S_BASE64CHAR[i&0x3f];
- ostream.write(out, 0, 4);
- rindex += 3;
- rest -= 3;
- }
- if (rest == 1) {
- int i = data[rindex]&0xff;
- out[0] = (byte)S_BASE64CHAR[i>>2];
- out[1] = (byte)S_BASE64CHAR[(i<<4)&0x3f];
- out[2] = (byte)S_BASE64PAD;
- out[3] = (byte)S_BASE64PAD;
- ostream.write(out, 0, 4);
- } else if (rest == 2) {
- int i = ((data[rindex]&0xff)<<8)+(data[rindex+1]&0xff);
- out[0] = (byte)S_BASE64CHAR[i>>10];
- out[1] = (byte)S_BASE64CHAR[(i>>4)&0x3f];
- out[2] = (byte)S_BASE64CHAR[(i<<2)&0x3f];
- out[3] = (byte)S_BASE64PAD;
- ostream.write(out, 0, 4);
- }
- }
-
- /**
- * Outputs base64 representation of the specified byte array to a character stream.
- */
- public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
- if (len <= 0) return;
- char[] out = new char[4];
- int rindex = off;
- int rest = len-off;
- while (rest >= 3) {
- int i = ((data[rindex]&0xff)<<16)
- +((data[rindex+1]&0xff)<<8)
- +(data[rindex+2]&0xff);
- out[0] = S_BASE64CHAR[i>>18];
- out[1] = S_BASE64CHAR[(i>>12)&0x3f];
- out[2] = S_BASE64CHAR[(i>>6)&0x3f];
- out[3] = S_BASE64CHAR[i&0x3f];
- writer.write(out, 0, 4);
- rindex += 3;
- rest -= 3;
-/*
- if (output % 76 == 0)
- writer.write("\n");
-*/
- }
- if (rest == 1) {
- int i = data[rindex]&0xff;
- out[0] = S_BASE64CHAR[i>>2];
- out[1] = S_BASE64CHAR[(i<<4)&0x3f];
- out[2] = S_BASE64PAD;
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- } else if (rest == 2) {
- int i = ((data[rindex]&0xff)<<8)+(data[rindex+1]&0xff);
- out[0] = S_BASE64CHAR[i>>10];
- out[1] = S_BASE64CHAR[(i>>4)&0x3f];
- out[2] = S_BASE64CHAR[(i<<2)&0x3f];
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- }
- }
-
- /**
- * Outputs base64 representation of the specified input stream to a character stream.
- */
- public static void encode(InputStream stream, long len, Writer writer)
- throws IOException
- {
- if (len <= 0) return;
- char[] out = new char[4];
- long rest = len;
- while (rest >= 3) {
- int i = ((stream.read()&0xff)<<16)
- +((stream.read()&0xff)<<8)
- +(stream.read()&0xff);
- out[0] = S_BASE64CHAR[i>>18];
- out[1] = S_BASE64CHAR[(i>>12)&0x3f];
- out[2] = S_BASE64CHAR[(i>>6)&0x3f];
- out[3] = S_BASE64CHAR[i&0x3f];
- writer.write(out, 0, 4);
- rest -= 3;
- }
- if (rest == 1) {
- int i = stream.read()&0xff;
- out[0] = S_BASE64CHAR[i>>2];
- out[1] = S_BASE64CHAR[(i<<4)&0x3f];
- out[2] = S_BASE64PAD;
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- } else if (rest == 2) {
- int i = ((stream.read()&0xff)<<8)+(stream.read()&0xff);
- out[0] = S_BASE64CHAR[i>>10];
- out[1] = S_BASE64CHAR[(i>>4)&0x3f];
- out[2] = S_BASE64CHAR[(i<<2)&0x3f];
- out[3] = S_BASE64PAD;
- writer.write(out, 0, 4);
- }
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/BeanUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/BeanUtils.java
deleted file mode 100644
index 55f49aaa6badf78a120e8dd26daa0f7aeb82f57d..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/BeanUtils.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils;
-
-import java.lang.reflect.*;
-import java.util.Collection;
-import java.util.StringTokenizer;
-
-/**
- * BeanUtils
- */
-public class BeanUtils {
-
- public static boolean isGetterName(String name) {
- return name.startsWith("get") || name.startsWith("is") || name.startsWith("has");
- }
-
- public static String getPropertyNameFromGetter(String getterName) {
- if (getterName.startsWith("get")) {
- return
- Character.toLowerCase(getterName.charAt(3)) +
- getterName.substring(4);
- } else if (getterName.startsWith("is")) {
- return
- Character.toLowerCase(getterName.charAt(2)) +
- getterName.substring(3);
- } else if (getterName.startsWith("has")) {
- return
- Character.toLowerCase(getterName.charAt(3)) +
- getterName.substring(4);
- } else {
- // Unrecognized getter name
- return null;
- }
- }
-
- public static String getSetterName(String getterName) {
- if (getterName.startsWith("get")) {
- return "set" + getterName.substring(3);
- } else if (getterName.startsWith("is")) {
- return "set" + getterName.substring(2);
- } else if (getterName.startsWith("has")) {
- return "set" + getterName.substring(3);
- } else {
- // Unrecognized getter name
- return null;
- }
- }
-
- /**
- * Returns a set method matching the property name.
- */
- public static Method getSetMethod(Class> cl, String propertyName) {
- Method method = getSetMethod(cl, propertyName, false);
-
- if (method != null) {
- return method;
- }
-
- return getSetMethod(cl, propertyName, true);
- }
-
- /**
- * Returns a set method matching the property name.
- */
- public static Method getSetMethod(
- Class> cl,
- String propertyName,
- boolean ignoreCase) {
- String setName = "set" + propertyNameToMethodName(propertyName);
-
- return getSetMethod(
- cl.getMethods(),
- setName,
- ignoreCase);
- }
-
- /**
- * Returns a get method matching the property name.
- */
- public static Method getGetMethod(Class> cl, String propertyName) {
- Method method = getGetMethod(cl, propertyName, false);
-
- return method != null ?
- method :
- getGetMethod(cl, propertyName, true);
- }
-
- /**
- * Returns a get method matching the property name.
- */
- public static Method getGetMethod(
- Class> cl,
- String propertyName,
- boolean ignoreCase) {
- String methodName = propertyNameToMethodName(propertyName);
- return getGetMethod(
- cl.getMethods(),
- "get" + methodName,
- "is" + methodName,
- ignoreCase);
- }
-
- /**
- * Converts a user's property name to a bean method name.
- *
- * @param propertyName the user property name
- * @return the equivalent bean method name
- */
- public static String propertyNameToMethodName(String propertyName) {
- char ch = propertyName.charAt(0);
- if (Character.isLowerCase(ch))
- propertyName = Character.toUpperCase(ch) + propertyName.substring(1);
-
- return propertyName;
- }
-
- /**
- * Converts a user's property name to a bean method name.
- *
- * @param methodName the method name
- * @return the equivalent property name
- */
- public static String methodNameToPropertyName(String methodName) {
- if (methodName.startsWith("get"))
- methodName = methodName.substring(3);
- else if (methodName.startsWith("set"))
- methodName = methodName.substring(3);
- else if (methodName.startsWith("is"))
- methodName = methodName.substring(2);
-
- if (methodName.length() == 0)
- return null;
-
- char ch = methodName.charAt(0);
- if (Character.isUpperCase(ch) && (methodName.length() == 1 || !Character.isUpperCase(methodName.charAt(1)))) {
- methodName = Character.toLowerCase(ch) + methodName.substring(1);
- }
-
- return methodName;
- }
-
- public static boolean isArrayType(Type type) {
- return (type instanceof Class && ((Class>) type).isArray());
- }
-
- public static boolean isCollectionType(Type type) {
- if (type instanceof Class && Collection.class.isAssignableFrom((Class>) type)) {
-/*
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType)type;
- if (pt.getActualTypeArguments().length == 1) {
- return true;
- }
- }
-*/
- return true;
- }
- return isArrayType(type);
- }
-
- public static Class> getCollectionType(Type type) {
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
- if (pt.getActualTypeArguments().length == 1) {
- final Type argType = pt.getActualTypeArguments()[0];
- if (argType instanceof Class) {
- return (Class>) argType;
- } else if (argType instanceof WildcardType) {
- final Type[] upperBounds = ((WildcardType) argType).getUpperBounds();
- if (upperBounds.length > 0 && upperBounds[0] instanceof Class) {
- return (Class>) upperBounds[0];
- }
- final Type[] lowerBounds = ((WildcardType) argType).getLowerBounds();
- if (lowerBounds.length > 0 && lowerBounds[0] instanceof Class) {
- return (Class>) lowerBounds[0];
- }
- }
- }
- }
- return null;
- }
-
- public static Object readObjectProperty(Object object, String propName)
- throws IllegalAccessException, InvocationTargetException {
- if (propName.indexOf('.') == -1) {
- Method getter = getGetMethod(object.getClass(), propName);
- return getter == null ? null : getter.invoke(object);
- }
- // Parse property path
- StringTokenizer st = new StringTokenizer(propName, ".");
- Object value = object;
- while (value != null && st.hasMoreTokens()) {
- String pathItem = st.nextToken();
- Method getter = getGetMethod(value.getClass(), pathItem);
- if (getter == null) {
- return null;
- }
- value = getter.invoke(value);
- }
- return value;
- }
-
- /**
- * Finds the matching set method
- */
- private static Method getGetMethod(
- Method[] methods,
- String getName,
- String isName,
- boolean ignoreCase) {
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
-
- // The method must be public
- if (
- (!Modifier.isPublic(method.getModifiers())) ||
- (!Modifier.isPublic(method.getDeclaringClass().getModifiers())) ||
- (method.getParameterTypes().length != 0) ||
- (method.getReturnType().equals(void.class))) {
- continue;
- } else if (!ignoreCase && method.getName().equals(getName)) {
- // If it matches the get name, it's the right method
- return method;
- } else if (ignoreCase && method.getName().equalsIgnoreCase(getName)) {
- // If it matches the get name, it's the right method
- return method;
- } else if (!method.getReturnType().equals(boolean.class)) {
- // The is methods must return boolean
- continue;
- } else if (!ignoreCase && method.getName().equals(isName)) {
- // If it matches the is name, it must return boolean
- return method;
- } else if (ignoreCase && method.getName().equalsIgnoreCase(isName)) {
- // If it matches the is name, it must return boolean
- return method;
- }
- }
-
- return null;
- }
-
- /**
- * Finds the matching set method
- *
- * @param setName the method name
- */
- private static Method getSetMethod(
- Method[] methods,
- String setName,
- boolean ignoreCase) {
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
-
- // The method name must match
- if (
- !(ignoreCase ? method.getName().equalsIgnoreCase(setName) : method.getName().equals(setName)) ||
- !Modifier.isPublic(method.getModifiers()) ||
- !Modifier.isPublic(method.getDeclaringClass().getModifiers()) ||
- method.getParameterTypes().length != 1
- )
- continue;
-
- return method;
- }
-
- return null;
- }
-
- public static final Short DEFAULT_SHORT = (short) 0;
- public static final Integer DEFAULT_INTEGER = 0;
- public static final Long DEFAULT_LONG = 0l;
- public static final Float DEFAULT_FLOAT = new Float(0.0);
- public static final Double DEFAULT_DOUBLE = 0.0;
- public static final Byte DEFAULT_BYTE = (byte) 0;
- public static final Character DEFAULT_CHAR = (char) 0;
-
- public static boolean isBooleanType(Type paramClass) {
- return paramClass == Boolean.class || paramClass == Boolean.TYPE;
- }
-
- public static Object getDefaultPrimitiveValue(Class> paramClass) {
- if (paramClass == Boolean.TYPE) {
- return Boolean.FALSE;
- } else if (paramClass == Short.TYPE) {
- return DEFAULT_SHORT;
- } else if (paramClass == Integer.TYPE) {
- return DEFAULT_INTEGER;
- } else if (paramClass == Long.TYPE) {
- return DEFAULT_LONG;
- } else if (paramClass == Float.TYPE) {
- return DEFAULT_FLOAT;
- } else if (paramClass == Double.TYPE) {
- return DEFAULT_DOUBLE;
- } else if (paramClass == Byte.TYPE) {
- return DEFAULT_BYTE;
- } else if (paramClass == Character.TYPE) {
- return DEFAULT_CHAR;
- } else {
- throw new IllegalArgumentException("Class " + paramClass.getName() + " is not primitive type");
- }
- }
-
- public static boolean isNumericType(Class> paramClass) {
- return
- Number.class.isAssignableFrom(paramClass) ||
- paramClass == Short.TYPE ||
- paramClass == Integer.TYPE ||
- paramClass == Long.TYPE ||
- paramClass == Double.TYPE ||
- paramClass == Float.TYPE ||
- paramClass == Byte.TYPE;
- }
-
- public static Object invokeObjectMethod(Object object, String name, Class> paramTypes[], Object args[])
- throws Throwable {
- Method method = object.getClass().getMethod(name, paramTypes);
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- try {
- return method.invoke(object, args);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
-
- public static Object invokeObjectMethod(Object object, String name)
- throws Throwable {
- Method method = object.getClass().getMethod(name);
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- try {
- return method.invoke(object);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
-
- public static Object invokeStaticMethod(Class> objectType, String name, Class> paramTypes[], Object args[])
- throws Throwable {
- Method method = objectType.getMethod(name, paramTypes);
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- try {
- return method.invoke(null, args);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java
deleted file mode 100644
index e7ea01adab88f500f8ed2d6c101c59381d0643ee..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils;
-
-import org.jkiss.code.NotNull;
-import org.jkiss.code.Nullable;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-/**
- * Common utils
- */
-public class CommonUtils {
-
- public static boolean isJavaIdentifier(@NotNull CharSequence str) {
- for (int i = 0; i < str.length(); i++) {
- if (!Character.isJavaIdentifierPart(str.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
- @NotNull
- public static String escapeJavaString(@NotNull String str) {
- StringBuilder res = new StringBuilder(str.length() + 5);
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- switch (c) {
- case '"':
- res.append("\\\"");
- break;
- case '\n':
- res.append("\\n");
- break;
- case '\r':
- res.append("\\r");
- break;
- case '\t':
- res.append("\\t");
- break;
- default:
- res.append(c);
- break;
- }
- }
- return res.toString();
- }
-
- @Nullable
- public static String escapeIdentifier(@Nullable String str) {
- if (str == null) {
- return null;
- }
- StringBuilder res = new StringBuilder(str.length());
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- if (Character.isJavaIdentifierPart(c)) {
- res.append(c);
- } else {
- if (res.length() == 0 || res.charAt(res.length() - 1) != '_') {
- res.append('_');
- }
- }
- }
- return res.toString();
- }
-
- @Nullable
- public static String escapeFileName(@Nullable String str) {
- if (str == null) {
- return null;
- }
- StringBuilder res = new StringBuilder(str.length());
- for (int i = 0; i < str.length(); i++) {
- char c = str.charAt(i);
- if (Character.isISOControl(c) || c == '\\' || c == '/' || c == '<' || c == '>' || c == '|' || c == '"' || c == ':'
- || c == '*' || c == '?') {
- res.append('_');
- } else {
- res.append(c);
- }
- }
- return res.toString();
- }
-
- public static String makeDirectoryName(@NotNull String str) {
- if (!str.endsWith("/")) {
- str += "/";
- }
- return str;
- }
-
- @NotNull
- public static String removeTrailingSlash(@NotNull String str) {
- while (str.endsWith("/") || str.endsWith("\\")) {
- str = str.substring(0, str.length() - 1);
- }
- return str;
- }
-
- public static String capitalizeWord(String str) {
- if (isEmpty(str) || Character.isUpperCase(str.charAt(0))) {
- return str;
- }
- return Character.toUpperCase(str.charAt(0)) + str.substring(1);
- }
-
- @NotNull
- public static T notNull(@Nullable T value, @NotNull T defaultValue) {
- return value != null ? value : defaultValue;
- }
-
- public static boolean isEmpty(@Nullable CharSequence value) {
- return value == null || value.length() == 0;
- }
-
- public static boolean isEmpty(@Nullable String value) {
- return value == null || value.length() == 0;
- }
-
- public static boolean isNotEmpty(@Nullable String value) {
- return !isEmpty(value);
- }
-
- public static boolean isEmpty(@Nullable Collection> value) {
- return value == null || value.isEmpty();
- }
-
- public static boolean isEmpty(@Nullable Map, ?> value) {
- return value == null || value.isEmpty();
- }
-
- @NotNull
- public static Collection safeCollection(@Nullable Collection theList) {
- if (theList == null) {
- theList = Collections.emptyList();
- }
- return theList;
- }
-
- @NotNull
- public static List safeList(@Nullable List theList) {
- if (theList == null) {
- theList = Collections.emptyList();
- }
- return theList;
- }
-
- @NotNull
- public static List copyList(@Nullable Collection theList) {
- if (theList == null) {
- return new ArrayList<>();
- } else {
- return new ArrayList<>(theList);
- }
- }
-
- @NotNull
- public static String notEmpty(@Nullable String value) {
- return value == null ? "" : value;
- }
-
- public static boolean isTrue(Boolean value) {
- return value != null && value;
- }
-
- public static boolean getBoolean(String value) {
- return Boolean.parseBoolean(value);
- }
-
- public static boolean getBoolean(@Nullable String value, boolean defaultValue) {
- return isEmpty(value) ? defaultValue : Boolean.parseBoolean(value);
- }
-
- public static boolean getBoolean(@Nullable Object value, boolean defaultValue) {
- if (value == null) {
- return defaultValue;
- } else if (value instanceof Boolean) {
- return (Boolean) value;
- } else {
- return getBoolean(value.toString(), defaultValue);
- }
- }
-
- @NotNull
- public static String getLineSeparator() {
- String lineSeparator = System.getProperty(StandardConstants.ENV_LINE_SEPARATOR);
- return lineSeparator == null ? "\n" : lineSeparator;
- }
-
- @NotNull
- public static Throwable getRootCause(@NotNull Throwable ex) {
- Throwable rootCause = ex;
- for (; ; ) {
- if (rootCause.getCause() != null) {
- rootCause = rootCause.getCause();
- } else if (rootCause instanceof InvocationTargetException
- && ((InvocationTargetException) rootCause).getTargetException() != null) {
- rootCause = ((InvocationTargetException) rootCause).getTargetException();
- } else {
- break;
- }
- }
- return rootCause;
- }
-
- public static boolean equalObjects(@Nullable Object o1, @Nullable Object o2) {
- if (o1 == o2) {
- return true;
- }
- if (o1 == null || o2 == null) {
- return false;
- }
-// if (o1.getClass() != o2.getClass()) {
-// return false;
-// }
- return o1.equals(o2);
- }
-
- @NotNull
- public static String toString(@Nullable Object object) {
- if (object == null) {
- return "";
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return object.toString();
- }
- }
-
- public static String toString(@Nullable Object object, String def) {
- if (object == null) {
- return def;
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return object.toString();
- }
- }
-
- public static boolean toBoolean(@Nullable Object object) {
- return object != null && getBoolean(object.toString());
- }
-
- public static int toInt(@Nullable Object object, int def) {
- if (object == null) {
- return def;
- } else if (object instanceof Number) {
- return ((Number) object).intValue();
- } else {
- try {
- return Integer.parseInt(toString(object));
- } catch (NumberFormatException e) {
- return def;
- }
- }
- }
-
- public static int toInt(@Nullable Object object) {
- return toInt(object, 0);
- }
-
- public static boolean isInt(@Nullable Object object) {
- if (object == null) {
- return false;
- } else if (object instanceof Number) {
- return true;
- } else {
- try {
- Integer.parseInt(toString(object));
- return true;
- } catch (NumberFormatException e) {
- return false;
- }
- }
- }
-
- public static long toLong(@Nullable Object object) {
- if (object == null) {
- return 0;
- } else if (object instanceof Number) {
- return ((Number) object).longValue();
- } else {
- try {
- return Long.parseLong(toString(object));
- } catch (NumberFormatException e) {
- return -1;
- }
- }
- }
-
- public static boolean isLong(@Nullable Object object) {
- if (object == null) {
- return false;
- } else if (object instanceof Number) {
- return true;
- } else {
- try {
- Long.parseLong(toString(object));
- return true;
- } catch (NumberFormatException e) {
- return false;
- }
- }
- }
-
- @NotNull
- public static String toHexString(@Nullable byte[] bytes) {
- return bytes == null ? "" : toHexString(bytes, 0, bytes.length);
- }
-
- final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
-
- @NotNull
- public static String toHexString(@Nullable byte[] bytes, int offset, int length) {
- if (bytes == null || bytes.length == 0) {
- return "";
- }
- char[] hexChars = new char[length * 2];
- for (int i = 0; i < length; i++) {
- int v = bytes[offset + i] & 0xFF;
- hexChars[i * 2] = hexArray[v >>> 4];
- hexChars[i * 2 + 1] = hexArray[v & 0x0F];
- }
- return new String(hexChars);
- }
-
- public static String toBinaryString(long longValue, int bitCount) {
- String strValue = Long.toString(longValue, 2);
- if (strValue.length() < bitCount) {
- char[] headZeroes = new char[bitCount - strValue.length()];
- Arrays.fill(headZeroes, '0');
- strValue = String.valueOf(headZeroes) + strValue;
- }
- return strValue;
- }
-
- @NotNull
- public static List splitString(@Nullable String str, char delimiter) {
- if (CommonUtils.isEmpty(str)) {
- return Collections.emptyList();
- } else {
- List result = new ArrayList<>();
- StringTokenizer st = new StringTokenizer(str, String.valueOf(delimiter));
- while (st.hasMoreTokens()) {
- result.add(st.nextToken());
- }
- return result;
- }
- }
-
- @NotNull
- public static String makeString(@Nullable List tokens, char delimiter) {
- if (tokens == null) {
- return "";
- } else if (tokens.size() == 1) {
- return tokens.get(0);
- } else {
- StringBuilder buf = new StringBuilder();
- for (String token : tokens) {
- if (buf.length() > 0) {
- buf.append(delimiter);
- }
- buf.append(token);
- }
- return buf.toString();
- }
- }
-
- @Nullable
- public static String truncateString(@Nullable String str, int maxLength) {
- if (str != null && str.length() > maxLength) {
- return str.substring(0, maxLength);
- }
- return str;
- }
-
- public static String joinStrings(String divider, String ... array) {
- if (array == null) return "";
- StringBuilder str = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- if (i > 0) str.append(divider);
- str.append(array[i]);
- }
- return str.toString();
- }
-
- public static String joinStrings(String divider, Collection col) {
- if (col == null) return "";
- StringBuilder str = new StringBuilder();
- for (String item : col) {
- if (str.length() > 0) str.append(divider);
- str.append(item);
- }
- return str.toString();
- }
-
- public static boolean isEmptyTrimmed(@Nullable String str) {
- return str == null || str.length() == 0 || str.trim().length() == 0;
- }
-
- public static boolean isBitSet(int value, int mask) {
- return (value & mask) == mask;
- }
-
- @Nullable
- public static > T valueOf(@NotNull Class type, @Nullable String name) {
- return valueOf(type, name, false);
- }
-
- @Nullable
- public static > T valueOf(@Nullable Class type, @Nullable String name, boolean underscoreSpaces) {
- if (name == null) {
- return null;
- }
- name = name.trim();
- if (name.length() == 0) {
- return null;
- }
- if (underscoreSpaces) {
- name = name.replace(' ', '_');
- }
- try {
- return Enum.valueOf(type, name);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- @NotNull
- public static T getItem(@NotNull Collection collection, int index) {
- if (collection instanceof List) {
- return ((List) collection).get(index);
- } else {
- Iterator iter = collection.iterator();
- for (int i = 0; i < index; i++) {
- iter.next();
- }
- return iter.next();
- }
- }
-
- @NotNull
- public static > T fromOrdinal(Class enumClass, int ordinal) {
- T[] enumConstants = enumClass.getEnumConstants();
- for (T value : enumConstants) {
- if (value.ordinal() == ordinal) {
- return value;
- }
- }
- IllegalArgumentException error = new IllegalArgumentException("Invalid ordinal " + ordinal + " for type " + enumClass.getName());
- if (enumConstants.length == 0) {
- throw error;
- } else {
- error.printStackTrace(System.err);
- return enumConstants[0];
- }
- }
-
- @NotNull
- public static List filterCollection(@NotNull Collection> collection, @NotNull Class type) {
- List result = new ArrayList<>();
- for (Object item : collection) {
- if (type.isInstance(item)) {
- result.add(type.cast(item));
- }
- }
- return result;
- }
-
- @NotNull
- public static String escapeDisplayString(@NotNull final String delim) {
- StringBuilder str = new StringBuilder();
- for (int i = 0; i < delim.length(); i++) {
- char c = delim.charAt(i);
- if (c == '\n') {
- str.append("\\n");
- } else if (c == '\r') {
- str.append("\\r");
- } else if (c == '\t') {
- str.append("\\t");
- } else {
- str.append(c);
- }
- }
- return str.toString();
- }
-
- @NotNull
- public static String unescapeDisplayString(@NotNull final String delim) {
- return delim.replace("\\t", "\t").replace("\\n", "\n").replace("\\r", "\r");
- }
-
- public static int hashCode(@Nullable Object obj) {
- return obj == null ? 0 : obj.hashCode();
- }
-
- public static T getOption(Map options, String name, T defValue) {
- Object optionValue = options.get(name);
- if (optionValue == null) {
- return defValue;
- }
- return (T)optionValue;
- }
-
- public static boolean getOption(Map options, String name) {
- return getOption(options, name, false);
- }
-
- public static boolean getOption(Map options, String name, boolean defValue) {
- if (options == null) {
- return false;
- }
- Object optionValue = options.get(name);
- if (optionValue == null) {
- return defValue;
- }
- return Boolean.TRUE.equals(optionValue);
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/IOUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/IOUtils.java
deleted file mode 100644
index ec5865dc9bf06932f72919abbca090bf1be72c93..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/IOUtils.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils;
-
-import java.io.*;
-import java.net.ServerSocket;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
-
-/**
- * Some IO helper functions
- */
-public final class IOUtils {
-
- public static final int DEFAULT_BUFFER_SIZE = 16384;
-
- public static void close(Closeable closeable) {
- try {
- closeable.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static void fastCopy(final InputStream src, final OutputStream dest) throws IOException {
- fastCopy(src, dest, DEFAULT_BUFFER_SIZE);
- }
-
- public static void fastCopy(final InputStream src, final OutputStream dest, int bufferSize) throws IOException {
- final ReadableByteChannel inputChannel = Channels.newChannel(src);
- final WritableByteChannel outputChannel = Channels.newChannel(dest);
- fastCopy(inputChannel, outputChannel, bufferSize);
- }
-
- public static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest, int bufferSize) throws IOException {
- final ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize);
-
- while (src.read(buffer) != -1) {
- buffer.flip();
- dest.write(buffer);
- buffer.compact();
- }
-
- buffer.flip();
-
- while (buffer.hasRemaining()) {
- dest.write(buffer);
- }
- }
-
- public static void copyStream(
- java.io.InputStream inputStream,
- java.io.OutputStream outputStream)
- throws IOException {
- copyStream(inputStream, outputStream, DEFAULT_BUFFER_SIZE);
- }
-
- /**
- * Read entire input stream and writes all data to output stream
- * then closes input and flushed output
- */
- public static void copyStream(
- java.io.InputStream inputStream,
- java.io.OutputStream outputStream,
- int bufferSize)
- throws IOException {
- try {
- byte[] writeBuffer = new byte[bufferSize];
- for (int br = inputStream.read(writeBuffer); br != -1; br = inputStream.read(writeBuffer)) {
- outputStream.write(writeBuffer, 0, br);
- }
- outputStream.flush();
- } finally {
- // Close input stream
- inputStream.close();
- }
- }
-
- /**
- * Read entire input stream portion and writes it data to output stream
- */
- public static void copyStreamPortion(
- java.io.InputStream inputStream,
- java.io.OutputStream outputStream,
- int portionSize,
- int bufferSize)
- throws IOException {
- if (bufferSize > portionSize) {
- bufferSize = portionSize;
- }
- byte[] writeBuffer = new byte[bufferSize];
- int totalRead = 0;
- while (totalRead < portionSize) {
- int bytesToRead = bufferSize;
- if (bytesToRead > portionSize - totalRead) {
- bytesToRead = portionSize - totalRead;
- }
- int bytesRead = inputStream.read(writeBuffer, 0, bytesToRead);
- outputStream.write(writeBuffer, 0, bytesRead);
- totalRead += bytesRead;
- }
-
- // Close input stream
- outputStream.flush();
- }
-
- public static String toString(File file, String encoding) throws IOException {
- try (InputStream is = new FileInputStream(file)) {
- try (Reader reader = new InputStreamReader(is, encoding)) {
- StringWriter writer = new StringWriter();
- copyText(reader, writer, DEFAULT_BUFFER_SIZE);
- return writer.toString();
- }
- }
- }
-
- /**
- * Read entire reader content and writes it to writer
- * then closes reader and flushed output.
- */
- public static void copyText(
- java.io.Reader reader,
- java.io.Writer writer,
- int bufferSize)
- throws IOException {
- char[] writeBuffer = new char[bufferSize];
- for (int br = reader.read(writeBuffer); br != -1; br = reader.read(writeBuffer)) {
- writer.write(writeBuffer, 0, br);
- }
- writer.flush();
- }
-
- public static void copyText(
- java.io.Reader reader,
- java.io.Writer writer)
- throws IOException {
- copyText(reader, writer, DEFAULT_BUFFER_SIZE);
- }
-
- public static byte[] readFileToBuffer(File file) throws IOException {
- byte[] buffer = new byte[(int) file.length()];
- try (InputStream is = new FileInputStream(file)) {
- readStreamToBuffer(is, buffer);
- }
- return buffer;
- }
-
- public static int readStreamToBuffer(
- java.io.InputStream inputStream,
- byte[] buffer)
- throws IOException {
- int totalRead = 0;
- while (totalRead != buffer.length) {
- int br = inputStream.read(buffer, totalRead, buffer.length - totalRead);
- if (br == -1) {
- break;
- }
- totalRead += br;
- }
- return totalRead;
- }
-
- public static String readLine(java.io.InputStream input)
- throws IOException {
- StringBuilder linebuf = new StringBuilder();
- for (int b = input.read(); b != '\n'; b = input.read()) {
- if (b == -1) {
- if (linebuf.length() == 0) {
- return null;
- } else {
- break;
- }
- }
- if (b != '\r') {
- linebuf.append((char) b);
- }
- }
- return linebuf.toString();
- }
-
- public static String readFullLine(java.io.InputStream input)
- throws IOException {
- StringBuilder linebuf = new StringBuilder();
- for (int b = input.read(); ; b = input.read()) {
- if (b == -1) {
- if (linebuf.length() == 0) {
- return null;
- } else {
- break;
- }
- }
- linebuf.append((char) b);
- if (b == '\n') {
- break;
- }
- }
- return linebuf.toString();
- }
-
- public static int findFreePort(int minPort, int maxPort) {
- int portRange = Math.abs(maxPort - minPort);
- while (true) {
- int portNum = minPort + SecurityUtils.getRandom().nextInt(portRange);
- try {
- ServerSocket socket = new ServerSocket(portNum);
- try {
- socket.close();
- } catch (IOException e) {
- // just skip
- }
- return portNum;
- } catch (IOException e) {
- // Port is busy
- }
- }
- }
-
- public static String readToString(Reader is) throws IOException {
- StringBuilder result = new StringBuilder(4000);
- char[] buffer = new char[4000];
- for (; ; ) {
- int count = is.read(buffer);
- if (count <= 0) {
- break;
- }
- result.append(buffer, 0, count);
- }
- return result.toString();
- }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/IntKeyMap.java b/modules/org.jkiss.utils/src/org/jkiss/utils/IntKeyMap.java
deleted file mode 100644
index 00f6569c4287f06148b242883cff072b96ce2ec0..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/IntKeyMap.java
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils;
-
-import java.util.*;
-
-/**
- Map with int key.
-*/
-@SuppressWarnings("unchecked")
-public class IntKeyMap implements Map {
- /**
- * The default initial capacity - MUST be a power of two.
- */
- static final int DEFAULT_INITIAL_CAPACITY = 16;
-
- /**
- * The maximum capacity, used if a higher value is implicitly specified
- * by either of the constructors with arguments.
- * MUST be a power of two <= 1<<30.
- */
- static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * The load fast used when none specified in constructor.
- **/
- static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
- /**
- * The table, resized as necessary. Length MUST Always be a power of two.
- */
- transient IntEntry[] table;
-
- /**
- * The number of key-value mappings contained in this identity hash map.
- */
- transient int size;
-
- /**
- * The next size value at which to resize (capacity * load factor).
- * @serial
- */
- int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial
- */
- final float loadFactor;
-
- /**
- * The number of times this IntKeyMap has been structurally modified
- */
- transient volatile int modCount;
-
- /**
- * Constructs an empty IntKeyMap with the specified initial
- * capacity and load factor.
- *
- * @param initialCapacity The initial capacity.
- * @param loadFactor The load factor.
- * @throws IllegalArgumentException if the initial capacity is negative
- * or the load factor is nonpositive.
- */
- public IntKeyMap(int initialCapacity, float loadFactor) {
- if (initialCapacity < 0)
- throw new IllegalArgumentException("Illegal initial capacity: " +
- initialCapacity);
- if (initialCapacity > MAXIMUM_CAPACITY)
- initialCapacity = MAXIMUM_CAPACITY;
- if (loadFactor <= 0 || Float.isNaN(loadFactor))
- throw new IllegalArgumentException("Illegal load factor: " +
- loadFactor);
-
- // Find a power of 2 >= initialCapacity
- int capacity = 1;
- while (capacity < initialCapacity)
- capacity <<= 1;
-
- this.loadFactor = loadFactor;
- threshold = (int)(capacity * loadFactor);
- table = new IntEntry[capacity];
- }
-
- /**
- * Constructs an empty IntKeyMap with the specified initial
- * capacity and the default load factor (0.75).
- *
- * @param initialCapacity the initial capacity.
- * @throws IllegalArgumentException if the initial capacity is negative.
- */
- public IntKeyMap(int initialCapacity) {
- this(initialCapacity, DEFAULT_LOAD_FACTOR);
- }
-
- /**
- * Constructs an empty IntKeyMap with the default initial capacity
- * (16) and the default load factor (0.75).
- */
- public IntKeyMap() {
- this.loadFactor = DEFAULT_LOAD_FACTOR;
- threshold = DEFAULT_INITIAL_CAPACITY;
- table = new IntEntry[DEFAULT_INITIAL_CAPACITY];
- }
-
- static int hash(long x) {
- int h = (int)(x ^ (x >>> 32));
- h += ~(h << 9);
- h ^= (h >>> 14);
- h += (h << 4);
- h ^= (h >>> 10);
- return h;
- }
-
- /**
- * Returns index for hash code h.
- */
- static int indexFor(int h, int length) {
- return h & (length-1);
- }
-
- /**
- * Returns the number of key-value mappings in this map.
- *
- * @return the number of key-value mappings in this map.
- */
- @Override
- public int size() {
- return size;
- }
-
- /**
- * Returns true if this map contains no key-value mappings.
- *
- * @return true if this map contains no key-value mappings.
- */
- @Override
- public boolean isEmpty()
- {
- return size == 0;
- }
-
- @Override
- public boolean containsKey(Object key)
- {
- return containsKey(((Number)key).intValue());
- }
-
- /**
- * Returns the value to which the specified key is mapped in this identity
- * hash map, or null if the map contains no mapping for this key.
- * A return value of null does not necessarily indicate
- * that the map contains no mapping for the key; it is also possible that
- * the map explicitly maps the key to null. The
- * containsKey method may be used to distinguish these two cases.
- *
- * @param key the key whose associated value is to be returned.
- * @return the value to which this map maps the specified key, or
- * null if the map contains no mapping for this key.
- * @see #put(int, Object)
- */
- public VALUE get(int key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- IntEntry e = table[i];
- while (true) {
- if (e == null)
- return null;
- if (e.hash == hash && key == e.key)
- return e.value;
- e = e.next;
- }
- }
-
- /**
- * Returns true if this map contains a mapping for the
- * specified key.
- */
- public boolean containsKey(int key)
- {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- IntEntry e = table[i];
- while (e != null) {
- if (e.hash == hash && key == e.key)
- return true;
- e = e.next;
- }
- return false;
- }
-
- /**
- * Returns the entry associated with the specified key in the
- * IntKeyMap. Returns null if the IntKeyMap contains no mapping
- * for this key.
- */
- IntEntry getEntry(int key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- IntEntry e = table[i];
- while (e != null && !(e.hash == hash && key == e.key))
- e = e.next;
- return e;
- }
-
- /**
- * Associates the specified value with the specified key in this map.
- * If the map previously contained a mapping for this key, the old
- * value is replaced.
- *
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return previous value associated with specified key, or null
- * if there was no mapping for key. A null return can
- * also indicate that the IntKeyMap previously associated
- * null with the specified key.
- */
- public VALUE put(int key, VALUE value) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
-
- for (IntEntry e = table[i]; e != null; e = e.next) {
- if (e.hash == hash && key == e.key) {
- VALUE oldValue = e.value;
- e.value = value;
- return oldValue;
- }
- }
-
- modCount++;
- addEntry(hash, key, value, i);
- return null;
- }
-
- /**
- * This method is used instead of put by constructors and
- * pseudoconstructors (clone, readObject). It does not resize the table,
- * check for comodification, etc. It calls createEntry rather than
- * addEntry.
- */
- private void putForCreate(int key, VALUE value) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
-
- /**
- * Look for preexisting entry for key. This will never happen for
- * clone or deserialize. It will only happen for construction if the
- * input Map is a sorted map whose ordering is inconsistent w/ equals.
- */
- for (IntEntry e = table[i]; e != null; e = e.next) {
- if (e.hash == hash && key == e.key) {
- e.value = value;
- return;
- }
- }
-
- createEntry(hash, key, value, i);
- }
-
- void putAllForCreate(IntKeyMap m) {
- for (Iterator i = m.entrySet().iterator(); i.hasNext(); ) {
- IntEntry e = (IntEntry) i.next();
- putForCreate(e.key, e.value);
- }
- }
-
- /**
- * Rehashes the contents of this map into a new IntKeyMap instance
- * with a larger capacity. This method is called automatically when the
- * number of keys in this map exceeds its capacity and load factor.
- *
- * @param newCapacity the new capacity, MUST be a power of two.
- */
- void resize(int newCapacity) {
- // assert (newCapacity & -newCapacity) == newCapacity; // power of 2
- IntEntry[] oldTable = table;
- int oldCapacity = oldTable.length;
-
- // check if needed
- if (size < threshold || oldCapacity > newCapacity)
- return;
-
- IntEntry[] newTable = new IntEntry[newCapacity];
- transfer(newTable);
- table = newTable;
- threshold = (int)(newCapacity * loadFactor);
- }
-
- /**
- * Transfer all entries from current table to newTable.
- */
- void transfer(IntEntry[] newTable) {
- IntEntry[] src = table;
- int newCapacity = newTable.length;
- for (int j = 0; j < src.length; j++) {
- IntEntry e = src[j];
- if (e != null) {
- src[j] = null;
- do {
- IntEntry next = e.next;
- int i = indexFor(e.hash, newCapacity);
- e.next = newTable[i];
- newTable[i] = e;
- e = next;
- } while (e != null);
- }
- }
- }
-
- /**
- * Copies all of the mappings from the specified map to this map
- * These mappings will replace any mappings that
- * this map had for any of the keys currently in the specified map.
- *
- * @param t mappings to be stored in this map.
- * @throws NullPointerException if the specified map is null.
- */
- public void putAll(IntKeyMap t) {
- // Expand enough to hold t's elements without resizing.
- int n = t.size();
- if (n == 0)
- return;
- if (n >= threshold) {
- n = (int)(n / loadFactor + 1);
- if (n > MAXIMUM_CAPACITY)
- n = MAXIMUM_CAPACITY;
- int capacity = table.length;
- while (capacity < n)
- capacity <<= 1;
- resize(capacity);
- }
-
- for (Iterator i = t.entrySet().iterator(); i.hasNext(); ) {
- IntEntry e = (IntEntry) i.next();
- put(e.key, e.value);
- }
- }
-
- /**
- * Removes the mapping for this key from this map if present.
- *
- * @param key key whose mapping is to be removed from the map.
- * @return previous value associated with specified key, or null
- * if there was no mapping for key. A null return can
- * also indicate that the map previously associated null
- * with the specified key.
- */
- public VALUE remove(int key) {
- IntEntry e = removeEntryForKey(key);
- return (e == null ? null : e.value);
- }
-
- /**
- * Removes and returns the entry associated with the specified key
- * in the IntKeyMap. Returns null if the IntKeyMap contains no mapping
- * for this key.
- */
- IntEntry removeEntryForKey(int key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- IntEntry prev = table[i];
- IntEntry e = prev;
-
- while (e != null) {
- IntEntry next = e.next;
- if (e.hash == hash && key == e.key) {
- modCount++;
- size--;
- if (prev == e)
- table[i] = next;
- else
- prev.next = next;
- return e;
- }
- prev = e;
- e = next;
- }
-
- return e;
- }
-
- /**
- * Special version of remove for EntrySet.
- */
- IntEntry removeMapping(Object o) {
- if (!(o instanceof IntEntry))
- return null;
-
- IntEntry entry = (IntEntry)o;
- int hash = hash(entry.key);
- int i = indexFor(hash, table.length);
- IntEntry prev = table[i];
- IntEntry e = prev;
-
- while (e != null) {
- IntEntry next = e.next;
- if (e.hash == hash && e.equals(entry)) {
- modCount++;
- size--;
- if (prev == e)
- table[i] = next;
- else
- prev.next = next;
- return e;
- }
- prev = e;
- e = next;
- }
-
- return e;
- }
-
- /**
- * Removes all mappings from this map.
- */
- @Override
- public void clear() {
- modCount++;
- IntEntry tab[] = table;
- for (int i = 0; i < tab.length; i++)
- tab[i] = null;
- size = 0;
- }
-
- /**
- * Returns true if this map maps one or more keys to the
- * specified value.
- *
- * @param value value whose presence in this map is to be tested.
- * @return true if this map maps one or more keys to the
- * specified value.
- */
- @Override
- public boolean containsValue(Object value)
- {
- if (value == null)
- return containsNullValue();
-
- IntEntry tab[] = table;
- for (int i = 0; i < tab.length ; i++)
- for (IntEntry e = tab[i] ; e != null ; e = e.next)
- if (value.equals(e.value))
- return true;
- return false;
- }
-
- @Override
- public VALUE get(Object key)
- {
- return get(((Number)key).intValue());
- }
-
- @Override
- public VALUE put(Integer key, VALUE value)
- {
- return put(key.intValue(), value);
- }
-
- @Override
- public VALUE remove(Object key)
- {
- return remove(((Number)key).intValue());
- }
-
- @Override
- public void putAll(Map extends Integer, ? extends VALUE> t)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Special-case code for containsValue with null argument
- **/
- private boolean containsNullValue()
- {
- IntEntry tab[] = table;
- for (int i = 0; i < tab.length ; i++)
- for (IntEntry e = tab[i] ; e != null ; e = e.next)
- if (e.value == null)
- return true;
- return false;
- }
-
- public static class IntEntry implements Entry {
- final int key;
- VALUE value;
- final int hash;
- IntEntry next;
-
- /**
- * Create new entry.
- */
- IntEntry(int h, int k, VALUE v, IntEntry n) {
- value = v;
- next = n;
- key = k;
- hash = h;
- }
-
- public int getInt() {
- return key;
- }
-
- @Override
- public Integer getKey()
- {
- return key;
- }
-
- @Override
- public VALUE getValue() {
- return value;
- }
-
- @Override
- public VALUE setValue(VALUE newValue) {
- VALUE oldValue = value;
- value = newValue;
- return oldValue;
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof IntEntry))
- return false;
- IntEntry e = (IntEntry)o;
- if (key == e.key) {
- VALUE v1 = getValue();
- VALUE v2 = e.getValue();
- if (v1 == v2 || (v1 != null && v1.equals(v2)))
- return true;
- }
- return false;
- }
-
- public int hashCode() {
- return hash(key) ^ (value==null ? 0 : value.hashCode());
- }
-
- public String toString() {
- return String.valueOf(key) + "=" + getValue();
- }
-
- }
-
- /**
- * Add a new entry with the specified key, value and hash code to
- * the specified bucket. It is the responsibility of this
- * method to resize the table if appropriate.
- *
- * Subclass overrides this to alter the behavior of put method.
- */
- void addEntry(int hash, int key, VALUE value, int bucketIndex) {
- table[bucketIndex] = new IntEntry<>(hash, key, value, table[bucketIndex]);
- if (size++ >= threshold)
- resize(2 * table.length);
- }
-
- /**
- * Like addEntry except that this version is used when creating entries
- * as part of Map construction or "pseudo-construction" (cloning,
- * deserialization). This version needn't worry about resizing the table.
- *
- * Subclass overrides this to alter the behavior of IntKeyMap(Map),
- * clone, and readObject.
- */
- void createEntry(int hash, int key, VALUE value, int bucketIndex) {
- table[bucketIndex] = new IntEntry<>(hash, key, value, table[bucketIndex]);
- size++;
- }
-
- private abstract class HashIterator implements Iterator {
- IntEntry next; // next entry to return
- int expectedModCount; // For fast-fail
- int index; // current slot
- IntEntry current; // current entry
-
- HashIterator() {
- expectedModCount = modCount;
- IntEntry[] t = table;
- int i = t.length;
- IntEntry n = null;
- if (size != 0) { // advance to first entry
- while (i > 0 && (n = t[--i]) == null)
- ;
- }
- next = n;
- index = i;
- }
-
- @Override
- public boolean hasNext() {
- return next != null;
- }
-
- IntEntry nextEntry() {
- if (modCount != expectedModCount)
- throw new ConcurrentModificationException();
- IntEntry e = next;
- if (e == null)
- throw new NoSuchElementException();
-
- IntEntry n = e.next;
- IntEntry[] t = table;
- int i = index;
- while (n == null && i > 0)
- n = t[--i];
- index = i;
- next = n;
- return current = e;
- }
-
- @Override
- public void remove() {
- if (current == null)
- throw new IllegalStateException();
- if (modCount != expectedModCount)
- throw new ConcurrentModificationException();
- int k = current.key;
- current = null;
- IntKeyMap.this.removeEntryForKey(k);
- expectedModCount = modCount;
- }
-
- }
-
- private class ValueIterator extends HashIterator {
- @Override
- public VALUE next() {
- return nextEntry().value;
- }
- }
-
- private class KeyIterator extends HashIterator {
- @Override
- public Integer next() {
- return nextEntry().key;
- }
- public int nextInt() {
- return nextEntry().key;
- }
- }
-
- private class EntryIterator extends HashIterator> {
- @Override
- public IntEntry next() {
- return nextEntry();
- }
- }
-
- // Subclass overrides these to alter behavior of views' iterator() method
- Iterator newKeyIterator()
- {
- return new KeyIterator();
- }
- Iterator newValueIterator()
- {
- return new ValueIterator();
- }
- Iterator> newEntryIterator()
- {
- return new EntryIterator();
- }
-
-
- // Views
-
- private transient Set> entrySet = null;
- transient volatile Set keySet = null;
- transient volatile Collection values = null;
-
- /**
- * Returns a set view of the keys contained in this map. The set is
- * backed by the map, so changes to the map are reflected in the set, and
- * vice-versa. The set supports element removal, which removes the
- * corresponding mapping from this map, via the Iterator.remove,
- * Set.remove, removeAll, retainAll, and
- * clear operations. It does not support the add or
- * addAll operations.
- *
- * @return a set view of the keys contained in this map.
- */
- @Override
- public Set keySet() {
- Set ks = keySet;
- return (ks != null ? ks : (keySet = new KeySet()));
- }
-
- private class KeySet extends AbstractSet {
- @Override
- public Iterator iterator() {
- return newKeyIterator();
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public boolean contains(Object o) {
- if (o instanceof Number) {
- return containsKey(((Number)o).intValue());
- } else {
- return false;
- }
- }
- @Override
- public boolean remove(Object o) {
- if (o instanceof Number) {
- return IntKeyMap.this.removeEntryForKey(((Number)o).intValue()) != null;
- } else {
- return false;
- }
- }
- @Override
- public void clear() {
- IntKeyMap.this.clear();
- }
- }
-
- /**
- * Returns a collection view of the values contained in this map. The
- * collection is backed by the map, so changes to the map are reflected in
- * the collection, and vice-versa. The collection supports element
- * removal, which removes the corresponding mapping from this map, via the
- * Iterator.remove, Collection.remove,
- * removeAll, retainAll, and clear operations.
- * It does not support the add or addAll operations.
- *
- * @return a collection view of the values contained in this map.
- */
- @Override
- public Collection values() {
- Collection vs = values;
- return (vs != null ? vs : (values = new Values()));
- }
-
- private class Values extends AbstractCollection {
- @Override
- public Iterator iterator() {
- return newValueIterator();
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public boolean contains(Object o) {
- return containsValue(o);
- }
- @Override
- public void clear() {
- IntKeyMap.this.clear();
- }
- }
-
- @Override
- public Set entrySet()
- {
- Set> es = entrySet;
- return (es != null ? es : (entrySet = new EntrySet()));
- }
-
- private class EntrySet extends AbstractSet> {
- @Override
- public Iterator> iterator() {
- return newEntryIterator();
- }
- @Override
- public boolean contains(Object o) {
- if (!(o instanceof IntEntry))
- return false;
- IntEntry e = (IntEntry)o;
- IntEntry candidate = getEntry(e.key);
- return candidate != null && candidate.equals(e);
- }
- @Override
- public boolean remove(Object o) {
- return removeMapping(o) != null;
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public void clear() {
- IntKeyMap.this.clear();
- }
- }
-
- // These methods are used when serializing HashSets
- int capacity() { return table.length; }
- float loadFactor() { return loadFactor; }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/LongKeyMap.java b/modules/org.jkiss.utils/src/org/jkiss/utils/LongKeyMap.java
deleted file mode 100644
index 74478f5ce7d692fa736bbe9d02e32a8772858c3f..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/LongKeyMap.java
+++ /dev/null
@@ -1,806 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils;
-
-import java.util.*;
-
-/**
- Map with long key.
-*/
-public class LongKeyMap implements Map {
- /**
- * The default initial capacity - MUST be a power of two.
- */
- static final int DEFAULT_INITIAL_CAPACITY = 16;
-
- /**
- * The maximum capacity, used if a higher value is implicitly specified
- * by either of the constructors with arguments.
- * MUST be a power of two <= 1<<30.
- */
- static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * The load fast used when none specified in constructor.
- **/
- static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
- /**
- * The table, resized as necessary. Length MUST Always be a power of two.
- */
- transient LongEntry[] table;
-
- /**
- * The number of key-value mappings contained in this identity hash map.
- */
- transient int size;
-
- /**
- * The next size value at which to resize (capacity * load factor).
- * @serial
- */
- int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial
- */
- final float loadFactor;
-
- /**
- * The number of times this LongKeyMap has been structurally modified
- */
- transient volatile int modCount;
-
- /**
- * Constructs an empty LongKeyMap with the specified initial
- * capacity and load factor.
- *
- * @param initialCapacity The initial capacity.
- * @param loadFactor The load factor.
- * @throws IllegalArgumentException if the initial capacity is negative
- * or the load factor is nonpositive.
- */
- public LongKeyMap(int initialCapacity, float loadFactor) {
- if (initialCapacity < 0)
- throw new IllegalArgumentException("Illegal initial capacity: " +
- initialCapacity);
- if (initialCapacity > MAXIMUM_CAPACITY)
- initialCapacity = MAXIMUM_CAPACITY;
- if (loadFactor <= 0 || Float.isNaN(loadFactor))
- throw new IllegalArgumentException("Illegal load factor: " +
- loadFactor);
-
- // Find a power of 2 >= initialCapacity
- int capacity = 1;
- while (capacity < initialCapacity)
- capacity <<= 1;
-
- this.loadFactor = loadFactor;
- threshold = (int)(capacity * loadFactor);
- table = new LongEntry[capacity];
- }
-
- /**
- * Constructs an empty LongKeyMap with the specified initial
- * capacity and the default load factor (0.75).
- *
- * @param initialCapacity the initial capacity.
- * @throws IllegalArgumentException if the initial capacity is negative.
- */
- public LongKeyMap(int initialCapacity) {
- this(initialCapacity, DEFAULT_LOAD_FACTOR);
- }
-
- /**
- * Constructs an empty LongKeyMap with the default initial capacity
- * (16) and the default load factor (0.75).
- */
- public LongKeyMap() {
- this.loadFactor = DEFAULT_LOAD_FACTOR;
- threshold = DEFAULT_INITIAL_CAPACITY;
- table = new LongEntry[DEFAULT_INITIAL_CAPACITY];
- }
-
- static int hash(long x) {
- int h = (int)(x ^ (x >>> 32));
- h += ~(h << 9);
- h ^= (h >>> 14);
- h += (h << 4);
- h ^= (h >>> 10);
- return h;
- }
-
- /**
- * Returns index for hash code h.
- */
- static int indexFor(int h, int length) {
- return h & (length-1);
- }
-
- /**
- * Returns the number of key-value mappings in this map.
- *
- * @return the number of key-value mappings in this map.
- */
- @Override
- public int size() {
- return size;
- }
-
- /**
- * Returns true if this map contains no key-value mappings.
- *
- * @return true if this map contains no key-value mappings.
- */
- @Override
- public boolean isEmpty()
- {
- return size == 0;
- }
-
- @Override
- public boolean containsKey(Object key)
- {
- return containsKey(((Number)key).longValue());
- }
-
- /**
- * Returns the value to which the specified key is mapped in this identity
- * hash map, or null if the map contains no mapping for this key.
- * A return value of null does not necessarily indicate
- * that the map contains no mapping for the key; it is also possible that
- * the map explicitly maps the key to null. The
- * containsKey method may be used to distinguish these two cases.
- *
- * @param key the key whose associated value is to be returned.
- * @return the value to which this map maps the specified key, or
- * null if the map contains no mapping for this key.
- * @see #put(long, Object)
- */
- public VALUE get(long key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- LongEntry e = table[i];
- while (true) {
- if (e == null)
- return null;
- if (e.hash == hash && key == e.key)
- return e.value;
- e = e.next;
- }
- }
-
- /**
- * Returns true if this map contains a mapping for the
- * specified key.
- */
- public boolean containsKey(long key)
- {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- LongEntry e = table[i];
- while (e != null) {
- if (e.hash == hash && key == e.key)
- return true;
- e = e.next;
- }
- return false;
- }
-
- /**
- * Returns the entry associated with the specified key in the
- * LongKeyMap. Returns null if the LongKeyMap contains no mapping
- * for this key.
- */
- LongEntry getEntry(long key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- LongEntry e = table[i];
- while (e != null && !(e.hash == hash && key == e.key))
- e = e.next;
- return e;
- }
-
- /**
- * Associates the specified value with the specified key in this map.
- * If the map previously contained a mapping for this key, the old
- * value is replaced.
- *
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return previous value associated with specified key, or null
- * if there was no mapping for key. A null return can
- * also indicate that the LongKeyMap previously associated
- * null with the specified key.
- */
- public VALUE put(long key, VALUE value) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
-
- for (LongEntry e = table[i]; e != null; e = e.next) {
- if (e.hash == hash && key == e.key) {
- VALUE oldValue = e.value;
- e.value = value;
- return oldValue;
- }
- }
-
- modCount++;
- addEntry(hash, key, value, i);
- return null;
- }
-
- /**
- * This method is used instead of put by constructors and
- * pseudoconstructors (clone, readObject). It does not resize the table,
- * check for comodification, etc. It calls createEntry rather than
- * addEntry.
- */
- private void putForCreate(long key, VALUE value) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
-
- /**
- * Look for preexisting entry for key. This will never happen for
- * clone or deserialize. It will only happen for construction if the
- * input Map is a sorted map whose ordering is inconsistent w/ equals.
- */
- for (LongEntry e = table[i]; e != null; e = e.next) {
- if (e.hash == hash && key == e.key) {
- e.value = value;
- return;
- }
- }
-
- createEntry(hash, key, value, i);
- }
-
- void putAllForCreate(LongKeyMap m) {
- for (Iterator> i = m.entrySet().iterator(); i.hasNext(); ) {
- LongEntry e = i.next();
- putForCreate(e.key, e.value);
- }
- }
-
- /**
- * Rehashes the contents of this map into a new LongKeyMap instance
- * with a larger capacity. This method is called automatically when the
- * number of keys in this map exceeds its capacity and load factor.
- *
- * @param newCapacity the new capacity, MUST be a power of two.
- */
- void resize(int newCapacity) {
- // assert (newCapacity & -newCapacity) == newCapacity; // power of 2
- LongEntry[] oldTable = table;
- int oldCapacity = oldTable.length;
-
- // check if needed
- if (size < threshold || oldCapacity > newCapacity)
- return;
-
- LongEntry[] newTable = new LongEntry[newCapacity];
- transfer(newTable);
- table = newTable;
- threshold = (int)(newCapacity * loadFactor);
- }
-
- /**
- * Transfer all entries from current table to newTable.
- */
- void transfer(LongEntry[] newTable) {
- LongEntry[] src = table;
- int newCapacity = newTable.length;
- for (int j = 0; j < src.length; j++) {
- LongEntry e = src[j];
- if (e != null) {
- src[j] = null;
- do {
- LongEntry next = e.next;
- int i = indexFor(e.hash, newCapacity);
- e.next = newTable[i];
- newTable[i] = e;
- e = next;
- } while (e != null);
- }
- }
- }
-
- /**
- * Copies all of the mappings from the specified map to this map
- * These mappings will replace any mappings that
- * this map had for any of the keys currently in the specified map.
- *
- * @param t mappings to be stored in this map.
- * @throws NullPointerException if the specified map is null.
- */
- public void putAll(LongKeyMap t) {
- // Expand enough to hold t's elements without resizing.
- int n = t.size();
- if (n == 0)
- return;
- if (n >= threshold) {
- n = (int)(n / loadFactor + 1);
- if (n > MAXIMUM_CAPACITY)
- n = MAXIMUM_CAPACITY;
- int capacity = table.length;
- while (capacity < n)
- capacity <<= 1;
- resize(capacity);
- }
-
- for (Iterator> i = t.entrySet().iterator(); i.hasNext(); ) {
- LongEntry e = i.next();
- put(e.key, e.value);
- }
- }
-
- /**
- * Removes the mapping for this key from this map if present.
- *
- * @param key key whose mapping is to be removed from the map.
- * @return previous value associated with specified key, or null
- * if there was no mapping for key. A null return can
- * also indicate that the map previously associated null
- * with the specified key.
- */
- public VALUE remove(long key) {
- LongEntry e = removeEntryForKey(key);
- return (e == null ? null : e.value);
- }
-
- /**
- * Removes and returns the entry associated with the specified key
- * in the LongKeyMap. Returns null if the LongKeyMap contains no mapping
- * for this key.
- */
- LongEntry removeEntryForKey(long key) {
- int hash = hash(key);
- int i = indexFor(hash, table.length);
- LongEntry prev = table[i];
- LongEntry e = prev;
-
- while (e != null) {
- LongEntry next = e.next;
- if (e.hash == hash && key == e.key) {
- modCount++;
- size--;
- if (prev == e)
- table[i] = next;
- else
- prev.next = next;
- return e;
- }
- prev = e;
- e = next;
- }
-
- return e;
- }
-
- /**
- * Special version of remove for EntrySet.
- */
- LongEntry removeMapping(Object o) {
- if (!(o instanceof LongEntry))
- return null;
-
- LongEntry entry = (LongEntry)o;
- int hash = hash(entry.key);
- int i = indexFor(hash, table.length);
- LongEntry prev = table[i];
- LongEntry e = prev;
-
- while (e != null) {
- LongEntry next = e.next;
- if (e.hash == hash && e.equals(entry)) {
- modCount++;
- size--;
- if (prev == e)
- table[i] = next;
- else
- prev.next = next;
- return e;
- }
- prev = e;
- e = next;
- }
-
- return e;
- }
-
- /**
- * Removes all mappings from this map.
- */
- @Override
- public void clear() {
- modCount++;
- LongEntry tab[] = table;
- for (int i = 0; i < tab.length; i++)
- tab[i] = null;
- size = 0;
- }
-
- /**
- * Returns true if this map maps one or more keys to the
- * specified value.
- *
- * @param value value whose presence in this map is to be tested.
- * @return true if this map maps one or more keys to the
- * specified value.
- */
- @Override
- public boolean containsValue(Object value)
- {
- if (value == null)
- return containsNullValue();
-
- LongEntry tab[] = table;
- for (int i = 0; i < tab.length ; i++)
- for (LongEntry e = tab[i] ; e != null ; e = e.next)
- if (value.equals(e.value))
- return true;
- return false;
- }
-
- @Override
- public VALUE get(Object key)
- {
- return get(((Number)key).longValue());
- }
-
- @Override
- public VALUE put(Long key, VALUE value)
- {
- return put(key.longValue(), value);
- }
-
- @Override
- public VALUE remove(Object key)
- {
- return remove(((Number)key).longValue());
- }
-
- @Override
- public void putAll(Map extends Long, ? extends VALUE> t)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Special-case code for containsValue with null argument
- **/
- private boolean containsNullValue()
- {
- LongEntry tab[] = table;
- for (int i = 0; i < tab.length ; i++)
- for (LongEntry e = tab[i] ; e != null ; e = e.next)
- if (e.value == null)
- return true;
- return false;
- }
-
- public static class LongEntry implements Entry {
- final long key;
- VALUE value;
- final int hash;
- LongEntry next;
-
- /**
- * Create new entry.
- */
- LongEntry(int h, long k, VALUE v, LongEntry n) {
- value = v;
- next = n;
- key = k;
- hash = h;
- }
-
- public long getLong() {
- return key;
- }
-
- @Override
- public Long getKey()
- {
- return key;
- }
-
- @Override
- public VALUE getValue() {
- return value;
- }
-
- @Override
- public VALUE setValue(VALUE newValue) {
- VALUE oldValue = value;
- value = newValue;
- return oldValue;
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof LongEntry))
- return false;
- LongEntry e = (LongEntry)o;
- if (key == e.key) {
- VALUE v1 = getValue();
- VALUE v2 = e.getValue();
- if (v1 == v2 || (v1 != null && v1.equals(v2)))
- return true;
- }
- return false;
- }
-
- public int hashCode() {
- return hash(key) ^ (value==null ? 0 : value.hashCode());
- }
-
- public String toString() {
- return String.valueOf(key) + "=" + getValue();
- }
-
- }
-
- /**
- * Add a new entry with the specified key, value and hash code to
- * the specified bucket. It is the responsibility of this
- * method to resize the table if appropriate.
- *
- * Subclass overrides this to alter the behavior of put method.
- */
- void addEntry(int hash, long key, VALUE value, int bucketIndex) {
- table[bucketIndex] = new LongEntry<>(hash, key, value, table[bucketIndex]);
- if (size++ >= threshold)
- resize(2 * table.length);
- }
-
- /**
- * Like addEntry except that this version is used when creating entries
- * as part of Map construction or "pseudo-construction" (cloning,
- * deserialization). This version needn't worry about resizing the table.
- *
- * Subclass overrides this to alter the behavior of LongKeyMap(Map),
- * clone, and readObject.
- */
- void createEntry(int hash, long key, VALUE value, int bucketIndex) {
- table[bucketIndex] = new LongEntry<>(hash, key, value, table[bucketIndex]);
- size++;
- }
-
- private abstract class HashIterator implements Iterator {
- LongEntry next; // next entry to return
- int expectedModCount; // For fast-fail
- int index; // current slot
- LongEntry current; // current entry
-
- HashIterator() {
- expectedModCount = modCount;
- LongEntry[] t = table;
- int i = t.length;
- LongEntry n = null;
- if (size != 0) { // advance to first entry
- while (i > 0 && (n = t[--i]) == null)
- ;
- }
- next = n;
- index = i;
- }
-
- @Override
- public boolean hasNext() {
- return next != null;
- }
-
- LongEntry nextEntry() {
- if (modCount != expectedModCount)
- throw new ConcurrentModificationException();
- LongEntry e = next;
- if (e == null)
- throw new NoSuchElementException();
-
- LongEntry n = e.next;
- LongEntry[] t = table;
- int i = index;
- while (n == null && i > 0)
- n = t[--i];
- index = i;
- next = n;
- return current = e;
- }
-
- @Override
- public void remove() {
- if (current == null)
- throw new IllegalStateException();
- if (modCount != expectedModCount)
- throw new ConcurrentModificationException();
- long k = current.key;
- current = null;
- LongKeyMap.this.removeEntryForKey(k);
- expectedModCount = modCount;
- }
-
- }
-
- private class ValueIterator extends HashIterator {
- @Override
- public VALUE next() {
- return nextEntry().value;
- }
- }
-
- private class KeyIterator extends HashIterator {
- @Override
- public Long next() {
- return nextEntry().key;
- }
- public long nextLong() {
- return nextEntry().key;
- }
- }
-
- private class EntryIterator extends HashIterator> {
- @Override
- public LongEntry next() {
- return nextEntry();
- }
- }
-
- // Subclass overrides these to alter behavior of views' iterator() method
- Iterator newKeyIterator()
- {
- return new KeyIterator();
- }
- Iterator newValueIterator()
- {
- return new ValueIterator();
- }
- Iterator> newEntryIterator()
- {
- return new EntryIterator();
- }
-
-
- // Views
-
- private transient Set> entrySet = null;
- transient volatile Set keySet = null;
- transient volatile Collection values = null;
-
- /**
- * Returns a set view of the keys contained in this map. The set is
- * backed by the map, so changes to the map are reflected in the set, and
- * vice-versa. The set supports element removal, which removes the
- * corresponding mapping from this map, via the Iterator.remove,
- * Set.remove, removeAll, retainAll, and
- * clear operations. It does not support the add or
- * addAll operations.
- *
- * @return a set view of the keys contained in this map.
- */
- @Override
- public Set keySet() {
- Set ks = keySet;
- return (ks != null ? ks : (keySet = new KeySet()));
- }
-
- private class KeySet extends AbstractSet {
- @Override
- public Iterator iterator() {
- return newKeyIterator();
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public boolean contains(Object o) {
- if (o instanceof Number) {
- return containsKey(((Number)o).longValue());
- } else {
- return false;
- }
- }
- @Override
- public boolean remove(Object o) {
- if (o instanceof Number) {
- return LongKeyMap.this.removeEntryForKey(((Number)o).longValue()) != null;
- } else {
- return false;
- }
- }
- @Override
- public void clear() {
- LongKeyMap.this.clear();
- }
- }
-
- /**
- * Returns a collection view of the values contained in this map. The
- * collection is backed by the map, so changes to the map are reflected in
- * the collection, and vice-versa. The collection supports element
- * removal, which removes the corresponding mapping from this map, via the
- * Iterator.remove, Collection.remove,
- * removeAll, retainAll, and clear operations.
- * It does not support the add or addAll operations.
- *
- * @return a collection view of the values contained in this map.
- */
- @Override
- public Collection values() {
- Collection vs = values;
- return (vs != null ? vs : (values = new Values()));
- }
-
- private class Values extends AbstractCollection {
- @Override
- public Iterator iterator() {
- return newValueIterator();
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public boolean contains(Object o) {
- return containsValue(o);
- }
- @Override
- public void clear() {
- LongKeyMap.this.clear();
- }
- }
-
- @Override
- public Set entrySet()
- {
- Set> es = entrySet;
- return (es != null ? es : (entrySet = new EntrySet()));
- }
-
- private class EntrySet extends AbstractSet> {
- @Override
- public Iterator> iterator() {
- return newEntryIterator();
- }
- @Override
- public boolean contains(Object o) {
- if (!(o instanceof LongEntry))
- return false;
- LongEntry e = (LongEntry)o;
- LongEntry candidate = getEntry(e.key);
- return candidate != null && candidate.equals(e);
- }
- @Override
- public boolean remove(Object o) {
- return removeMapping(o) != null;
- }
- @Override
- public int size() {
- return size;
- }
- @Override
- public void clear() {
- LongKeyMap.this.clear();
- }
- }
-
- // These methods are used when serializing HashSets
- int capacity() { return table.length; }
- float loadFactor() { return loadFactor; }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/MimeType.java b/modules/org.jkiss.utils/src/org/jkiss/utils/MimeType.java
deleted file mode 100644
index 080754da7dc4a910f2cc16b0101f5950f429cba3..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/MimeType.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils;
-
-import java.util.Locale;
-
-/**
- * MIME type parser
- */
-public class MimeType {
-
- private String primaryType;
- private String subType;
-
- public MimeType() {
- primaryType = "application";
- subType = "*";
- }
-
- public MimeType(String rawdata) throws IllegalArgumentException {
- parse(rawdata);
- }
-
- public MimeType(String primary, String sub) {
- primaryType = primary.toLowerCase(Locale.ENGLISH);
- subType = sub.toLowerCase(Locale.ENGLISH);
- }
-
- private void parse(String rawdata) throws IllegalArgumentException {
- int slashIndex = rawdata.indexOf('/');
- int semIndex = rawdata.indexOf(';');
- if ((slashIndex < 0) && (semIndex < 0)) {
- primaryType = rawdata;
- subType = "*";
- } else if ((slashIndex < 0) && (semIndex >= 0)) {
- primaryType = rawdata.substring(0, semIndex);
- subType = "*";
- } else if ((slashIndex >= 0) && (semIndex < 0)) {
- primaryType = rawdata.substring(0, slashIndex).trim().toLowerCase(Locale.ENGLISH);
- subType = rawdata.substring(slashIndex + 1).trim().toLowerCase(Locale.ENGLISH);
- } else if (slashIndex < semIndex) {
- primaryType = rawdata.substring(0, slashIndex).trim().toLowerCase(Locale.ENGLISH);
- subType = rawdata.substring(slashIndex + 1, semIndex).trim().toLowerCase(Locale.ENGLISH);
- } else {
- // we have a ';' lexically before a '/' which means we
- // have a primary type and a parameter list but no sub type
- throw new IllegalArgumentException("Unable to find a sub type.");
- }
- }
-
- public String getPrimaryType() {
- return primaryType;
- }
-
- public String getSubType() {
- return subType;
- }
-
- public String toString() {
- return getBaseType();
- }
-
- public String getBaseType() {
- return primaryType + "/" + subType;
- }
-
- public boolean match(MimeType type) {
- return primaryType.equals(type.getPrimaryType()) &&
- (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType())));
- }
-
- public boolean match(String rawdata) throws IllegalArgumentException {
- return match(new MimeType(rawdata));
- }
-
-}
\ No newline at end of file
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/Pair.java b/modules/org.jkiss.utils/src/org/jkiss/utils/Pair.java
deleted file mode 100644
index 92b290498c28aed5626da1b318441c25e7f802a8..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/Pair.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.jkiss.utils;
-
-/**
- * Pair
- */
-public class Pair {
- private T1 first;
- private T2 second;
-
- public Pair(T1 first, T2 second)
- {
- this.first = first;
- this.second = second;
- }
-
- public T1 getFirst()
- {
- return first;
- }
-
- public void setFirst(T1 first) {
- this.first = first;
- }
-
- public T2 getSecond()
- {
- return second;
- }
-
- public void setSecond(T2 second) {
- this.second = second;
- }
-
- @Override
- public String toString() {
- return first + "=" + second;
- }
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/SecurityUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/SecurityUtils.java
deleted file mode 100644
index 6545fa54938a3650fac7b188fa209908d80323e5..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/SecurityUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.util.Random;
-
-/**
- * Come security-related functions.
- */
-public class SecurityUtils {
-
- public static String ECRYPTION_ALGORYTHM = "MD5";
-
- private static java.util.Random random;
- private static java.util.Random secureRand;
-
- static {
- secureRand = new java.util.Random(System.currentTimeMillis());
- long secureInitializer = secureRand.nextLong();
- random = new java.util.Random(secureInitializer);
- }
-
- /**
- * Generate the random GUID
- */
- public static String generateGUID(boolean secure) {
- String localHostAddr;
- {
- java.net.InetAddress id;
- try {
- id = java.net.InetAddress.getLocalHost();
- localHostAddr = id.toString();
- } catch (java.net.UnknownHostException e) {
- localHostAddr = "localhost";
- }
- }
-
- long time = System.currentTimeMillis();
- long rand;
-
- if (secure) {
- rand = secureRand.nextLong();
- } else {
- rand = SecurityUtils.random.nextLong();
- }
-
- // This StringBuilder can be a long as you need; the MD5
- // hash will always return 128 bits. You can change
- // the seed to include anything you want here.
- // You could even stream a file through the MD5 making
- // the odds of guessing it at least as great as that
- // of guessing the contents of the file!
- StringBuilder sb = new StringBuilder(32);
- sb.append(localHostAddr)
- .append(":")
- .append(Long.toString(time))
- .append(":")
- .append(Long.toString(rand));
-
-
- byte[] array;
- try {
- MessageDigest md5 = MessageDigest.getInstance(ECRYPTION_ALGORYTHM);
- md5.update(sb.toString().getBytes());
- array = md5.digest();
- } catch (NoSuchAlgorithmException e) {
- // Too bad. Lets get simple random numbers
- array = new byte[16];
- random.nextBytes(array);
- }
- sb.setLength(0);
- for (int j = 0; j < array.length; ++j) {
- int b = array[j] & 0xFF;
- if (b < 0x10) {
- sb.append('0');
- }
- sb.append(Integer.toHexString(b));
- }
-
- String raw = sb.toString().toUpperCase();
- sb.setLength(0);
- sb.append(raw.substring(0, 8));
- sb.append("-");
- sb.append(raw.substring(8, 12));
- sb.append("-");
- sb.append(raw.substring(12, 16));
- sb.append("-");
- sb.append(raw.substring(16, 20));
- sb.append("-");
- sb.append(raw.substring(20));
-
- return sb.toString();
- }
-
- public static String generateUniqueId() {
- long curTime = System.currentTimeMillis();
- int random = secureRand.nextInt();
- if (random < 0) {
- random = -random;
- }
-
- return
- Long.toString(curTime, Character.MAX_RADIX) +
- Integer.toString(random, Character.MAX_RADIX);
- }
-
- public static String makeDigest(
- String userAlias,
- String userPassword) {
- try {
- if (userPassword == null) {
- userPassword = "";
- }
- MessageDigest md5 =
- MessageDigest.getInstance(ECRYPTION_ALGORYTHM);
- md5.update(userAlias.getBytes());
-
- return Base64.encode(md5.digest(userPassword.getBytes()));
- } catch (NoSuchAlgorithmException toCatch) {
- return "*";
- }
- }
-
- public static String makeDigest(
- String userPassword) {
- try {
- MessageDigest md5 =
- MessageDigest.getInstance(ECRYPTION_ALGORYTHM);
-
- return Base64.encode(md5.digest(userPassword.getBytes()));
- } catch (NoSuchAlgorithmException toCatch) {
- return "*";
- }
- }
-
- /**
- * Generate a random password of the given length.
- */
- public static String generatePassword(int length) {
- SecureRandom random = new SecureRandom();
- StringBuilder pass = new StringBuilder(length);
- for (int i = 0; i < length; i++) {
- pass.append(
- PASSWORD_ALPHABET[random.nextInt(PASSWORD_ALPHABET.length)]
- );
- }
- return (pass.toString());
- }
-
- /**
- * Generate a random password of the default length (8).
- */
- public static String generatePassword() {
- return generatePassword(DEFAULT_PASSWORD_LENGTH);
- }
-
- public static Random getRandom() {
- return random;
- }
-
- /**
- * Default length for passwords
- */
- public static final int DEFAULT_PASSWORD_LENGTH = 8;
-
- /**
- * Alphabet consisting of upper and lowercase letters A-Z and
- * the digits 0-9.
- */
- public static final char[] PASSWORD_ALPHABET = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9',
- };
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/StandardConstants.java b/modules/org.jkiss.utils/src/org/jkiss/utils/StandardConstants.java
deleted file mode 100644
index 725bab12d0fcc92f323b7c82f0e90638caaea174..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/StandardConstants.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software is Open Source Initiative approved Open Source Software.
- * Open Source Initative Approved is a trademark of the Open Source Initiative.
- *
- * This file is part of DrJava. Download the current version of this project
- * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
- */
-
-package org.jkiss.utils;
-
-/**
- * Standard Java constants
- */
-public abstract class StandardConstants {
-
- public static final String ENV_LINE_SEPARATOR = "line.separator";
- public static final String ENV_PATH_SEPARATOR = "path.separator";
-
- public static final String ENV_TMP_DIR = "java.io.tmpdir";
- public static final String ENV_FILE_ENCODING = "file.encoding";
- public static final String ENV_CONSOLE_ENCODING = "console.encoding";
-
- public static final String ENV_USER_HOME = "user.home";
- public static final String ENV_USER_NAME = "user.name";
- public static final String ENV_OS_NAME = "os.name";
-
- public static final String ENV_JAVA_VERSION = "java.version";
- public static final String ENV_JAVA_CLASSPATH = "java.class.path";
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/time/ExtendedDateFormat.java b/modules/org.jkiss.utils/src/org/jkiss/utils/time/ExtendedDateFormat.java
deleted file mode 100644
index 26e32a81884a42f92cc26fb266f1a8f444f248ce..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/time/ExtendedDateFormat.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils.time;
-
-import java.sql.Timestamp;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Formatter adapted to support nanoseconds from java.sql.Timestanp.
- */
-public class ExtendedDateFormat extends SimpleDateFormat {
-
- private static final String NINE_ZEROES = "000000000";
- public static final int MAX_NANO_LENGTH = 8;
-
- int nanoStart = -1, nanoLength;
- boolean nanoOptional;
- String nanoPrefix, nanoPostfix;
-
- public ExtendedDateFormat(String pattern)
- {
- this(pattern, Locale.getDefault());
- }
-
- public ExtendedDateFormat(String pattern, Locale locale)
- {
- super(stripNanos(pattern), locale);
-
- int quoteCount = 0;
- for (int i = 0; i < pattern.length(); i++) {
- char c = pattern.charAt(i);
- if (c == '\'') {
- quoteCount++;
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) == '\'') {
- if (k != i + 1) {
- quoteCount++;
- }
- i = k;
- break;
- }
- }
- } else if (c == '[') {
- nanoStart = i;
- nanoOptional = true;
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) == 'f') {
- nanoLength++;
- if (nanoPrefix == null) {
- nanoPrefix = pattern.substring(i + 1, k);
- }
- }
- if (pattern.charAt(k) == ']') {
- nanoPostfix = pattern.substring(i + 1 + nanoPrefix.length() + nanoLength, k);
- i = k + 1;
- break;
- }
- }
- } else if (c == 'f') {
- nanoStart = i - quoteCount;
- nanoOptional = false;
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) != 'f') {
- break;
- }
- nanoLength++;
- }
- nanoLength++;
- i = i + nanoLength;
- }
- }
- }
-
- @Override
- public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
- {
- StringBuffer result = super.format(date, toAppendTo, pos);
- if (nanoStart >= 0) {
- long nanos = 0;
- if (date instanceof Timestamp) {
- nanos = ((Timestamp) date).getNanos();
- }
- if (!nanoOptional || nanos > 0) {
- StringBuilder nanosRes = new StringBuilder(nanoLength);
- // Append nanos value in the end
- if (nanoPrefix != null) {
- nanosRes.append(nanoPrefix);
- }
- String nanoStr = String.valueOf(nanos);
-
- // nanoStr must be a string of exactly 9 chars in length. Pad with leading "0" if not
- int nbZeroesToPad = 9 - nanoStr.length();
- if (nbZeroesToPad > 0) {
- nanoStr = NINE_ZEROES.substring(0, nbZeroesToPad) + nanoStr;
- }
-
- if (nanoLength < nanoStr.length()) {
- // Truncate nanos string to fit in the pattern
- nanoStr = nanoStr.substring(0, nanoLength);
- } else {
- // Pad with 0s
- for (int i = 0; i < nanoLength - nanoStr.length(); i++) {
- nanosRes.append("0");
- }
- }
- nanosRes.append(nanoStr);
- if (nanoPostfix != null) {
- nanosRes.append(nanoPostfix);
- }
- result.insert(nanoStart, nanosRes.toString());
- }
- }
- return result;
- }
-
- @Override
- public Date parse(String text, ParsePosition pos)
- {
- Date date = super.parse(text, pos);
- int index = pos.getIndex();
- if (index < text.length() && nanoStart > 0) {
- long nanos = 0;
- for (int i = 0; i < nanoLength; i++) {
- int digitPos = index + i;
- if (digitPos == text.length()) {
- break;
- }
- char c = text.charAt(digitPos);
- if (!Character.isDigit(c)) {
- pos.setErrorIndex(index);
- pos.setIndex(index);
- //throw new ParseException("Invalid nanosecond character at pos " + digitPos + ": " + c, index);
- return null;
- }
- long digit = ((int)c - (int)'0');
- for (int k = MAX_NANO_LENGTH - i; k > 0; k--) {
- digit *= 10;
- }
- nanos += digit;
- }
- if (nanos > 0) {
- Timestamp ts = new Timestamp(date.getTime());
- ts.setNanos((int)nanos);
- return ts;
- }
- }
- return date;
- }
-
- private static String stripNanos(String pattern)
- {
- for (int i = 0; i < pattern.length(); i++) {
- char c = pattern.charAt(i);
- if (c == '\'') {
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) == '\'') {
- i = k;
- break;
- }
- }
- } else if (c == '[') {
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) == ']') {
- return pattern.substring(0, i) + pattern.substring(k + 1);
- }
- }
- } else if (c == 'f') {
- for (int k = i + 1; k < pattern.length(); k++) {
- if (pattern.charAt(k) != 'f') {
- return pattern.substring(0, i) + pattern.substring(k);
- }
- }
- return pattern.substring(0, i);
- }
- }
- return pattern;
- }
-
- public static void main(String[] args)
- {
- test("'TIMESTAMP '''yyyy-MM-dd HH:mm:ss.ffffff''");
- test("yyyy-MM-dd Z hh:mm:ss[.fffffffff]");
- test("yyyy-MM-dd Z hh:mm:ss.fffffffff");
- test("yyyy-MM-dd Z hh:mm:ss");
- test("yyyy-MM-dd Z hh:mm:ss[.fffffffff nanos]");
- test("yyyy-MM-dd Z hh:mm:ss[.ffffff micros]");
- test("yyyy-MM-dd Z hh:mm:ss.ffffff");
- test("yyyy-MM-dd Z hh:mm:ss.f"); // 1/10 secs = 'S'
- }
-
- private static void test(String pattern)
- {
- ExtendedDateFormat edf = new ExtendedDateFormat(pattern);
- Timestamp date = new Timestamp(System.currentTimeMillis());
- System.out.println(edf.format(date));
- date.setNanos(0);
- System.out.println(edf.format(date));
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXListener.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXListener.java
deleted file mode 100644
index b03ee89971390cd6e23fbf00ef93c06e44f38659..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils.xml;
-
-import org.xml.sax.Attributes;
-
-/**
- SAX document listener
-*/
-public interface SAXListener {
-
- void saxStartElement(
- SAXReader reader,
- String namespaceURI,
- String localName,
- org.xml.sax.Attributes atts)
- throws XMLException;
-
- void saxText(
- SAXReader reader,
- String data)
- throws XMLException;
-
- void saxEndElement(
- SAXReader reader,
- String namespaceURI,
- String localName)
- throws XMLException;
-
-
- /**
- * Empty listener supposed to skip element subtrees
- */
- class BaseListener implements SAXListener {
-
- @Override
- public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
- }
-
- @Override
- public void saxText(SAXReader reader, String data) throws XMLException {
- }
-
- @Override
- public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
- }
- }
- SAXListener EMPTY_LISTENER = new BaseListener();
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXReader.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXReader.java
deleted file mode 100644
index b5f50200e7653e9dba50628d1df1568d9ae839d9..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/SAXReader.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.utils.xml;
-
-import org.xml.sax.*;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * SAX document reader
- */
-public final class SAXReader implements ContentHandler, EntityResolver, DTDHandler {
-
- public static final int DEFAULT_POOL_SIZE = 10;
-
- private static javax.xml.parsers.SAXParserFactory saxParserFactory = null;
- private static List parsersPool = new ArrayList<>();
-
- private org.xml.sax.InputSource inputSource;
- private Locator locator;
-
- private Map attributes = new HashMap<>();
- private List elementLayers = new ArrayList<>();
- private SAXListener curListener;
- private StringBuilder textValue = new StringBuilder();
- private int depth = 0;
- private boolean handleWhiteSpaces = false;
-
- /**
- * Private constructor.
- * Initialize parser.
- */
- private SAXReader() {
- }
-
- /**
- * Standard constructor.
- * Initialize parser and prepare input stream for reading.
- */
- public SAXReader(InputStream stream) {
- this();
- inputSource = new org.xml.sax.InputSource(stream);
- }
-
- /**
- * Standard constructor.
- * Initialize parser and prepare input stream for reading.
- */
- public SAXReader(Reader reader) {
- this();
- inputSource = new org.xml.sax.InputSource(reader);
- }
-
- public boolean isHandleWhiteSpaces() {
- return handleWhiteSpaces;
- }
-
- public void setHandleWhiteSpaces(
- boolean flag) {
- handleWhiteSpaces = flag;
- }
-
- public Locator getLocator() {
- return locator;
- }
-
- /**
- * Parse input stream and handle XML tags.
- */
- public void parse(SAXListener listener)
- throws IOException, XMLException {
- // Initialize SAX parser
- Parser parser = acquireParser();
-
- // Get reader and parse using SAX2 API
- try {
- XMLReader saxReader = parser.getSAXParser().getXMLReader();
- saxReader.setErrorHandler(new ParseErrorHandler());
- saxReader.setContentHandler(this);
- saxReader.setEntityResolver(this);
- saxReader.setDTDHandler(this);
-
- curListener = listener;
-
- elementLayers.add(listener);
-
- saxReader.parse(inputSource);
- } catch (SAXParseException toCatch) {
- throw new XMLException(
- "Document parse error (line " + toCatch.getLineNumber() + ", pos " + toCatch.getColumnNumber(),
- toCatch);
- } catch (SAXException toCatch) {
- throw new XMLException(
- "Document reading SAX exception",
- XMLUtils.adaptSAXException(toCatch));
- } finally {
- parser.close();
- }
- }
-
- public synchronized static Parser acquireParser() throws XMLException {
- try {
- if (saxParserFactory == null) {
- try {
- saxParserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
- saxParserFactory.setNamespaceAware(true);
- saxParserFactory.setValidating(false);
- } catch (FactoryConfigurationError toCatch) {
- throw new XMLException(
- "SAX factory configuration error",
- toCatch);
- }
- }
-
- for (int i = 0; i < parsersPool.size(); i++) {
- Parser parser = parsersPool.get(i);
- if (parser != null) {
- if (!parser.isAcquired()) {
- parser.acquire();
- return parser;
- }
- } else {
- parsersPool.remove(i);
- parser = new Parser(saxParserFactory.newSAXParser(), true);
- parsersPool.add(parser);
- return parser;
- }
- }
- if (parsersPool.size() == DEFAULT_POOL_SIZE) {
- throw new XMLException(
- "Maximum SAX Parsers Number Exceeded (" + DEFAULT_POOL_SIZE + ")");
- }
- Parser parser = new Parser(saxParserFactory.newSAXParser(), true);
- parsersPool.add(parser);
- return parser;
- } catch (ParserConfigurationException toCatch) {
- throw new XMLException(
- "SAX Parser Configuration error",
- toCatch);
- } catch (SAXException toCatch) {
- throw new XMLException(
- "SAX Parser error",
- toCatch);
- }
- }
-
- /**
- * Closes parser and frees all resources.
- */
- public void close() {
- if (elementLayers != null) {
- elementLayers.clear();
- elementLayers = null;
- }
- inputSource = null;
- curListener = null;
- }
-
- /**
- * Set listener for next event.
- */
- public void setListener(
- SAXListener listener) {
- curListener = listener;
- }
-
- public boolean hasAttribute(
- String name) {
- return attributes.get(name) != null;
- }
-
- public Object getAttribute(
- String name) {
- return attributes.get(name);
- }
-
- public void setAttribute(
- String name,
- Object value) {
- attributes.put(name, value);
- }
-
- public Object removeAttribute(
- String name) {
- return attributes.remove(name);
- }
-
- private void handleText()
- throws SAXException {
- curListener = elementLayers.get(elementLayers.size() - 1);
- try {
- String value = textValue.toString();
-
- curListener.saxText(this, value);
- } catch (Exception toCatch) {
- throw new SAXException(toCatch);
- } finally {
- textValue.setLength(0);
- }
- }
-
- ///////////////////////////////////////////////////////////////
- // SAX Context Handler overrides
- ///////////////////////////////////////////////////////////////
-
- @Override
- public void startDocument() {
- // just do-nothing
- }
-
- @Override
- public void endDocument() {
- this.close();
- }
-
- @Override
- public void startElement(
- String namespaceURI,
- String localName,
- String qName,
- org.xml.sax.Attributes attributes)
- throws SAXException {
- if (depth++ > 0) {
- this.handleText();
- }
-
- curListener = elementLayers.get(elementLayers.size() - 1);
-
- try {
- curListener.saxStartElement(this, namespaceURI, localName, attributes);
- } catch (XMLException toCatch) {
- throw new SAXException(toCatch);
- }
-
- elementLayers.add(curListener);
- }
-
- @Override
- public void endElement(
- String namespaceURI,
- String localName,
- String qName)
- throws SAXException {
- this.handleText();
-
- elementLayers.remove(elementLayers.size() - 1);
-
- curListener = elementLayers.get(elementLayers.size() - 1);
- try {
- curListener.saxEndElement(this, namespaceURI, localName);
- } catch (XMLException toCatch) {
- throw new SAXException(toCatch);
- }
- depth--;
- }
-
- @Override
- public void startPrefixMapping(String prefix, String uri) {
- // just do-nothing
- }
-
- @Override
- public void endPrefixMapping(String prefix) {
- // just do-nothing
- }
-
- @Override
- public void characters(char[] ch, int start, int length) {
- textValue.append(ch, start, length);
- }
-
- @Override
- public void ignorableWhitespace(char[] ch, int start, int length) {
- if (handleWhiteSpaces) {
- textValue.append(ch, start, length);
- }
- }
-
- @Override
- public void processingInstruction(String target, String data) {
- // just do-nothing
- }
-
- @Override
- public void setDocumentLocator(Locator locator) {
- this.locator = locator;
- }
-
- @Override
- public void skippedEntity(String name) {
- // just do-nothing
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- // Return empty stream - we don't need entities by default
- return new InputSource(new StringReader(""));
- }
-
- @Override
- public void notationDecl(String name, String publicId, String systemId) throws SAXException {
- // do nothing
- }
-
- @Override
- public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException {
- // do nothing
- }
-
- static public class Parser {
- private javax.xml.parsers.SAXParser saxParser;
- private boolean isAcquired;
-
- public Parser(javax.xml.parsers.SAXParser saxParser, boolean isAcquired) {
- this.saxParser = saxParser;
- this.isAcquired = isAcquired;
- }
-
- public void setSAXParser(javax.xml.parsers.SAXParser saxParser) {
- this.saxParser = saxParser;
- }
-
- public void acquire() {
- isAcquired = true;
- }
-
- public void close() {
- isAcquired = false;
- }
-
- public javax.xml.parsers.SAXParser getSAXParser() {
- return saxParser;
- }
-
- public boolean isAcquired() {
- return isAcquired;
- }
- }
-
- static class ParseErrorHandler implements org.xml.sax.ErrorHandler {
-
- @Override
- public void error(SAXParseException exception) {
-
- }
-
- @Override
- public void fatalError(SAXParseException exception) {
-
- }
-
- @Override
- public void warning(SAXParseException exception) {
-
- }
-
- }
-
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLBuilder.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLBuilder.java
deleted file mode 100644
index db236e97b7c6dc949730bfc113bbf5c5fc2c1daf..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLBuilder.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils.xml;
-
-import org.jkiss.utils.Base64;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Stream oriented XML document builder.
- */
-public class XMLBuilder
-{
-
- public final class Element implements AutoCloseable
- {
-
- private Element parent;
- private String name;
- private Map nsStack = null;
- private int level;
-
- Element(
- Element parent,
- String name)
- {
- this.init(parent, name);
- }
-
- void init(
- Element parent,
- String name)
- {
- this.parent = parent;
- this.name = name;
- this.nsStack = null;
- this.level = parent == null ? 0 : parent.level + 1;
- }
-
- public String getName()
- {
- return name;
- }
-
- public int getLevel()
- {
- return level;
- }
-
- public void addNamespace(String nsURI, String nsPrefix)
- {
- if (nsStack == null) {
- nsStack = new HashMap<>();
- }
- nsStack.put(nsURI, nsPrefix);
- }
-
- public String getNamespacePrefix(String nsURI)
- {
- if (nsURI.equals(XMLConstants.NS_XML)) {
- return XMLConstants.PREFIX_XML;
- }
- String prefix = (nsStack == null ? null : nsStack.get(nsURI));
- return prefix != null ?
- prefix :
- (parent != null ? parent.getNamespacePrefix(nsURI) : null);
- }
-
- @Override
- public void close() throws IOException {
- XMLBuilder.this.endElement();
- }
- }
-
- // At the beginning and after tag closing
- private static final int STATE_NOTHING = 0;
- // After tag opening
- private static final int STATE_ELEM_OPENED = 1;
- // After text added
- private static final int STATE_TEXT_ADDED = 2;
-
- private static final int IO_BUFFER_SIZE = 8192;
-
- private java.io.Writer writer;
-
- private int state = STATE_NOTHING;
-
- private Element element = null;
- private boolean butify = false;
-
- private List trashElements = new java.util.ArrayList<>();
-
- public XMLBuilder(
- java.io.OutputStream stream,
- String documentEncoding)
- throws java.io.IOException
- {
- this(stream, documentEncoding, true);
- }
-
- public XMLBuilder(
- java.io.OutputStream stream,
- String documentEncoding,
- boolean printHeader)
- throws java.io.IOException
- {
- if (documentEncoding == null) {
- this.init(new java.io.OutputStreamWriter(stream), null, printHeader);
- } else {
- this.init(
- new java.io.OutputStreamWriter(stream, documentEncoding),
- documentEncoding,
- printHeader);
- }
- }
-
- public XMLBuilder(
- java.io.Writer writer,
- String documentEncoding)
- throws java.io.IOException
- {
- this(writer, documentEncoding, true);
- }
-
- public XMLBuilder(
- java.io.Writer writer,
- String documentEncoding,
- boolean printHeader)
- throws java.io.IOException
- {
- this.init(writer, documentEncoding, printHeader);
- }
-
- private Element createElement(
- Element parent,
- String name)
- {
- if (trashElements.isEmpty()) {
- return new Element(parent, name);
- } else {
- Element element = trashElements.remove(trashElements.size() - 1);
- element.init(parent, name);
- return element;
- }
- }
-
- private void deleteElement(
- Element element)
- {
- trashElements.add(element);
- }
-
- private void init(
- java.io.Writer writer,
- String documentEncoding,
- boolean printHeader)
- throws java.io.IOException
- {
- this.writer = new java.io.BufferedWriter(writer, IO_BUFFER_SIZE);
-
- if (printHeader) {
- if (documentEncoding != null) {
- this.writer.write(XMLConstants.XML_HEADER(documentEncoding));
- } else {
- this.writer.write(XMLConstants.XML_HEADER());
- }
- }
- }
-
- public boolean isButify()
- {
- return butify;
- }
-
- public void setButify(boolean butify)
- {
- this.butify = butify;
- }
-
- public Element startElement(
- String elementName)
- throws java.io.IOException
- {
- return this.startElement(null, null, elementName);
- }
-
- public Element startElement(
- String nsURI,
- String elementName)
- throws java.io.IOException
- {
- return this.startElement(nsURI, null, elementName);
- }
-
- /*
- NS prefix will be used in element name if its directly specified
- as nsPrefix parameter or if nsURI has been declared above
- */
- public Element startElement(
- String nsURI,
- String nsPrefix,
- String elementName)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_NOTHING:
- if (butify) {
- writer.write('\n');
- }
- break;
- default:
- break;
- }
- if (butify) {
- if (element != null) {
- for (int i = 0; i <= element.getLevel(); i++) {
- writer.write('\t');
- }
- }
- }
- writer.write('<');
-
- boolean addNamespace = (nsURI != null);
-
- // If old nsURI specified - use prefix
- if (nsURI != null) {
- if (nsPrefix == null && element != null) {
- nsPrefix = element.getNamespacePrefix(nsURI);
- if (nsPrefix != null) {
- // Do not add NS declaration - it was declared somewhere above
- addNamespace = false;
- }
- }
- }
-
- // If we have prefix - use it in tag name
- if (nsPrefix != null) {
- elementName = nsPrefix + ':' + elementName;
- }
-
- writer.write(elementName);
- state = STATE_ELEM_OPENED;
-
- element = this.createElement(element, elementName);
-
- if (addNamespace) {
- this.addNamespace(nsURI, nsPrefix);
- element.addNamespace(nsURI, nsPrefix);
- }
-
- return element;
- }
-
- public XMLBuilder endElement()
- throws java.io.IOException, IllegalStateException
- {
- if (element == null) {
- throw new IllegalStateException("Close tag without open");
- }
-
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write("/>");
- break;
- case STATE_NOTHING:
- if (butify) {
- writer.write('\n');
- for (int i = 0; i < element.getLevel(); i++) {
- writer.write('\t');
- }
- }
- case STATE_TEXT_ADDED:
- writer.write("");
- writer.write(element.getName());
- writer.write('>');
- default:
- break;
- }
-
- this.deleteElement(element);
- element = element.parent;
- state = STATE_NOTHING;
-
- return this;
- }
-
- public XMLBuilder addNamespace(String nsURI)
- throws java.io.IOException
- {
- return this.addNamespace(nsURI, null);
- }
-
- public XMLBuilder addNamespace(
- String nsURI,
- String nsPrefix)
- throws java.io.IOException, IllegalStateException
- {
- if (element == null) {
- throw new IllegalStateException("Namespace outside of element");
- }
- String attrName = XMLConstants.XMLNS;
- if (nsPrefix != null) {
- attrName = attrName + ':' + nsPrefix;
- element.addNamespace(nsURI, nsPrefix);
- }
- this.addAttribute(null, attrName, nsURI, true);
-
- return this;
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- String attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, attributeValue, true);
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- int attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, String.valueOf(attributeValue), false);
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- long attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, String.valueOf(attributeValue), false);
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- boolean attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, String.valueOf(attributeValue), false);
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- float attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, String.valueOf(attributeValue), false);
- }
-
- public XMLBuilder addAttribute(
- String attributeName,
- double attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(null, attributeName, String.valueOf(attributeValue), false);
- }
-
- public XMLBuilder addAttribute(
- String nsURI,
- String attributeName,
- String attributeValue)
- throws java.io.IOException
- {
- return this.addAttribute(nsURI, attributeName, attributeValue, true);
- }
-
- private XMLBuilder addAttribute(
- String nsURI,
- String attributeName,
- String attributeValue,
- boolean escape)
- throws java.io.IOException, IllegalStateException
- {
- switch (state) {
- case STATE_ELEM_OPENED: {
- if (nsURI != null) {
- String nsPrefix = element.getNamespacePrefix(nsURI);
- if (nsPrefix == null) {
- throw new IllegalStateException(
- "Unknown attribute '" + attributeName + "' namespace URI '" + nsURI + "' in element '" + element.getName() + "'");
- }
- attributeName = nsPrefix + ':' + attributeName;
- }
- writer.write(' ');
- writer.write(attributeName);
- writer.write("=\"");
- writer.write(escape ? XMLUtils.escapeXml(attributeValue) : attributeValue);
- writer.write('"');
- break;
- }
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- throw new IllegalStateException(
- "Attribute ouside of element");
- default:
- break;
- }
-
- return this;
- }
-
- public XMLBuilder addText(
- CharSequence textValue)
- throws java.io.IOException
- {
- return addText(textValue, true);
- }
-
- public XMLBuilder addText(
- CharSequence textValue,
- boolean escape)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- break;
- default:
- break;
- }
- this.writeText(textValue, escape);
-
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- /**
- * Adds entire content of specified reader as text
- *
- * @param reader text reader
- * @return self reference
- * @throws java.io.IOException on IO error
- */
- public XMLBuilder addText(
- java.io.Reader reader)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- break;
- default:
- break;
- }
-
- writer.write("");
-
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- public XMLBuilder addTextData(
- String text)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- break;
- default:
- break;
- }
-
- writer.write("");
-
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- /**
- * Adds content of specified stream as Base64 encoded text
- *
- * @param stream Input content stream
- * @param length Content length (this parameter must be correctly specified)
- * @return self reference
- * @throws java.io.IOException on IO error
- */
- public XMLBuilder addBinary(
- java.io.InputStream stream,
- int length)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- break;
- default:
- break;
- }
-
- Base64.encode(stream, length, writer);
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- public XMLBuilder addBinary(
- byte[] buffer)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_TEXT_ADDED:
- case STATE_NOTHING:
- break;
- default:
- break;
- }
-
- Base64.encode(buffer, 0, buffer.length, writer);
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- /**
- * Adds character content as is without any escaping or validation
- * @param textValue content
- * @return self reference
- * @throws java.io.IOException
- */
- public XMLBuilder addContent(
- CharSequence textValue)
- throws java.io.IOException
- {
- writer.write(textValue.toString());
- return this;
- }
-
- public XMLBuilder addComment(
- String commentValue)
- throws java.io.IOException
- {
- switch (state) {
- case STATE_ELEM_OPENED:
- writer.write('>');
- case STATE_NOTHING:
- if (butify) {
- writer.write('\n');
- }
- break;
- default:
- break;
- }
- writer.write("");
- if (butify) {
- writer.write('\n');
- }
- state = STATE_TEXT_ADDED;
-
- return this;
- }
-
- public XMLBuilder addElement(
- String elementName,
- String elementValue)
- throws java.io.IOException
- {
- this.startElement(elementName);
- this.addText(elementValue);
- this.endElement();
- return this;
- }
-
- public XMLBuilder addElementText(
- String elementName,
- String elementValue)
- throws java.io.IOException
- {
- this.startElement(elementName);
- this.addTextData(elementValue);
- this.endElement();
- return this;
- }
-
- public XMLBuilder flush()
- throws java.io.IOException
- {
- writer.flush();
- return this;
- }
-
- private XMLBuilder writeText(CharSequence textValue, boolean escape)
- throws java.io.IOException
- {
- if (textValue != null) {
- writer.write(escape ? XMLUtils.escapeXml(textValue) : textValue.toString());
- }
- return this;
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLConstants.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLConstants.java
deleted file mode 100644
index 8ad7a0ab3fa177f4e8a8c5bbe8ff1d6f82b7b56e..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLConstants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils.xml;
-
-/**
- XML Constants
-*/
-public class XMLConstants {
-
- public static final String XMLNS = "xmlns";
- public static final String NS_XML = "http://www.w3.org/TR/REC-xml";
- public static final String PREFIX_XML = "xml";
- public static final String ATTR_LANG = "lang";
-
- public static String XML_HEADER()
- {
- return "";
- }
-
- public static String XML_HEADER(String encoding)
- {
- return "";
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLException.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLException.java
deleted file mode 100644
index 17f69a4f6994d64d627f8c8105e86d954bcd2759..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils.xml;
-
-/**
- * XMLException
- */
-public class XMLException extends Exception
-{
- public XMLException(String message)
- {
- super(message);
- }
-
- public XMLException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
-}
diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLUtils.java
deleted file mode 100644
index ad6bab69acd82f916a2076eff8be041d304653ec..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.utils/src/org/jkiss/utils/xml/XMLUtils.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.utils.xml;
-
-import org.jkiss.code.NotNull;
-import org.jkiss.code.Nullable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Common XML utils
- */
-public class XMLUtils {
-
- public static Document parseDocument(String fileName)
- throws XMLException {
- return parseDocument(new java.io.File(fileName));
- }
-
- public static Document parseDocument(java.io.File file) throws XMLException {
- try (InputStream is = new FileInputStream(file)) {
- return parseDocument(new InputSource(is));
- } catch (IOException e) {
- throw new XMLException("Error opening file '" + file + "'", e);
- }
- }
-
- public static Document parseDocument(java.io.InputStream is) throws XMLException {
- return parseDocument(new InputSource(is));
- }
-
- public static Document parseDocument(java.io.Reader is) throws XMLException {
- return parseDocument(new InputSource(is));
- }
-
- public static Document parseDocument(InputSource source) throws XMLException {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder xmlBuilder = dbf.newDocumentBuilder();
- return xmlBuilder.parse(source);
- } catch (Exception er) {
- throw new XMLException("Error parsing XML document", er);
- }
- }
-
- public static Document createDocument()
- throws XMLException {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder xmlBuilder = dbf.newDocumentBuilder();
- return xmlBuilder.newDocument();
- } catch (Exception er) {
- throw new XMLException("Error creating XML document", er);
- }
- }
-
- public static Element getChildElement(Element element,
- String childName) {
- for (org.w3c.dom.Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE &&
- ((Element) node).getTagName().equals(childName)) {
- return (Element) node;
- }
- }
- return null;
- }
-
- @Nullable
- public static String getChildElementBody(Element element,
- String childName) {
- for (org.w3c.dom.Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE &&
- ((Element) node).getTagName().equals(childName)) {
- return getElementBody((Element) node);
- }
- }
- return null;
- }
-
- @Nullable
- public static String getElementBody(Element element) {
- org.w3c.dom.Node valueNode = element.getFirstChild();
- if (valueNode == null) {
- return null;
- }
- if (valueNode.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
- return valueNode.getNodeValue();
- } else {
- return null;
- }
- }
-
- // Get list of all child elements of specified node
- @NotNull
- public static List getChildElementList(
- Element parent,
- String nodeName) {
- List list = new ArrayList<>();
- for (org.w3c.dom.Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE &&
- nodeName.equals(node.getNodeName())) {
- list.add((Element) node);
- }
- }
- return list;
- }
-
- // Get list of all child elements of specified node
- @NotNull
- public static Collection getChildElementListNS(
- Element parent,
- String nsURI) {
- List list = new ArrayList<>();
- for (org.w3c.dom.Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE &&
- node.getNamespaceURI().equals(nsURI)) {
- list.add((Element) node);
- }
- }
- return list;
- }
-
- // Get list of all child elements of specified node
- public static Collection getChildElementListNS(
- Element parent,
- String nodeName,
- String nsURI) {
- List list = new ArrayList<>();
- for (org.w3c.dom.Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE &&
- node.getLocalName().equals(nodeName) &&
- node.getNamespaceURI().equals(nsURI)) {
- list.add((Element) node);
- }
- }
- return list;
- }
-
- // Get list of all child elements of specified node
- @NotNull
- public static Collection getChildElementList(
- Element parent,
- String[] nodeNameList) {
- List list = new ArrayList<>();
- for (org.w3c.dom.Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
- for (int i = 0; i < nodeNameList.length; i++) {
- if (node.getNodeName().equals(nodeNameList[i])) {
- list.add((Element) node);
- }
- }
- }
- }
- return list;
- }
-
- // Find one child element with specified name
- @Nullable
- public static Element findChildElement(
- Element parent) {
- for (org.w3c.dom.Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
- return (Element) node;
- }
- }
- return null;
- }
-
- public static Object escapeXml(Object obj) {
- if (obj == null) {
- return null;
- } else if (obj instanceof CharSequence) {
- return escapeXml((CharSequence) obj);
- } else {
- return obj;
- }
- }
-
- public static String escapeXml(CharSequence str) {
- if (str == null) {
- return null;
- }
- StringBuilder res = null;
- int strLength = str.length();
- for (int i = 0; i < strLength; i++) {
- char c = str.charAt(i);
- String repl = encodeXMLChar(c);
- if (repl == null) {
- if (res != null) {
- res.append(c);
- }
- } else {
- if (res == null) {
- res = new StringBuilder(str.length() + 5);
- for (int k = 0; k < i; k++) {
- res.append(str.charAt(k));
- }
- }
- res.append(repl);
- }
- }
- return res == null ? str.toString() : res.toString();
- }
-
- public static boolean isValidXMLChar(char c) {
- return (c >= 32 || c == '\n' || c == '\r' || c == '\t');
- }
-
- /**
- * Encodes a char to XML-valid form replacing &,',",<,> with special XML encoding.
- *
- * @param ch char to convert
- * @return XML-encoded text
- */
- public static String encodeXMLChar(char ch) {
- switch (ch) {
- case '&':
- return "&";
- case '\"':
- return """;
- case '\'':
- return "'";
- case '<':
- return "<";
- case '>':
- return ">";
- default:
- return null;
- }
- }
-
- public static XMLException adaptSAXException(Exception toCatch) {
- if (toCatch instanceof XMLException) {
- return (XMLException) toCatch;
- } else if (toCatch instanceof org.xml.sax.SAXException) {
- String message = toCatch.getMessage();
- Exception embedded = ((org.xml.sax.SAXException) toCatch).getException();
- if (embedded != null && embedded.getMessage() != null && embedded.getMessage().equals(message)) {
- // Just SAX wrapper - skip it
- return adaptSAXException(embedded);
- } else {
- return new XMLException(
- message,
- embedded != null ? adaptSAXException(embedded) : null);
- }
- } else {
- return new XMLException(toCatch.getMessage(), toCatch);
- }
- }
-
- public static Collection getChildElementList(Element element) {
- List children = new ArrayList<>();
- for (org.w3c.dom.Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
- children.add((Element) node);
- }
- }
- return children;
- }
-}
diff --git a/modules/org.jkiss.wmi/.classpath b/modules/org.jkiss.wmi/.classpath
deleted file mode 100644
index 9131793b8a36bd54c12e85496a69430dfe62fc6d..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/modules/org.jkiss.wmi/.project b/modules/org.jkiss.wmi/.project
deleted file mode 100644
index ebead11bc7bf0d18d4747991a987dd6b89df3fbb..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.jkiss.wmi
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/modules/org.jkiss.wmi/.settings/org.eclipse.jdt.core.prefs b/modules/org.jkiss.wmi/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9a101d9ec1bcefef357a90e4b50e99c7a0ba5a83..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,8 +0,0 @@
-#Fri Dec 30 22:00:36 MSK 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/modules/org.jkiss.wmi/META-INF/MANIFEST.MF b/modules/org.jkiss.wmi/META-INF/MANIFEST.MF
deleted file mode 100644
index bac835e2f8582cc5f3976c887f2a4ea49fc2c0c9..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,9 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name
-Bundle-SymbolicName: org.jkiss.wmi
-Bundle-Version: 2.0.61
-Bundle-Release-Date: 20171030
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Bundle-Vendor: %Bundle-Vendor
-Export-Package: org.jkiss.wmi.service
diff --git a/modules/org.jkiss.wmi/OSGI-INF/l10n/bundle.properties b/modules/org.jkiss.wmi/OSGI-INF/l10n/bundle.properties
deleted file mode 100644
index b5aa18266d7de84e64203d6bad872252bc390674..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/OSGI-INF/l10n/bundle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Properties file for org.jkiss.wmi
-Bundle-Vendor = JKISS
-Bundle-Name = JKISS WMI native interface
diff --git a/modules/org.jkiss.wmi/build.properties b/modules/org.jkiss.wmi/build.properties
deleted file mode 100644
index 84998730714e09564349d79518a62ff4396aae1e..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/build.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-source.. = src/java
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- native/,\
- OSGI-INF/
diff --git a/modules/org.jkiss.wmi/copy_contrib.cmd b/modules/org.jkiss.wmi/copy_contrib.cmd
deleted file mode 100644
index 552a4d1b6f1c5e45dd28265553aff812ab217e80..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/copy_contrib.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
-copy .\lib\jkiss_wmi_x86.dll ..\..\contrib\drivers\wmi\x86\jkiss_wmi.dll
-copy .\lib\jkiss_wmi_x64.dll ..\..\contrib\drivers\wmi\x64\jkiss_wmi.dll
\ No newline at end of file
diff --git a/modules/org.jkiss.wmi/native/x64/jkiss_wmi.dll b/modules/org.jkiss.wmi/native/x64/jkiss_wmi.dll
deleted file mode 100644
index cdb6bd46e50e7dd28a5b0e72c1da793f783b0043..0000000000000000000000000000000000000000
Binary files a/modules/org.jkiss.wmi/native/x64/jkiss_wmi.dll and /dev/null differ
diff --git a/modules/org.jkiss.wmi/native/x86/jkiss_wmi.dll b/modules/org.jkiss.wmi/native/x86/jkiss_wmi.dll
deleted file mode 100644
index 44ef5b99bc06682ce1e6af07e9bae4a080dd517f..0000000000000000000000000000000000000000
Binary files a/modules/org.jkiss.wmi/native/x86/jkiss_wmi.dll and /dev/null differ
diff --git a/modules/org.jkiss.wmi/pom.xml b/modules/org.jkiss.wmi/pom.xml
deleted file mode 100644
index 9e9cc39ae8e998f20d7862a3573ac377cd14401e..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/pom.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- 4.0.0
-
- org.jkiss.dbeaver
- dbeaver
- 1.0.0
- ../../
-
- org.jkiss.wmi
- 2.0.61
- eclipse-plugin
-
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIConstants.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIConstants.java
deleted file mode 100644
index ff7141b53e7db538c0424b22e57bfb6fc897c1ec..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIConstants.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.service;
-
-/**
- * WMI constants
- */
-public class WMIConstants {
-
- public static final int CIM_ILLEGAL = 4095; // 0xFFF
- public static final int CIM_EMPTY = 0; // 0x0
- public static final int CIM_SINT8 = 16; // 0x10
- public static final int CIM_UINT8 = 17; // 0x11
- public static final int CIM_SINT16 = 2; // 0x2
- public static final int CIM_UINT16 = 18; // 0x12
- public static final int CIM_SINT32 = 3; // 0x3
- public static final int CIM_UINT32 = 19; // 0x13
- public static final int CIM_SINT64 = 20; // 0x14
- public static final int CIM_UINT64 = 21; // 0x15
- public static final int CIM_REAL32 = 4; // 0x4
- public static final int CIM_REAL64 = 5; // 0x5
- public static final int CIM_BOOLEAN = 11; // 0xB
- public static final int CIM_STRING = 8; // 0x8
- public static final int CIM_DATETIME = 101; // 0x65
- public static final int CIM_REFERENCE = 102; // 0x66
- public static final int CIM_CHAR16 = 103; // 0x67
- public static final int CIM_OBJECT = 13; // 0xD
- public static final int CIM_FLAG_ARRAY = 8192; // 0x2000
-
- public static final long WBEM_FLAG_RETURN_IMMEDIATELY = 0x10;
- public static final long WBEM_FLAG_RETURN_WBEM_COMPLETE = 0;
- public static final long WBEM_FLAG_BIDIRECTIONAL = 0;
- public static final long WBEM_FLAG_FORWARD_ONLY = 0x20;
- public static final long WBEM_FLAG_NO_ERROR_OBJECT = 0x40;
- public static final long WBEM_FLAG_RETURN_ERROR_OBJECT = 0;
- public static final long WBEM_FLAG_SEND_STATUS = 0x80;
- public static final long WBEM_FLAG_DONT_SEND_STATUS = 0;
- public static final long WBEM_FLAG_ENSURE_LOCATABLE = 0x100;
- public static final long WBEM_FLAG_DIRECT_READ = 0x200;
- public static final long WBEM_FLAG_SEND_ONLY_SELECTED = 0;
- public static final long WBEM_RETURN_WHEN_COMPLETE = 0;
- public static final long WBEM_RETURN_IMMEDIATELY = 0x10;
- public static final long WBEM_MASK_RESERVED_FLAGS = 0x1f000;
- public static final long WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000;
- public static final long WBEM_FLAG_STRONG_VALIDATION = 0x100000;
-
-
- public static final long WBEM_FLAG_DEEP = 0;
- public static final long WBEM_FLAG_SHALLOW = 1;
- public static final long WBEM_FLAG_PROTOTYPE = 2;
-
- // Condition flags
- public static final long WBEM_FLAG_ALWAYS = 0;
- public static final long WBEM_FLAG_ONLY_IF_TRUE = 0x1;
- public static final long WBEM_FLAG_ONLY_IF_FALSE = 0x2;
- public static final long WBEM_FLAG_ONLY_IF_IDENTICAL = 0x3;
- public static final long WBEM_MASK_PRIMARY_CONDITION = 0x3;
- public static final long WBEM_FLAG_KEYS_ONLY = 0x4;
- public static final long WBEM_FLAG_REFS_ONLY = 0x8;
- public static final long WBEM_FLAG_LOCAL_ONLY = 0x10;
- public static final long WBEM_FLAG_PROPAGATED_ONLY = 0x20;
- public static final long WBEM_FLAG_SYSTEM_ONLY = 0x30;
- public static final long WBEM_FLAG_NONSYSTEM_ONLY = 0x40;
- public static final long WBEM_MASK_CONDITION_ORIGIN = 0x70;
- public static final long WBEM_FLAG_CLASS_OVERRIDES_ONLY = 0x100;
- public static final long WBEM_FLAG_CLASS_LOCAL_AND_OVERRIDES = 0x200;
- public static final long WBEM_MASK_CLASS_CONDITION = 0x300;
-
- // Flavor types
- public static final long WBEM_FLAVOR_DONT_PROPAGATE = 0;
- public static final long WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE = 0x1;
- public static final long WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS = 0x2;
- public static final long WBEM_FLAVOR_MASK_PROPAGATION = 0xf;
- public static final long WBEM_FLAVOR_OVERRIDABLE = 0;
- public static final long WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10;
- public static final long WBEM_FLAVOR_MASK_PERMISSIONS = 0x10;
- public static final long WBEM_FLAVOR_ORIGIN_LOCAL = 0;
- public static final long WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20;
- public static final long WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40;
- public static final long WBEM_FLAVOR_MASK_ORIGIN = 0x60;
- public static final long WBEM_FLAVOR_NOT_AMENDED = 0;
- public static final long WBEM_FLAVOR_AMENDED = 0x80;
- public static final long WBEM_FLAVOR_MASK_AMENDED = 0x80;
-
- // Class properties
-
- public static final String CLASS_PROP_CLASS_NAME = "__CLASS";
- public static final String CLASS_PROP_SUPER_CLASS = "__SUPERCLASS";
- public static final String CLASS_PROP_PATH = "__PATH";
-
- // Standard qualifiers
-
- public static final String Q_Abstract = "Abstract";
- public static final String Q_Aggregate = "Aggregate";
- public static final String Q_Aggregation = "Aggregation";
- public static final String Q_Association = "Association";
- public static final String Q_Alias = "Alias";
- public static final String Q_ArrayType = "ArrayType";
- public static final String Q_BitMap = "BitMap";
- public static final String Q_BitValues = "BitValues";
- public static final String Q_Constructor = "Constructor";
- public static final String Q_CreateBy = "CreateBy";
- public static final String Q_DeleteBy = "DeleteBy";
- public static final String Q_Description = "Description";
- public static final String Q_Destructor = "Destructor";
- public static final String Q_DisplayName = "DisplayName";
- public static final String Q_Gauge = "Gauge";
- public static final String Q_In = "In";
- public static final String Q_InOut = "In, Out";
- public static final String Q_Key = "Key";
- public static final String Q_Lazy = "Lazy";
- public static final String Q_MappingStrings = "MappingStrings";
- public static final String Q_Max = "Max";
- public static final String Q_MaxLen = "MaxLen";
- public static final String Q_MaxValue = "MaxValue";
- public static final String Q_Min = "Min";
- public static final String Q_MinValue = "MinValue";
- public static final String Q_ModelCorrespondence = "ModelCorrespondence";
- public static final String Q_Nonlocal = "Nonlocal";
- public static final String Q_NonlocalType = "NonlocalType";
- public static final String Q_NullValue = "NullValue";
- public static final String Q_Out = "Out";
- public static final String Q_Override = "Override";
- public static final String Q_Propagated = "Propagated";
- public static final String Q_Read = "Read";
- public static final String Q_Required = "Required";
- public static final String Q_Revision = "Revision";
- public static final String Q_Schema = "Schema";
- public static final String Q_Source = "Source";
- public static final String Q_SourceType = "SourceType";
- public static final String Q_SupportsCreate = "SupportsCreate";
- public static final String Q_SupportsDelete = "SupportsDelete";
- public static final String Q_SupportsUpdate = "SupportsUpdate";
- public static final String Q_Terminal = "Terminal";
- public static final String Q_Units = "Units";
- public static final String Q_ValueMap = "ValueMap";
- public static final String Q_Values = "Values";
- public static final String Q_Version = "Version";
- public static final String Q_Weak = "Weak";
- public static final String Q_Write = "Write";
- public static final String Q_WriteAtCreate = "WriteAtCreate";
- public static final String Q_WriteAtUpdate = "WriteAtUpdate";
-
-
- public static final String Q_CIMTYPE = "CIMTYPE";
- public static final String Q_CIM_Key = "CIM_Key";
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIDataType.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIDataType.java
deleted file mode 100644
index fd0d72e85aed63740fac5e35a02b90605ae6a6d3..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIDataType.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * WMI data type
- */
-public enum WMIDataType {
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIException.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIException.java
deleted file mode 100644
index 240b79cdb0f06708813db15555b7a5e91577fa03..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * WMIException
- */
-public class WMIException extends Exception {
-
- public WMIException(String message) {
- super(message);
- }
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObject.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObject.java
deleted file mode 100644
index 32ce7ee217007d65fed1a86cfa7fb7692c9bc8e7..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObject.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.service;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * WQL ResultSet
- */
-public class WMIObject extends WMIQualifiedObject {
-
- private long objectHandle;
-
- public WMIObject() {
- }
-
- public String getObjectText()
- throws WMIException
- {
- return readObjectText();
- }
-
- public Object getValue(String name) throws WMIException
- {
- return readAttributeValue(name);
- }
-
- public void setValue(String name, Object value) throws WMIException
- {
- writeAttributeValue(name, value);
- }
-
- public Collection getAttributes(long flags) throws WMIException
- {
- List attributes = new ArrayList<>();
- readAttributes(flags, attributes);
- return attributes;
- }
-
- public Collection getMethods(long flags) throws WMIException
- {
- List methods = new ArrayList<>();
- readMethods(flags, methods);
- return methods;
- }
-
- public void release()
- {
- releaseObject();
- }
-
- @Override
- protected void finalize() throws Throwable
- {
- releaseObject();
- super.finalize();
- }
-
- @Override
- protected void readObjectQualifiers(List qualifiers)
- throws WMIException
- {
- readQualifiers(false, null, qualifiers);
- }
-
- @Override
- public String toString()
- {
- return "WMIObject:" + objectHandle;
- }
-
- private native String readObjectText()
- throws WMIException;
-
- private native Object readAttributeValue(String name)
- throws WMIException;
-
- private native void writeAttributeValue(String name, Object value)
- throws WMIException;
-
- private native void readAttributes(long flags, List attributes)
- throws WMIException;
-
- private native void readMethods(long flags, List method)
- throws WMIException;
-
- native void readQualifiers(boolean isAttribute, String attrName, List qualifiers)
- throws WMIException;
-
- native void releaseObject();
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectAttribute.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectAttribute.java
deleted file mode 100644
index 42d8043b15b21698531f45d3bc56fe284b7e4074..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectAttribute.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * WMI object property
- */
-public class WMIObjectAttribute extends WMIObjectElement
-{
-
- private int type;
- private int flavor;
- private Object value;
-
- public WMIObjectAttribute(WMIObject owner, String name, int type, int flavor, Object value)
- {
- super(owner, name);
- this.type = type;
- this.flavor = flavor;
- this.value = value;
- }
-
- public int getType()
- {
- return type;
- }
-
- public int getFlavor()
- {
- return flavor;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public boolean isSystem()
- {
- return getName().startsWith("__");
- }
-
- @Override
- public String toString()
- {
- return getName() + "=" + value;
- }
-
- public String getTypeName()
- {
- int type = getType();
- if ((type & WMIConstants.CIM_FLAG_ARRAY) != 0) {
- return getCIMTypeName(type ^ WMIConstants.CIM_FLAG_ARRAY) + "[]";
- } else {
- return getCIMTypeName(type);
- }
- }
-
- public static String getCIMTypeName(int type)
- {
- switch (type) {
- case WMIConstants.CIM_ILLEGAL: return "Illegal";
- case WMIConstants.CIM_EMPTY: return "Empty";
- case WMIConstants.CIM_SINT8: return "Int8";
- case WMIConstants.CIM_UINT8: return "UInt8";
- case WMIConstants.CIM_SINT16: return "Int16";
- case WMIConstants.CIM_UINT16: return "UInt16";
- case WMIConstants.CIM_SINT32: return "Int32";
- case WMIConstants.CIM_UINT32: return "UInt32";
- case WMIConstants.CIM_SINT64: return "Int64";
- case WMIConstants.CIM_UINT64: return "UInt64";
- case WMIConstants.CIM_REAL32: return "Real32";
- case WMIConstants.CIM_REAL64: return "Real64";
- case WMIConstants.CIM_BOOLEAN: return "Boolean";
- case WMIConstants.CIM_STRING: return "String";
- case WMIConstants.CIM_DATETIME: return "DateTime";
- case WMIConstants.CIM_REFERENCE: return "Reference";
- case WMIConstants.CIM_CHAR16: return "Char";
- case WMIConstants.CIM_OBJECT: return "Object";
- default: return "Unknown (" + type + ")";
- }
- }
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectElement.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectElement.java
deleted file mode 100644
index 2a26efed7736261c92331e43cbdf3776b9327934..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectElement.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-import java.util.List;
-
-/**
- * Object element (property or method)
- */
-public abstract class WMIObjectElement extends WMIQualifiedObject {
-
- private WMIObject owner;
- private String name;
-
- protected WMIObjectElement(WMIObject owner, String name)
- {
- this.owner = owner;
- this.name = name;
- }
-
- public WMIObject getOwner()
- {
- return owner;
- }
-
- public String getName()
- {
- return name;
- }
-
- @Override
- protected void readObjectQualifiers(List qualifiers) throws WMIException
- {
- getOwner().readQualifiers(this instanceof WMIObjectAttribute, getName(), qualifiers);
- }
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectMethod.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectMethod.java
deleted file mode 100644
index c2a29debb33a1a9874fae1d5ea2114f9a4705a6f..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectMethod.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.service;
-
-/**
- * WMI object property
- */
-public class WMIObjectMethod extends WMIObjectElement
-{
-
- private WMIObject inParameter;
- private WMIObject outParameter;
-
- public WMIObjectMethod(WMIObject owner, String name, WMIObject inParameter, WMIObject outParameter)
- {
- super(owner, name);
- this.inParameter = inParameter;
- this.outParameter = outParameter;
- }
-
- public WMIObject getInParameter()
- {
- return inParameter;
- }
-
- public WMIObject getOutParameter()
- {
- return outParameter;
- }
-
- @Override
- public String toString()
- {
- return getName() + "()";
- }
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSink.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSink.java
deleted file mode 100644
index b91716a057c158ef090f948f3bac3c60d56c1519..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSink.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * Object sink
- */
-public interface WMIObjectSink {
-
- void indicate(WMIObject[] objects);
-
- void setStatus(WMIObjectSinkStatus status, int result, String param, WMIObject errorObject);
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSinkStatus.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSinkStatus.java
deleted file mode 100644
index af4db3cf15cde4aeb2e5c1c3d86c452125ed5f52..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIObjectSinkStatus.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * Sink status
- */
-public enum WMIObjectSinkStatus {
- unknown,
- complete,
- progress,
- requirements,
- error,
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifiedObject.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifiedObject.java
deleted file mode 100644
index 371698a3b73f97a379b35adaaba3ff900e834e56..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifiedObject.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Qualified object
- */
-public abstract class WMIQualifiedObject {
-
- private volatile List qualifiers;
-
- public Collection getQualifiers()
- throws WMIException
- {
- if (qualifiers == null) {
- synchronized (this) {
- if (qualifiers == null) {
- qualifiers = new ArrayList<>();
- readObjectQualifiers(qualifiers);
- }
- }
- }
- return qualifiers;
- }
-
- public Object getQualifier(String name)
- throws WMIException
- {
- for (WMIQualifier q : getQualifiers()) {
- if (q.getName().equalsIgnoreCase(name)) {
- return q.getValue();
- }
- }
- return null;
- }
-
- protected abstract void readObjectQualifiers(List qualifiers) throws WMIException;
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifier.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifier.java
deleted file mode 100644
index 956d9b418de8361e407919b4fb8e8337a25d89fe..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIQualifier.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.service;
-
-/**
- * Qualifier
- */
-public class WMIQualifier {
-
- private final String name;
- private final Object value;
- private final int flavor;
-
- public WMIQualifier(String name, int flavor, Object value)
- {
- this.name = name;
- this.flavor = flavor;
- this.value = value;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public int getFlavor()
- {
- return flavor;
- }
-
- @Override
- public String toString()
- {
- return name + "=" + value;
- }
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIService.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIService.java
deleted file mode 100644
index 17a9c7e15fe923762d52cacb9c938e70be667e9d..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMIService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.service;
-
-/**
- * WMI Service
- * Uses native Win32 API access
- */
-public class WMIService {
-
-// static {
-// String arch = System.getProperty("os.arch");
-// if (arch != null && arch.indexOf("64") != -1) {
-// System.loadLibrary("jkiss_wmi_x86_64");
-// } else {
-// System.loadLibrary("jkiss_wmi_x86");
-// }
-// }
-
- public static void linkNative(String libPath)
- {
- System.load(libPath);
- }
-
- private long serviceHandle = 0l;
-
- public static native WMIService connect(String domain, String host, String user, String password, String locale, String resource)
- throws WMIException;
-
- public native WMIService openNamespace(String namespace)
- throws WMIException;
-
- public native void executeQuery(String query, WMIObjectSink sink, long flags)
- throws WMIException;
-
- public native void enumClasses(String superClass, WMIObjectSink sink, long flags)
- throws WMIException;
-
- public native void enumInstances(String className, WMIObjectSink sink, long flags)
- throws WMIException;
-
- public native void cancelSink(WMIObjectSink sink)
- throws WMIException;
-
- public native void close();
-
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMISinkStatus.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMISinkStatus.java
deleted file mode 100644
index 86ce77c4b9762ce1ca2cfb2533ee0d597885752a..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/service/WMISinkStatus.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jkiss.wmi.service;
-
-/**
- * Sink status
- */
-public enum WMISinkStatus {
- complete,
- progress,
- requirements
-}
diff --git a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/test/TestService.java b/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/test/TestService.java
deleted file mode 100644
index 63577e13ab19585a200c3f080d0eaa6be1b339eb..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/java/org/jkiss/wmi/test/TestService.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * DBeaver - Universal Database Manager
- * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jkiss.wmi.test;
-
-import org.jkiss.wmi.service.*;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * WMI Service tester
- */
-public class TestService {
-
- private WMIService service;
- private boolean finished = false;
- private WMIService nsService;
-
- public TestService()
- {
- }
-
- public static void main(String[] args)
- {
- new TestService()
- .test();
- }
-
- void test()
- {
- try {
- {
- Thread testThread = new Thread() {
- @Override
- public void run()
- {
- try {
- service = WMIService.connect(null, "localhost", null, null, null, "root");
- ObjectCollectorSink classesSink = new ObjectCollectorSink();
- service.enumClasses(null, classesSink, 0);
- classesSink.waitForFinish();
- Thread.sleep(10000);
-
- } catch (WMIException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- };
- testThread.start();
- Thread.sleep(1000);
- }
-
- {
- Thread testThread2 = new Thread() {
- @Override
- public void run()
- {
- try {
- testNamespace();
- } catch (WMIException e) {
- e.printStackTrace();
- }
- }
- };
- testThread2.start();
- testThread2.join();
- }
-
- } catch (InterruptedException e) {
- // do nothing
- } finally {
- service.close();
- }
-
- System.gc();
- System.out.println("DONE");
- System.exit(0);
- }
-
- private void testNamespace()
- throws WMIException
- {
- //WMIService.initializeThread();
-
- ObjectCollectorSink classesSink;
-
- nsService = service.openNamespace("cimv2");
- ObjectCollectorSink tmpSink = new ObjectCollectorSink();
- nsService.executeQuery("SELECT * FROM Win32_Process", tmpSink, WMIConstants.WBEM_FLAG_SEND_STATUS);
- tmpSink.waitForFinish();
- for (WMIObject o : tmpSink.objectList) {
- System.out.println("=============");
-// for (WMIObjectAttribute attr : o.getAttributes(WMIConstants.WBEM_FLAG_ALWAYS)) {
-// System.out.println(attr.toString());
-// }
- System.out.println("Caption=" + o.getValue("Caption"));
- System.out.println("CommandLine=" + o.getValue("CommandLine"));
- System.out.println("CreationClassName=" + o.getValue("CreationClassName"));
- System.out.println("CreationDate=" + o.getValue("CreationDate"));
- }
- }
-
- private static void printObject(WMIObject object)
- {
- try {
- System.out.println("====== " + object.getObjectText());
- } catch (WMIException e) {
- e.printStackTrace();
- }
- }
-
- private static void examineObject(WMIObject object) throws WMIException
- {
- final String objectText = object.getObjectText();
- //final Object name = object.getValue("Name");
-
- for (WMIObjectAttribute prop : object.getAttributes(WMIConstants.WBEM_FLAG_ALWAYS)) {
- Object propValue = prop.getValue();
- if (propValue instanceof Object[]) {
- //System.out.print("\t" + prop.getName() + "= { ");
- Object[] array = (Object[])propValue;
- for (int i = 0; i < array.length; i++) {
- //if (i > 0) System.out.print(", ");
- //System.out.print("'" + array[i] + "'");
- }
- //System.out.println(" }");
- } else if (propValue instanceof byte[]) {
- //System.out.println("\t" + prop.getName() + "= { byte array } " + ((byte[])propValue).length);
- } else {
- //System.out.println("\t" + prop.getName() + "=" + propValue);
- }
- }
- }
-
- private class ObjectCollectorSink implements WMIObjectSink
- {
- private final List objectList;
- private boolean finished = false;
-
- public ObjectCollectorSink()
- {
- this.objectList = new ArrayList<>();
- }
-
- @Override
- public void indicate(WMIObject[] objects)
- {
- Collections.addAll(objectList, objects);
- }
-
- @Override
- public void setStatus(WMIObjectSinkStatus status, int result, String param, WMIObject errorObject)
- {
- if (status == WMIObjectSinkStatus.complete) {
- finished = true;
- }
- }
-
- public void waitForFinish()
- {
- try {
- while (!finished) {
- Thread.sleep(100);
- }
- //service.cancelAsyncOperation(wmiObjectSink);
- }
- catch (InterruptedException e) {
- // do nothing
- }
- }
- }
-}
diff --git a/modules/org.jkiss.wmi/src/native/JNIMetaData.cpp b/modules/org.jkiss.wmi/src/native/JNIMetaData.cpp
deleted file mode 100644
index e6ad051605a4566fe7f2e9fce515c41fa2178d23..0000000000000000000000000000000000000000
--- a/modules/org.jkiss.wmi/src/native/JNIMetaData.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-#include "StdAfx.h"
-#include "JNIMetaData.h"
-#include "WMIUtils.h"
-#include