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