001: // /////////////////////////////
002: // Makumba, Makumba tag library
003: // Copyright (C) 2000-2003 http://www.makumba.org
004: //
005: // This library is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU Lesser General Public
007: // License as published by the Free Software Foundation; either
008: // version 2.1 of the License, or (at your option) any later version.
009: //
010: // This library is distributed in the hope that it will be useful,
011: // but WITHOUT ANY WARRANTY; without even the implied warranty of
012: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: // Lesser General Public License for more details.
014: //
015: // You should have received a copy of the GNU Lesser General Public
016: // License along with this library; if not, write to the Free Software
017: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: //
019: // -------------
020: // $Id: charEnumEditor.java 1888 2007-10-21 23:45:48Z rosso_nero $
021: // $Name$
022: /////////////////////////////////////
023:
024: package org.makumba.forms.html;
025:
026: import org.makumba.commons.formatters.FieldFormatter;
027: import org.makumba.commons.formatters.RecordFormatter;
028:
029: public class charEnumEditor extends choiceEditor {
030: private static final class SingletonHolder {
031: static final FieldEditor singleton = new charEnumEditor();
032: }
033:
034: /** Don't use this, use getInstance() */
035: protected charEnumEditor() {
036: }
037:
038: public static FieldFormatter getInstance() {
039: return SingletonHolder.singleton;
040: }
041:
042: public Object getOptions(RecordFormatter rf, int fieldIndex,
043: java.util.Dictionary fP) {
044: return null;
045: }
046:
047: public int getOptionsLength(RecordFormatter rf, int fieldIndex,
048: Object opts) {
049: int enumeratorSize = rf.dd.getFieldDefinition(fieldIndex)
050: .getEnumeratorSize();
051: if (nullOption != null) {
052: return enumeratorSize + 1;
053: } else {
054: return enumeratorSize;
055: }
056: }
057:
058: public Object getOptionValue(RecordFormatter rf, int fieldIndex,
059: Object options, int i) {
060: if (nullOption != null) {
061: if (i == 0) {
062: return null;
063: } else {
064: i -= 1;
065: }
066: }
067: return rf.dd.getFieldDefinition(fieldIndex).getStringAt(i);
068: }
069:
070: public String formatOptionValue(RecordFormatter rf, int fieldIndex,
071: Object val) {
072: return val.toString();
073: }
074:
075: public String formatOptionValue(RecordFormatter rf, int fieldIndex,
076: Object opts, int i, Object val) {
077: return val.toString();
078: }
079:
080: public String formatOptionTitle(RecordFormatter rf, int fieldIndex,
081: Object options, int i) {
082: if (nullOption != null) {
083: if (i == 0) {
084: return nullOption;
085: } else {
086: i -= 1;
087: }
088: }
089: return rf.dd.getFieldDefinition(fieldIndex).getNameAt(i);
090: }
091:
092: public String getMultiple(RecordFormatter rf, int fieldIndex) {
093: return "";
094: }
095:
096: public boolean isMultiple(RecordFormatter rf, int fieldIndex) {
097: return false;
098: }
099:
100: public int getDefaultSize(RecordFormatter rf, int fieldIndex) {
101: return 1;
102: }
103:
104: }
|