View Javadoc
1   /*
2    * Copyright (c) 2002-2025 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       * @return all the text in this element
48       */
49      String getText();
50  
51      /**
52       * Sets the text in this element.
53       * @param text the text to put in this element
54       */
55      void setText(String text);
56  
57      /**
58       * Returns the selected text in this element, or {@code null} if there is no selected text in this element.
59       * @return the selected text in this element, or {@code null} if there is no selected text in this element
60       */
61      String getSelectedText();
62  
63      /**
64       * Returns the start position of the selected text in this element.
65       * @return the start position of the selected text in this element
66       */
67      int getSelectionStart();
68  
69      /**
70       * Sets the start position of the selected text in this element.
71       * @param selectionStart the start position of the selected text in this element
72       */
73      void setSelectionStart(int selectionStart);
74  
75      /**
76       * Returns the end position of the selected text in this element.
77       * @return the end position of the selected text in this element
78       */
79      int getSelectionEnd();
80  
81      /**
82       * Sets the end position of the selected text in this element.
83       * @param selectionEnd the end position of the selected text in this element
84       */
85      void setSelectionEnd(int selectionEnd);
86  
87  }