Skip to content

Commit

Permalink
doc: add @SInCE
Browse files Browse the repository at this point in the history
  • Loading branch information
null8626 committed Jul 9, 2024
1 parent 8eaceff commit e318c85
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* </p>
*
* @author null8626
* @since 3.0.0
*/
public class CuredString {

Expand Down Expand Up @@ -80,6 +81,7 @@ public class CuredString {
* @return Match[] An array of Match objects containing every similar-looking match.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.0
*/
public native Match[] find(String other);

Expand All @@ -95,6 +97,7 @@ public class CuredString {
* @return Match[] An array of Match objects containing every similar-looking match.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.1
*/
public native Match[] findMultiple(String[] other);

Expand All @@ -111,6 +114,7 @@ public class CuredString {
* @throws IllegalArgumentException If the character to repeat is a UTF-16 surrogate.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.1
*/
public native void censor(String other, char with);

Expand All @@ -127,6 +131,7 @@ public class CuredString {
* @throws IllegalArgumentException If the character to repeat is a UTF-16 surrogate.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.1
*/
public native void censorMultiple(String[] other, char with);

Expand All @@ -142,6 +147,7 @@ public class CuredString {
* @see replaceMultiple
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.1
*/
public native void replace(String other, String with);

Expand All @@ -157,6 +163,7 @@ public class CuredString {
* @see replace
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.1.1
*/
public native void replaceMultiple(String[] other, String with);

Expand All @@ -171,6 +178,7 @@ public class CuredString {
* @return boolean Whether this object is similar with another string.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native boolean equals(String other);

Expand All @@ -185,6 +193,7 @@ public class CuredString {
* @return boolean Whether this object similarly starts with another string.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native boolean startsWith(String other);

Expand All @@ -199,6 +208,7 @@ public class CuredString {
* @return boolean Whether this object similarly ends with another string.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native boolean endsWith(String other);

Expand All @@ -213,6 +223,7 @@ public class CuredString {
* @return boolean Whether this object similarly contains another string.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native boolean contains(String other);

Expand All @@ -228,6 +239,7 @@ public class CuredString {
* @return String The String representation of this object.
* @throws NullPointerException If destroy() has been called prior to this.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native String toString();

Expand All @@ -240,6 +252,7 @@ public class CuredString {
* </p>
*
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public native void destroy();

Expand All @@ -254,6 +267,7 @@ public class CuredString {
* @param input The string to cure.
* @throws IllegalArgumentException If the string is malformed to the point where it's not possible to apply unicode's bidirectional algorithm to it.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public CuredString(String input) {
this.inner = CuredString.cure(input, 0);
Expand All @@ -266,6 +280,7 @@ public CuredString(String input) {
* @param options The explicit options.
* @throws IllegalArgumentException If the string is malformed to the point where it's not possible to apply unicode's bidirectional algorithm to it.
* @throws RuntimeException If a Rust panic occurs.
* @since 3.0.0
*/
public CuredString(String input, Options options) {
this.inner = CuredString.cure(input, options.inner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
* A match yielded by the CuredString.find() method.
*
* @author null8626
* @since 3.1.0
*/
public class Match {

/**
* The UTF-8 byte offset to the beginning of the match.
*
* @since 3.1.0
*/
public final long start;

/**
* The UTF-8 byte offset to the end of the match (non-inclusive).
*
* @since 3.1.0
*/
public final long end;

Expand All @@ -27,6 +32,7 @@ private Match(final long start, final long end, final String matched) {

/**
* @return String The matched portion of the original String.
* @since 3.1.0
*/
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@
* </p>
*
* @author null8626
* @since 3.0.0
*/
public final class Options {

/**
* Raw native bitflags.
*
* @since 3.0.0
*/
protected int inner;

/**
* Predefined configuration with all options enabled.
*
* @since 3.2.0
*/
public static Options ALL = new Options(0xffffff);

/**
* Predefined configuration that prevents decancer from curing characters from major foreign writing systems, including diacritics.
*
* @since 3.0.0
*/
public static Options PURE_HOMOGLYPH = new Options(0x1ffffc);

Expand All @@ -32,6 +39,8 @@ public final class Options {
* <p>
* By default, all options here are disabled, which means that decancer cures as much characters as possible and turns all of the output characters to lowercase.
* </p>
*
* @since 3.0.0
*/
public Options() {
this.inner = 0;
Expand All @@ -50,6 +59,7 @@ private Options(final int inner) {
* </p>
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainCapitalization() {
this.inner |= (1 << 0);
Expand All @@ -67,6 +77,7 @@ public Options retainCapitalization() {
* @see retainArabic
* @see retainHebrew
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options disableBidi() {
this.inner |= (1 << 1);
Expand All @@ -81,6 +92,7 @@ public Options disableBidi() {
* </p>
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainDiacritics() {
this.inner |= (1 << 2);
Expand All @@ -91,6 +103,7 @@ public Options retainDiacritics() {
* Prevents decancer from curing all greek characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainGreek() {
this.inner |= (1 << 3);
Expand All @@ -101,6 +114,7 @@ public Options retainGreek() {
* Prevents decancer from curing all cyrillic characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainCyrillic() {
this.inner |= (1 << 4);
Expand All @@ -111,6 +125,7 @@ public Options retainCyrillic() {
* Prevents decancer from curing all hebrew characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainHebrew() {
this.inner |= (1 << 5);
Expand All @@ -121,6 +136,7 @@ public Options retainHebrew() {
* Prevents decancer from curing all arabic characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainArabic() {
this.inner |= (1 << 6);
Expand All @@ -131,6 +147,7 @@ public Options retainArabic() {
* Prevents decancer from curing all devanagari characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainDevanagari() {
this.inner |= (1 << 7);
Expand All @@ -141,6 +158,7 @@ public Options retainDevanagari() {
* Prevents decancer from curing all bengali characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainBengali() {
this.inner |= (1 << 8);
Expand All @@ -151,6 +169,7 @@ public Options retainBengali() {
* Prevents decancer from curing all armenian characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainArmenian() {
this.inner |= (1 << 9);
Expand All @@ -161,6 +180,7 @@ public Options retainArmenian() {
* Prevents decancer from curing all gujarati characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainGujarati() {
this.inner |= (1 << 10);
Expand All @@ -171,6 +191,7 @@ public Options retainGujarati() {
* Prevents decancer from curing all tamil characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainTamil() {
this.inner |= (1 << 11);
Expand All @@ -181,6 +202,7 @@ public Options retainTamil() {
* Prevents decancer from curing all thai characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainThai() {
this.inner |= (1 << 12);
Expand All @@ -191,6 +213,7 @@ public Options retainThai() {
* Prevents decancer from curing all lao characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainLao() {
this.inner |= (1 << 13);
Expand All @@ -201,6 +224,7 @@ public Options retainLao() {
* Prevents decancer from curing all burmese characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainBurmese() {
this.inner |= (1 << 14);
Expand All @@ -211,6 +235,7 @@ public Options retainBurmese() {
* Prevents decancer from curing all khmer characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainKhmer() {
this.inner |= (1 << 15);
Expand All @@ -221,6 +246,7 @@ public Options retainKhmer() {
* Prevents decancer from curing all mongolian characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainMongolian() {
this.inner |= (1 << 16);
Expand All @@ -231,6 +257,7 @@ public Options retainMongolian() {
* Prevents decancer from curing all chinese characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainChinese() {
this.inner |= (1 << 17);
Expand All @@ -246,6 +273,7 @@ public Options retainChinese() {
*
* @see retainChinese
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainJapanese() {
this.inner |= (1 << 18);
Expand All @@ -256,6 +284,7 @@ public Options retainJapanese() {
* Prevents decancer from curing all korean characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainKorean() {
this.inner |= (1 << 19);
Expand All @@ -266,6 +295,7 @@ public Options retainKorean() {
* Prevents decancer from curing all braille characters.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainBraille() {
this.inner |= (1 << 20);
Expand All @@ -276,6 +306,7 @@ public Options retainBraille() {
* Prevents decancer from curing all emojis.
*
* @return Options A reference to this object to allow for method chaining.
* @since 3.0.0
*/
public Options retainEmojis() {
this.inner |= (1 << 21);
Expand All @@ -287,6 +318,7 @@ public Options retainEmojis() {
*
* @see alphanumericOnly
* @return Options A reference to this object to allow for method chaining.
* @since 3.2.0
*/
public Options asciiOnly() {
this.inner |= (1 << 22);
Expand All @@ -298,6 +330,7 @@ public Options asciiOnly() {
*
* @see asciiOnly
* @return Options A reference to this object to allow for method chaining.
* @since 3.2.0
*/
public Options alphanumericOnly() {
this.inner |= (1 << 23);
Expand Down
Loading

0 comments on commit e318c85

Please sign in to comment.