Skip to content

Commit

Permalink
Merge pull request #45 from trydofor/develop
Browse files Browse the repository at this point in the history
v2.7.3 with minor change
  • Loading branch information
trydofor authored Aug 31, 2024
2 parents 96d19eb + 858dcc7 commit 5e81078
Show file tree
Hide file tree
Showing 121 changed files with 3,757 additions and 859 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jobs:
if: steps.settings.outputs.MVN_DEPLOY_OSSRH == 'true'
run: >
mvn
-P 'deploy,ossrh'
-P 'deploy,deploy-ossrh'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
deploy
Expand All @@ -192,7 +192,7 @@ jobs:
continue-on-error: ${{ inputs.deployAltrh != 'true' }}
run: >
mvn
-P 'deploy,altrh'
-P 'deploy,deploy-altrh,deploy-old'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
deploy
Expand Down
57 changes: 53 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</issueManagement>

<properties>
<revision>2.7.2-SNAPSHOT</revision>
<revision>2.7.3-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down Expand Up @@ -295,7 +295,6 @@
<exclude>**/data/U.*</exclude>
<exclude>**/data/U$*</exclude>
<!-- exception thrown -->
<exclude>**/flow/FlowBreak.*</exclude>
<exclude>**/evil/*Attention.*</exclude>
<!-- stat manually checked -->
<exclude>**/stat/GitStat*</exclude>
Expand Down Expand Up @@ -339,6 +338,7 @@
<id>deploy</id>
<properties>
<maven.test.skip>true</maven.test.skip>
<maven.install.skip>true</maven.install.skip>
</properties>
<build>
<plugins>
Expand All @@ -363,7 +363,7 @@
</build>
</profile>
<profile>
<id>ossrh</id>
<id>deploy-ossrh</id>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -392,13 +392,62 @@
</distributionManagement>
</profile>
<profile>
<id>altrh</id>
<id>deploy-altrh</id>
<properties>
<!--suppress UnresolvedMavenProperty -->
<altReleaseDeploymentRepository>altrh::${MVN_ALT_REPO}</altReleaseDeploymentRepository>
<!--suppress UnresolvedMavenProperty -->
<altSnapshotDeploymentRepository>altrh::${MVN_ALT_SNAP}</altSnapshotDeploymentRepository>
</properties>
</profile>
<profile>
<id>deploy-old</id>
<properties>
<deploy.old.todir>${project.build.directory}/old-build</deploy.old.todir>
<deploy.old.files>${project.artifactId}-${project.version}*</deploy.old.files>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<!-- Backup before packaging -->
<execution>
<id>backup-artifacts</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${deploy.old.todir}" failonerror="false"/>
<copy todir="${deploy.old.todir}" overwrite="true">
<fileset dir="${project.build.directory}" includes="${deploy.old.files}"/>
</copy>
</target>
</configuration>
</execution>
<!-- Restore artifacts before deployment -->
<execution>
<id>restore-artifacts</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.directory}" overwrite="true">
<fileset dir="${deploy.old.todir}" includes="${deploy.old.files}" erroronmissingdir="false"/>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
14 changes: 9 additions & 5 deletions src/main/java/pro/fessional/mirana/best/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import org.jetbrains.annotations.NotNull;

