diff --git a/Java/src/main/java/ej2/webservices/SpellCheckJsonData.java b/Java/src/main/java/ej2/webservices/SpellCheckJsonData.java index 59c6260..38613be 100644 --- a/Java/src/main/java/ej2/webservices/SpellCheckJsonData.java +++ b/Java/src/main/java/ej2/webservices/SpellCheckJsonData.java @@ -4,15 +4,40 @@ public class SpellCheckJsonData { - @JsonProperty("LanguageID") - int languageID; - @JsonProperty("TexttoCheck") - String texttoCheck; - @JsonProperty("CheckSpelling") - boolean checkSpelling; - @JsonProperty("CheckSuggestion") - boolean checkSuggestion; - @JsonProperty("AddWord") - boolean addWord; + @JsonProperty("LanguageID") + int languageID; + + @JsonProperty("TexttoCheck") + String texttoCheck; + + @JsonProperty("CheckSpelling") + boolean checkSpelling; + + @JsonProperty("CheckSuggestion") + boolean checkSuggestion; + + @JsonProperty("AddWord") + boolean addWord; + + @JsonProperty("IgnoreUppercase") + boolean ignoreUppercase; + + public int getLanguageID() { return languageID; } + public void setLanguageID(int languageID) { this.languageID = languageID; } + + public String getTexttoCheck() { return texttoCheck; } + public void setTexttoCheck(String texttoCheck) { this.texttoCheck = texttoCheck; } + + public boolean isCheckSpelling() { return checkSpelling; } + public void setCheckSpelling(boolean checkSpelling) { this.checkSpelling = checkSpelling; } + + public boolean isCheckSuggestion() { return checkSuggestion; } + public void setCheckSuggestion(boolean checkSuggestion) { this.checkSuggestion = checkSuggestion; } + + public boolean isAddWord() { return addWord; } + public void setAddWord(boolean addWord) { this.addWord = addWord; } + + public boolean isIgnoreUppercase() { return ignoreUppercase; } + public void setIgnoreUppercase(boolean ignoreUppercase) { this.ignoreUppercase = ignoreUppercase; } } diff --git a/Java/src/main/java/ej2/webservices/WordEditorController.java b/Java/src/main/java/ej2/webservices/WordEditorController.java index 0760695..cda459d 100644 --- a/Java/src/main/java/ej2/webservices/WordEditorController.java +++ b/Java/src/main/java/ej2/webservices/WordEditorController.java @@ -180,12 +180,25 @@ private static StreamSupport getManifestResourceStream(String fileName) throws E return assembly.getManifestResourceStream("ImageNotFound.jpg"); } + private static SpellCheckOptions mapToOptions(SpellCheckJsonData data) throws Exception { + SpellCheckOptions options = new SpellCheckOptions(); + options.setLanguageId(data.getLanguageID()); + options.setText(data.getTexttoCheck()); + options.setEnableSuggestions(data.isCheckSuggestion()); + options.setCheckSpelling(data.isCheckSpelling()); + options.setAddWord(data.isAddWord()); + options.setIgnoreUppercase(data.isIgnoreUppercase()); + return options; + } + + @CrossOrigin(origins = "*", allowedHeaders = "*") @PostMapping("/api/wordeditor/SpellCheck") public String spellCheck(@RequestBody SpellCheckJsonData spellChecker) throws Exception { try { SpellChecker spellCheck = new SpellChecker(); - String data = spellCheck.getSuggestions(spellChecker.languageID, spellChecker.texttoCheck, spellChecker.checkSpelling, spellChecker.checkSuggestion, spellChecker.addWord); + SpellCheckOptions spellCheckOptions = mapToOptions(spellChecker); + String data = spellCheck.getSuggestions(spellCheckOptions); return data; } catch (Exception e) { e.printStackTrace(); @@ -198,7 +211,8 @@ public String spellCheck(@RequestBody SpellCheckJsonData spellChecker) throws Ex public String spellCheckByPage(@RequestBody SpellCheckJsonData spellChecker) throws Exception { try { SpellChecker spellCheck = new SpellChecker(); - String data = spellCheck.checkSpelling(spellChecker.languageID, spellChecker.texttoCheck); + SpellCheckOptions spellCheckOptions = mapToOptions(spellChecker); + String data = spellCheck.checkSpelling(spellCheckOptions); return data; } catch (Exception e) { e.printStackTrace();