diff --git a/api/.gitignore b/api/.gitignore
new file mode 100644
index 0000000..2a91258
--- /dev/null
+++ b/api/.gitignore
@@ -0,0 +1,201 @@
+
+# Created by https://www.gitignore.io/api/java,maven,eclipse,intellij+all,visualstudiocode
+# Edit at https://www.gitignore.io/?templates=java,maven,eclipse,intellij+all,visualstudiocode
+
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.settings/
+.loadpath
+.recommenders
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# PyDev specific (Python IDE for Eclipse)
+*.pydevproject
+
+# CDT-specific (C/C++ Development Tooling)
+.cproject
+
+# CDT- autotools
+.autotools
+
+# Java annotation processor (APT)
+.factorypath
+
+# PDT-specific (PHP Development Tools)
+.buildpath
+
+# sbteclipse plugin
+.target
+
+# Tern plugin
+.tern-project
+
+# TeXlipse plugin
+.texlipse
+
+# STS (Spring Tool Suite)
+.springBeans
+
+# Code Recommenders
+.recommenders/
+
+# Annotation Processing
+.apt_generated/
+
+# Scala IDE specific (Scala & Java development for Eclipse)
+.cache-main
+.scala_dependencies
+.worksheet
+
+# Eclipse Core
+.project
+
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+# Annotation Processing
+.apt_generated
+
+.sts4-cache/
+
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+# Ignores the whole .idea folder and all .iml files
+# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+
+.idea/
+
+# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
+
+*.iml
+modules.xml
+.idea/misc.xml
+*.ipr
+
+# Sonarlint plugin
+.idea/sonarlint
+
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+.flattened-pom.xml
+
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# Ignore all local history of files
+.history
+
+# End of https://www.gitignore.io/api/java,maven,eclipse,intellij+all,visualstudiocode
\ No newline at end of file
diff --git a/api/README.md b/api/README.md
new file mode 100644
index 0000000..e84f94c
--- /dev/null
+++ b/api/README.md
@@ -0,0 +1 @@
+# api
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..c328865
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,74 @@
+
+
]*>(.+?)<.+?(?=.*)href=\"\\/(.+?)\".+?znaczenie.+?
]*>(.+?)<\\/p>";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
@@ -59,7 +59,7 @@ private String translateArrayToJSON(List ]*.+?<\\/p>";
+ final String HTML_PATTERN = "]*>.+?<\\/a>|]*.+?<\\/span>| ]*.+?<\\/p>";
Pattern pattern = Pattern.compile(HTML_PATTERN);
Matcher matcher = pattern.matcher(text);
return matcher.find();
diff --git a/test/CurlReaderTest.java b/api/src/test/java/sjpapi/api/CurlReaderTest.java
similarity index 96%
rename from test/CurlReaderTest.java
rename to api/src/test/java/sjpapi/api/CurlReaderTest.java
index c1419d9..e2f84e8 100644
--- a/test/CurlReaderTest.java
+++ b/api/src/test/java/sjpapi/api/CurlReaderTest.java
@@ -1,19 +1,21 @@
package sjpapi.api;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
-import java.net.MalformedURLException;
-public class CurlReaderTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
- private CurlReader reader = new CurlReader();
+class CurlReaderTest {
- //If this test fails it is means sjp.pl changed something
- // in the structure of the page, it is possible that
+ private final CurlReader reader = new CurlReader();
+
+ //If this test fails, it means sjp.pl changed something
+ // in the structure of the page; it is possible that
// SjpAPI has stopped working.
// If it still works, you can ignore this test.
- public void testIsSJPHaveSameSite() throws IOException {
+ @Test
+ void testIsSJPHaveSameSite() throws IOException {
String mockCurl = "200 Słownik języka polskiego, ortograficzny, wyrazów obcych i słownik do gier w jednym. Słownik jest rozwijany z myślą o zastosowaniu do sprawdzania pisowni w programach open-source, do gier słownych (np. literaki) i do użytku online jako kilka rodzajów słowników w jednym. Redakcją słownika zajmują się hobbyści. Słownik jest udostępniany na otwartych licencjach (różnych w zależności od wersji). Pierwsza wersja (słownik alternatywny) powstała na bazie dawnego słownika do ispella. Kontakt w sprawach technicznych: sjpslownik@gmail.com © Zespół SJP.PL> wordsFromCurlOutput ) thr
jsonObject.put("name",wordsFromCurlOutput.get(0).get(0));
jsonObject.put("count",wordsFromCurlOutput.size());
for( int i = 0; i < wordsFromCurlOutput.size(); i++){
- jsonObject.put("canBeUsed"+"["+i+"]",TranslateCanBeUsed(wordsFromCurlOutput.get(i).get(1)));
+ jsonObject.put("canBeUsed"+"["+i+"]", translateCanBeUsed(wordsFromCurlOutput.get(i).get(1)));
jsonObject.put("variant"+"["+i+"]", StringUtils.htmlToPolishLetter(wordsFromCurlOutput.get(i).get(2)));
jsonObject.put("meaning"+"["+i+"]", wrappedDescription(wordsFromCurlOutput.get(i).get(3)));
}
@@ -68,7 +68,7 @@ private String translateArrayToJSON(List
> wordsFromCurlOutput ) thr
return allWrappedWord;
}
- private Boolean TranslateCanBeUsed(String oneParamOfWordFromCurl){
+ private Boolean translateCanBeUsed(String oneParamOfWordFromCurl){
return !oneParamOfWordFromCurl.startsWith("niedopuszczalne");
}
diff --git a/src/StringUtils.java b/api/src/main/java/sjpapi/api/StringUtils.java
similarity index 94%
rename from src/StringUtils.java
rename to api/src/main/java/sjpapi/api/StringUtils.java
index 4f1cb6f..c8b5b64 100644
--- a/src/StringUtils.java
+++ b/api/src/main/java/sjpapi/api/StringUtils.java
@@ -57,11 +57,14 @@ public class StringUtils {
htmlEntities.put("€", "\u20a0");
}
+ private StringUtils() {
+ }
// Function from
// https://www.rgagnon.com/javadetails/java-0307.html
public static String unescapeHTML(String source, int start) {
- int startOfHtmlSpecialCharCombination, closeOfHtmlSpecialCharCombination;
+ int startOfHtmlSpecialCharCombination;
+ int closeOfHtmlSpecialCharCombination;
startOfHtmlSpecialCharCombination = source.indexOf("&", start);
if (startOfHtmlSpecialCharCombination > -1) {
@@ -86,7 +89,7 @@ public static String htmlToPolishLetter(String htmlWithBadCoding) throws Unsuppo
}
public static boolean hasSpecyficHTMLTags(String text){
- String HTML_PATTERN = "]*>.+?<\\/a>|]*.+?<\\/span>|
Słownik SJP.PL