Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 40 additions & 10 deletions Java/src/main/java/ej2/webservices/SpellCheckJsonData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,45 @@

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;

@JsonProperty("UserName")
String userName;

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; }

public String getUserName() { return userName; }
public void setUserName(String userName) { this.userName = userName; }
}
19 changes: 17 additions & 2 deletions Java/src/main/java/ej2/webservices/WordEditorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,26 @@ 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());
options.setUserName(data.getUserName());
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();
Expand All @@ -198,7 +212,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();
Expand Down