1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.html.impl;
16
17 import org.htmlunit.Page;
18
19 /**
20 * Internal interface which defines an input element which contains selectable text. This interface just keeps
21 * the various implementations in sync as to selection functionality, and provides a definition of the functionality
22 * required by the {@link SelectableTextSelectionDelegate} so that it can do its job.
23 * This interface is not public because it is an internal contract.
24 *
25 * @author Daniel Gredler
26 * @author Ronald Brill
27 */
28 public interface SelectableTextInput {
29
30 /**
31 * Returns the page which contains this element.
32 * @return the page which contains this element
33 */
34 Page getPage();
35
36 /**
37 * Focuses this element.
38 */
39 void focus();
40
41 /**
42 * Focuses this element and selects all of its text.
43 */
44 void select();
45
46 /**
47 * Returns all the text in this element.
48 *
49 * @return all the text in this element
50 */
51 String getText();
52
53 /**
54 * Sets the text in this element.
55 * @param text the text to put in this element
56 */
57 void setText(String text);
58
59 /**
60 * Returns the selected text in this element, or {@code null} if there is no selected text in this element.
61 * @return the selected text in this element, or {@code null} if there is no selected text in this element
62 */
63 String getSelectedText();
64
65 /**
66 * Returns the start position of the selected text in this element.
67 * @return the start position of the selected text in this element
68 */
69 int getSelectionStart();
70
71 /**
72 * Sets the start position of the selected text in this element.
73 * @param selectionStart the start position of the selected text in this element
74 */
75 void setSelectionStart(int selectionStart);
76
77 /**
78 * Returns the end position of the selected text in this element.
79 * @return the end position of the selected text in this element
80 */
81 int getSelectionEnd();
82
83 /**
84 * Sets the end position of the selected text in this element.
85 * @param selectionEnd the end position of the selected text in this element
86 */
87 void setSelectionEnd(int selectionEnd);
88
89 }