choicequestion.java
来自「cqME :java framework for TCK test.」· Java 代码 · 共 202 行
JAVA
202 行
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tck.j2me.interview.lib;import java.util.Map;import com.sun.interview.Interview;import com.sun.interview.Question;/** * A question to which the response is one of a number of choices. * */public class ChoiceQuestion extends com.sun.interview.ChoiceQuestion implements QuestionExtension { /** * Creates a question with a nominated tag. If this constructor is used, the * choices must be supplied separately. * * @param interview * The interview containing this question. * @param tag * A unique tag to identify this specific question. */ public ChoiceQuestion(Interview interview, String tag) { super(interview, tag); ext = new QuestionExtensionImpl(this); setResolver(PathResolvers.NULL); setValidator(Validators.NOT_EMPTY); setExporter(Exporters.NO_EXPORT); } /** * Create a question with a nominated tag. * * @param interview * The interview containing this question. * @param tag * A unique tag to identify this specific question. * @param choices * The set of legal values for responses to this question. */ public ChoiceQuestion(Interview interview, String tag, String[] choices) { this(interview, tag); setChoices(choices); } /** * Create a question with a nominated tag. * * @param interview * The interview containing this question. * @param tag * A unique tag to identify this specific question. * @param choices * The set of legal values for responses to this question. * @param displayNames An array of strings to be presented to * the user that identify the choices for this question. * The value can also be null, to indicate that the display * choices should be determined automatically by obtaining * localized values for the entries in the choices array. * The display names of the choices, which can each * be selected (true) or not (false). */ public ChoiceQuestion(Interview interview, String tag, String[] choices, String[] displayNames) { this(interview, tag); setChoices(choices, displayNames); } /** * This method is just a public wrapper around protected method from the * superclass. The behavior of this method is specified in the superclass: * <code>com.sun.interview.ChoiceQuestion</code>. */ public void setChoices(String[] choices, boolean localize) { super.setChoices(choices, localize); } /** * This method is just a public wrapper around protected method from the * superclass. The behavior of this method is specified in the superclass: * <code>com.sun.interview.ChoiceQuestion</code>. */ public void setChoices(String[] choices, String[] displayChoices) { super.setChoices(choices, displayChoices); } /** * This method is just a public wrapper around protected method from the * superclass. The behavior of this method is specified in the superclass: * <code>com.sun.interview.ChoiceQuestion</code>. */ public void setChoices(String[] choices) { super.setChoices(choices); } /* ========= Common code below this line ============ * Will eventually be eliminated when this library moves into Javatest * distribution. For now, we just copy-paste this simple delegation code. */ // see javadoc in QuestionExtension interface public Question getNext() { return ext.getNext(); } // see javadoc in QuestionExtension interface public void export(Map data) { ext.export(data); } // see javadoc in QuestionExtension interface public boolean isEnabled() { return ext.isEnabled(); } /** * {@inheritDoc} */ public void setResolver(PathResolver resolver) { ext.setResolver(resolver); } /** * {@inheritDoc} */ public PathResolver getResolver() { return ext.getResolver(); } /** * {@inheritDoc} */ public void linkTo(Question next) { ext.linkTo(next); } /** * {@inheritDoc} */ public void setValidator(Validator validator) { ext.setValidator(validator); } /** * {@inheritDoc} */ public Validator getValidator() { return ext.getValidator(); } /** * {@inheritDoc} */ public void setExporter(Exporter exporter) { ext.setExporter(exporter); } /** * {@inheritDoc} */ public Exporter getExporter() { return ext.getExporter(); } /** * {@inheritDoc} */ public void setEnabled(boolean b) { ext.setEnabled(b); } private QuestionExtensionImpl ext;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?