import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author trydofor
Expand All @@ -17,7 +21,7 @@ public interface Param {
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PARAMETER)
@NotNull
@interface Out {
public @interface Out {
String value() default "";
}

Expand All @@ -28,7 +32,7 @@ public interface Param {
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PARAMETER)
@NotNull
@interface InOut {
public @interface InOut {
String value() default "";
}

Expand All @@ -38,7 +42,7 @@ public interface Param {
@Documented
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PARAMETER)
@interface HadClose {
public @interface HadClose {
String value() default "";
}

Expand All @@ -49,7 +53,7 @@ public interface Param {
@Documented
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PARAMETER)
@interface NotClose {
public @interface NotClose {
String value() default "";
}
}
82 changes: 79 additions & 3 deletions src/main/java/pro/fessional/mirana/bits/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,82 @@
*/
public class Base64 {

public static boolean isB64(char c) {
return ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
c == '=' ||
c == '-' || c == '_' ||
c == '+' || c == '/');
}

public static boolean isB64(char c, boolean urlSafe) {
return ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
c == '=' ||
(urlSafe && (c == '-' || c == '_')) ||
(!urlSafe && (c == '+' || c == '/')));
}

/**
* check base64 char URLSAFE and Default, empty string means false always
*/
public static boolean isB64(String b64) {
if (b64 == null) return false;
final int len = b64.length();
if (len == 0) return false;
for (int i = 0; i < len; i++) {
char c = b64.charAt(i);
if (!isB64(c)) return false;
}
return true;
}

/**
* check base64 char URLSAFE or Default, empty string means false always
*/
public static boolean isB64(String b64, boolean urlSafe) {
if (b64 == null) return false;
final int len = b64.length();
if (len == 0) return false;
for (int i = 0; i < len; i++) {
char c = b64.charAt(i);
if (!isB64(c, urlSafe)) return false;
}
return true;
}

/**
* check base64 char URLSAFE and Default, empty string means false always
*/
public static boolean asB64(String b64) {
if (b64 == null) return false;
final int len = b64.length();
int i = 0;
for (; i < len; i++) {
char c = b64.charAt(i);
if (Bytes.isPad(c)) continue;
if (!isB64(c)) return false;
}
return i > 0;
}

/**
* check base64 char URLSAFE or Default, empty string means false always
*/
public static boolean asB64(String b64, boolean urlSafe) {
if (b64 == null) return false;
final int len = b64.length();
int i = 0;
for (; i < len; i++) {
char c = b64.charAt(i);
if (Bytes.isPad(c)) continue;
if (!isB64(c, urlSafe)) return false;
}
return i > 0;
}

public static java.util.Base64.Encoder getEncoder(boolean urlSafe) {
return getEncoder(urlSafe, true);
}
Expand Down Expand Up @@ -117,9 +193,9 @@ public static String de2str(@Nullable InputStream ins) {
break;
}
}
java.util.Base64.Decoder decoder = urlSafe ?
java.util.Base64.getUrlDecoder() :
java.util.Base64.getDecoder();
java.util.Base64.Decoder decoder = urlSafe
? java.util.Base64.getUrlDecoder()
: java.util.Base64.getDecoder();
return decoder.decode(bytes);
}

Expand Down
78 changes: 75 additions & 3 deletions src/main/java/pro/fessional/mirana/bits/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,78 @@
*/
public class Bytes {

/**
* check the hex char
*/
public static boolean isHex(char c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}

/**
* check the padding white char (0x20,\t\r\n)
*/
public static boolean isPad(char c) {
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}

/**
* check the hex string exactly.
* empty string means false always
*/
public static boolean isHex(@Nullable String hex) {
return isHex(hex, 0);
}

/**
* check the hex string and its length(0 do NOT check length) exactly.
* empty string means false always
*/
public static boolean isHex(@Nullable String hex, int len) {
if (hex == null) return false;

final int sz = hex.length();
if (sz == 0 || len > 0 && sz != len) return false;

int i = 0;
for (; i < sz; i++) {
if (!isHex(hex.charAt(i))) return false;
}
return i == sz;
}

/**
* check the hex string ignoring whitespace(0x20,\t\r\n)
* empty string means false always
*/
public static boolean asHex(@Nullable String hex) {
return asHex(hex, 0);
}

/**
* check the hex string ignoring whitespace(0x20,\t\r\n) and its length(0 do NOT check length)
* empty string means false always
*/
public static boolean asHex(@Nullable String hex, int len) {
if (hex == null) return false;

final int sz = hex.length();
int count = 0;
for (int i = 0; i < sz; i++) {
char c = hex.charAt(i);
if (isPad(c)) continue;
if (!isHex(c)) return false;

count++;
if (len > 0 && count > len) break;
}
if (len > 0) {
return count == len;
}
else {
return count > 0;
}
}

/**
* Parse HEX string (can contain `0x20\t\r\n` case insensitive) into bytes.
*/
Expand Down Expand Up @@ -92,8 +164,8 @@ public static String hex(byte[] bytes, boolean upper) {
return sb.toString();
}

private static final char[] HEX_UPPER = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
private static final char[] HEX_LOWER = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static final char[] HEX_UPPER = new char[]{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
private static final char[] HEX_LOWER = new char[]{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

/**
* get HEX by lookup table
Expand All @@ -107,7 +179,7 @@ public static void hex(@NotNull StringBuilder sb, byte b, char[] table) {
sb.append(table[(b & 0x0F)]);
}

private static final byte[] HEX_BYTE = new byte[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
private static final byte[] HEX_BYTE = new byte[]{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

/**
* <pre>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/pro/fessional/mirana/bits/Md5.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
*/
public class Md5 {

public static boolean isSum(String str) {
return MdHelp.md5.isSum(str);
}

public static boolean asSum(String str) {
return MdHelp.md5.asSum(str);
}

@NotNull
public static String sum(@Nullable String str) {
return MdHelp.md5.sum(str);
Expand Down
Loading

0 comments on commit 5e81078

Please sign in to comment.