Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INF-10 Move utils to dbeaver-common. Refactor WMI #1

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/workflows/maven.yml

This file was deleted.

49 changes: 0 additions & 49 deletions modules/com.dbeaver.common.rest.client/pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: DBeaver REST clients
Bundle-SymbolicName: com.dbeaver.common.rest.client
Bundle-Version: 1.0.0
Bundle-SymbolicName: org.jkiss.common.rest
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20231225
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: com.dbeaver.lm.api
Expand Down
3 changes: 3 additions & 0 deletions modules/org.jkiss.common.rest/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source.. = src/
output.. = target/classes/
bin.includes = META-INF/,.
18 changes: 18 additions & 0 deletions modules/org.jkiss.common.rest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>com.dbeaver.common</groupId>
<artifactId>com.dbeaver.common.modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>org.jkiss.common.rest</artifactId>
<packaging>eclipse-plugin</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>REST clients</name>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.common.rest.client;
package org.jkiss.common.rest.client;


public abstract class AbstractRemoteClient {
Expand Down
17 changes: 17 additions & 0 deletions modules/org.jkiss.utils/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DBeaver Utils
Bundle-Vendor: DBeaver Corp
Bundle-SymbolicName: org.jkiss.utils
Bundle-Version: 2.1.207.qualifier
Bundle-Release-Date: 20240205
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: com.google.gson
Export-Package: org.jkiss.code,
org.jkiss.utils,
org.jkiss.utils.csv,
org.jkiss.utils.io,
org.jkiss.utils.rest,
org.jkiss.utils.time,
org.jkiss.utils.xml
Automatic-Module-Name: org.jkiss.utils
3 changes: 3 additions & 0 deletions modules/org.jkiss.utils/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source.. = src/
output.. = target/classes/
bin.includes = META-INF/,.
14 changes: 14 additions & 0 deletions modules/org.jkiss.utils/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dbeaver.common</groupId>
<artifactId>com.dbeaver.common.modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.utils</artifactId>
<version>2.1.207-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
25 changes: 25 additions & 0 deletions modules/org.jkiss.utils/src/org/jkiss/code/NotNull.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* 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 {

}
25 changes: 25 additions & 0 deletions modules/org.jkiss.utils/src/org/jkiss/code/Nullable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* 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 {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* 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 java.util.Comparator;

/**
* A comparator for comparing two strings lexicographically, treating them as sequences of alphanumeric characters.
* <p>
* This comparator compares strings based on their alphanumeric content. It considers
* the characters in the strings as a sequence of alphanumeric characters (letters and digits)
* and compares them lexicographically. The comparison is case-insensitive.
*/
public class AlphanumericComparator implements Comparator<CharSequence> {
private static final AlphanumericComparator INSTANCE = new AlphanumericComparator();

private AlphanumericComparator() {
// prevents instantiation
}

@NotNull
public static AlphanumericComparator getInstance() {
return INSTANCE;
}

@Override
public int compare(CharSequence o1, CharSequence o2) {
final int len1 = o1.length();
final int len2 = o2.length();

int i = 0;
int j = 0;

while (i < len1 && j < len2) {
final char ch1 = Character.toUpperCase(o1.charAt(i));
final char ch2 = Character.toUpperCase(o2.charAt(i));

if (Character.isDigit(ch1) && Character.isDigit(ch2)) {
int num1 = 0;
int num2 = 0;

while (i < len1 && Character.isDigit(o1.charAt(i))) {
num1 = num1 * 10 + Character.digit(o1.charAt(i), 10);
i += 1;
}

while (j < len2 && Character.isDigit(o2.charAt(j))) {
num2 = num2 * 10 + Character.digit(o2.charAt(j), 10);
j += 1;
}

if (num1 != num2) {
return num1 - num2;
}
} else {
if (ch1 != ch2) {
return ch1 - ch2;
}

i += 1;
j += 1;
}
}

return len1 - len2;
}
}
Loading