Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Proofreader

  1. Object
  2. Proofreader

Spelling and grammar checks together, as a DocumentView uses them to underline problems. Results are remembered per text, so a paragraph is checked again only when it changes.

DocumentModel model = new DocumentModel(new Document());
model.insertBlock(0, new Paragraph(model.newId('p'), RichText.of("Quarterly review")));
Proofreader p = new Proofreader(SpellChecker.forLanguage("en_US"), GrammarChecker.english());
DocumentView view = new DocumentView(model);
view.setProofreader(p);
Form form = new Form("Proofreading", new BorderLayout());
form.add(BorderLayout.CENTER, view);
form.show();

Constructors

public Proofreader(SpellChecker spelling, GrammarChecker grammar)Creates a proofreader; either checker may be null.

Methods

public SpellChecker getSpellChecker()The spell checker.
public GrammarChecker getGrammarChecker()The grammar checker.
public synchronized List<ProofIssue> check(String text)The problems in a text, by position, without spelling suggestions.
public ProofIssue issueAt(String text, int offset, int max)The problem at a character of a text, with suggestions filled in for a misspelling.
public synchronized void invalidate()Forgets remembered results, after the user dictionary or the rules changed.

Inherited methods

Constructor details

Proofreader

public Proofreader(SpellChecker spelling, GrammarChecker grammar)
Creates a proofreader; either checker may be null.

Parameters

spelling SpellChecker
the spell checker, or null
grammar GrammarChecker
the grammar checker, or null

Method details

getSpellChecker

public SpellChecker getSpellChecker()
The spell checker.

Returns

the checker, or null

getGrammarChecker

public GrammarChecker getGrammarChecker()
The grammar checker.

Returns

the checker, or null

check

public synchronized List<ProofIssue> check(String text)
The problems in a text, by position, without spelling suggestions.

Parameters

text String
the text, typically a paragraph

Returns

the issues; do not modify the list

issueAt

public ProofIssue issueAt(String text, int offset, int max)
The problem at a character of a text, with suggestions filled in for a misspelling.

Parameters

text String
the text
offset int
the character
max int
the most suggestions

Returns

the issue, or null when there is none there

invalidate

public synchronized void invalidate()
Forgets remembered results, after the user dictionary or the rules changed.