001/* 002 * Copyright 2024 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.forms.question.autofill; 017 018import java.util.List; 019import java.util.Map; 020 021import org.xml.sax.ContentHandler; 022import org.xml.sax.SAXException; 023 024import org.ametys.plugins.forms.repository.FormQuestion; 025import org.ametys.runtime.i18n.I18nizableText; 026import org.ametys.runtime.model.ModelItem; 027import org.ametys.runtime.model.ViewItem; 028 029/** 030 * Interface for creating a new source for autofill in text fields 031 */ 032public interface AutofillSource 033{ 034 /** 035 * Get id of the autofill source 036 * @return the id 037 */ 038 public String getId(); 039 040 /** 041 * Get label of autofill source 042 * @return the label 043 */ 044 public I18nizableText getLabel(); 045 046 /** 047 * Get description of autofill source 048 * @return the description 049 */ 050 public I18nizableText getDescription(); 051 052 /** 053 * Get autofill value 054 * @param question the question 055 * @return the autofill value. 056 */ 057 public String getAutofillValue(FormQuestion question); 058 059 /** 060 * Get the type model items 061 * If the return value is null there won't be any processing on the server side 062 * @return a list of the model items 063 */ 064 public Map<String, ModelItem> getModelItems(); 065 066 /** 067 * Get the view items for the main tab 068 * @return a list of view items 069 */ 070 public List<ViewItem> getViewElements(); 071 072 /** 073 * Sax additional infos 074 * @param contentHandler the content handler 075 * @param question the question 076 * @throws SAXException if an error occurred 077 */ 078 public void saxAdditionalInfos(ContentHandler contentHandler, FormQuestion question) throws SAXException; 079 080 /** 081 * Return <code>true</code> if the question can be cacheable with this source. 082 * @param question the question 083 * @return <code>true</code> if the question can be cacheable. 084 */ 085 public boolean isCacheable(FormQuestion question); 086 087}