kom.gateway
Class Form

java.lang.Object
  |
  +--kom.gateway.DBLow
        |
        +--kom.gateway.DBHigh
              |
              +--kom.gateway.KOMutil
                    |
                    +--kom.gateway.Form
Direct Known Subclasses:
Chat

public class Form
extends KOMutil

HTML forms (templates) handling for the KOM 2000 system


Inner classes inherited from class kom.gateway.KOMutil
KOMutil.LookupTables, KOMutil.UFtable
 
Field Summary
(package private)  boolean acceptform
          True if used within an "accept" (moderator view) display
(package private)  boolean added
          Keeps track of whether a language-dependent string has been handled
(package private)  java.lang.String bodytext
           
(package private)  java.lang.String curform
           
(package private)  java.lang.String formcodes
          Special variable, may contain codes used in interpreting a template
(package private)  boolean isHTML
          Set true if current text is determined to be HTML-formatted
(package private)  boolean isVote
          Set true if current text is determined to contain a voting form
(package private) static int kBase
           
(package private) static int kBbody
           
(package private) static int kCname
           
(package private) static int kCuser
           
(package private) static int kDColor
           
(package private) static int kFBase
           
(package private) static java.lang.String KFC
          Special key, used in templates to refer to formcodes
(package private) static int kHColor
           
(package private) static int kIcons
           
(package private) static int kKFC
           
(package private) static int kLColor
           
(package private) static int kPboard
           
(package private) static int kPcomm
           
(package private) static int kPdate
           
(package private) static int kPhtml
           
(package private) static int kPhtmldef
           
(package private) static int kPinterval
           
(package private) static int kPnotif
           
(package private) static int kPshort
           
(package private) static int kPtype
           
(package private) static int kServer
           
(package private) static int kTarea
           
private  java.lang.StringBuffer oldOutput
           
protected  java.lang.StringBuffer outputText
          Buffer for constructing the current HTML page
(package private)  boolean submitted
          Set true if current text is determined to contain a vote
(package private) static java.util.Hashtable substkey
          Special key table
 
Fields inherited from class kom.gateway.KOMutil
ACT, anyAccess, arglist, argsep, argtab, attachments, BOK, BOUNDARYSTART, CAT, CHA, cidTable, CLO, config, curNgd, DIC, environment, gateway, gavePassword, GEN, GRA, GRP, inlineCurr, inlines, INT, LINE_CUTOFF, LINE_FUDGE, LIS, lt, MAILIT, messageRecipientTypeCode, MIM, MOD, N_RECTY, N_RECTYPECODE, newsclient, newsClients, newsData, nntpAuth, NWS, NWSART, objCache, oCurr, oldnews, POSTIT, RAT, REC_BCC, REC_CC, REC_TO, recTypeCode, REP, response, rLoc, savednews, sCursor, servletBase, session, THR, userData, USR, VOT
 
Fields inherited from class kom.gateway.DBHigh
AdminURL, cache, HomeURL, UsersURL
 
Fields inherited from class kom.gateway.DBLow
absCDBpath, config, fSep, fSeparator, msgAuth, msgParts
 
Constructor Summary
Form(ServerConfig config, HTTPResponse response, Gateway gateway)
          Class constructor
 
Method Summary
(package private) static void ()
           
 void add(java.lang.String str)
          Adds a string to the page buffer
(package private)  void addBody(java.lang.String body)
          Adds body text to page buffer.
private  void addv(java.lang.String value)
           
(package private)  java.lang.String checkHTML(java.lang.String body, KomData ht)
           
private  void checkHTTP(java.lang.String line)
           
private  void checkTag(java.lang.String tag, java.util.Hashtable lev)
           
private  java.lang.String checkVote(java.lang.String text, java.util.Hashtable lev)
           
private  java.lang.String complete(java.lang.String tag, java.lang.String text, java.util.Hashtable lev)
           
private  boolean contains(java.lang.String result, java.lang.String value)
          Checks if a string contains another string (delimited by ,-s)
(package private)  void dispauth(KomData ht)
           
private  void dispbody(java.lang.String body, KomData ht)
          Adds body text to page buffer.
private  void dispcheck(java.lang.String property, java.lang.String wanted)
          Adds " checked" to the desired choice.
(package private)  void dispname(java.lang.String name, KomData ht, java.lang.String limit)
          Displays a name in the current HTML page buffer.
private  void dispselect(java.lang.String sel, java.lang.String wanted)
          Adds " selected" to the desired selection item.
private  void disptype(java.lang.String type, java.lang.String arg)
          Shows object type in HTML form or adds a check mark to a choice.
 void form(java.lang.String tmplid)
          Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings.
 void form(java.lang.String tmplid, KomData ht)
          Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings.
 void form(java.lang.String tmplid, KomData ht, java.lang.String codes)
          Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings.
 void form(java.lang.String tmplid, java.lang.String codes)
          Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings.
 int formsegment(java.lang.String tmpl, int pos, int last, KomData ht)
          Handles a segment of a form (template).
private  void getAreaResult(KomData ht, java.lang.String name, boolean pub)
           
 java.lang.String getForm(java.lang.String tmplid, java.lang.String codes)
          Creates an HTML-formatted String from a template.
private  java.lang.String getHTML(java.lang.String body, java.util.Hashtable lev)
           
protected  java.lang.StringBuffer getOutputText()
          Gets a reference to the current html output page buffer
(package private)  java.util.Vector getQryValues()
          Returns a Vector of KomData.toString() values, containing one value each, with key = "Bscaletext".
private  void getResultBox(KomData ht, java.lang.String name, java.lang.String value, boolean pub)
           
private  void getResultText(KomData ht, java.lang.String name, boolean pub)
           
private  java.util.Vector getSelect1(java.lang.String old, java.lang.String text, java.lang.String norm)
           
private  java.lang.String getSelect2(java.lang.String old, java.lang.String inside, java.lang.String outside)
           
private  void getSelectResult(KomData ht, java.lang.String name, java.util.Vector vals, boolean pub)
           
private  void getTag(java.lang.String tag, int inc, java.util.Hashtable lev)
           
private  void getVote(java.lang.String text, KomData ht)
           
private  int getVoteArea(java.lang.String tag, java.lang.String norm, int end, KomData vote, java.lang.String text, KomData ht, boolean pub)
           
private  void getVoteCheck(java.lang.String text, java.lang.String norm, java.lang.String old)
           
private  int getVoteSelect(java.lang.String tag, java.lang.String norm, int end, KomData vote, java.lang.String text, KomData ht, boolean pub)
           
private  void getVoteSubmit(KomData ht, java.lang.String text, boolean pub)
           
private  java.lang.String getVoteTag(KomData ht, java.lang.String text, KomData vote, boolean pub)
           
private  void getVoteText(java.lang.String text, java.lang.String norm, java.lang.String old)
           
private  void insertSelect(KomData ht, java.lang.String name, java.lang.String value, boolean pub)
           
 java.lang.String makeHTML()
          Creates the HTML page
(package private)  int nextmatching(java.lang.String tmpl, java.lang.String key, int pos, int end)
           
private  java.lang.String normalize(java.lang.String text)
           
(package private)  java.lang.String restoreOutput()
          Restores the old HTML output buffer
(package private)  void saveOutput()
          Saves the HTML output buffer as oldOutput and starts another output buffer.
(package private)  java.lang.String textareaSubst(java.lang.String t, boolean back)
          Replaces "textarea" with $Tarea() to avoid confusion with actual textarea tag, or reverses the substitution.
 void transform(int keyindex, java.lang.String arg, java.lang.String value, KomData ht)
           
 void translate(java.lang.String lang, java.lang.String text)
          Adds a text string to the output HTML buffer if the language matches.
private  KomData trbody(java.lang.String place, KomData ht, java.lang.String key, java.lang.String name)
           
 
Methods inherited from class kom.gateway.KOMutil
a, accessCont, accessCont, accessObj, addInfoData, addrToLocal, changeEnvironment, cidReplace, contType, decodeText, deleted, dispMailMessage, doAction, equal, excluded, fetchNews, findId, findId, findlocal, findLogin, findOwner, findUser, getActId, getcont, getcont, getcontV, getcontV, getCurNgd, getmemb, getMsgParts, getMsgText, getNews, getNewsAuth, getobj, getobject, getold, getParent, getPart, getSimpleFileName, getSimpleFileName, getStream, getTail, getTextPart, getVal, getVal, isAllowed, isarg, isMember, isOrganizer, isOrganizer, ispunct, isType, isValidEmailAddress, loggedIn, mailDate, mailDate, mimeMessage, mimeMessageStream, mkdate, mkdate, noQuote, parseArglist, parseArgs, setCids, setNewsAuth, setValidMsgPwd, showBody, showHeader, showHeader, showHeaders, showInputStream, showMailMessage, showMessage, showMultipart, toString, transbody, urlexpand, userGavePassword, userGavePassword, wrap
 
Methods inherited from class kom.gateway.DBHigh
addContent, addContent, addDraft, addInfo, addLast, addMember, addNews, addObj, addObj, addObject, addObject, addQuery, cleanDrafts, contentCount, createNews, depth, expungeRef, findContent, findDraft, findDraftData, findInfo, findMemb, findNews, findObject, findObject, findQuery, getFormContents, getQryDefault, getQueries, getseq, getStringValues, getValues, invalidateCount, isEmpty, isStandard, listDraft, makeArea, modObject, msgExists, nextDraft, queryExists, ref2path, refExists, removeDraft, removeQuery, replaceObject, Stream2String, String2Stream, StringBuffer2Stream, updateCount, updCount, updref, updseq
 
Methods inherited from class kom.gateway.DBLow
accessPart, addFile, areaExists, basedRef, createArea, debugLog, errorLog, expungeFile, File2Stream, File2String, findPart, getFile, getFileContents, getFileStream, getPath, getStandard, isMailSpool, lastModified, length, listFiles, makePart, msgPartStream, partfile, partpath, printStackTrace, readObject, removeFile, replaceMime, updseq1, validate, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

added

boolean added
Keeps track of whether a language-dependent string has been handled

isHTML

boolean isHTML
Set true if current text is determined to be HTML-formatted

isVote

boolean isVote
Set true if current text is determined to contain a voting form

submitted

boolean submitted
Set true if current text is determined to contain a vote

acceptform

boolean acceptform
True if used within an "accept" (moderator view) display

curform

java.lang.String curform

formcodes

java.lang.String formcodes
Special variable, may contain codes used in interpreting a template

KFC

static final java.lang.String KFC
Special key, used in templates to refer to formcodes

outputText

protected java.lang.StringBuffer outputText
Buffer for constructing the current HTML page

oldOutput

private java.lang.StringBuffer oldOutput

bodytext

java.lang.String bodytext

substkey

static java.util.Hashtable substkey
Special key table

kBase

static final int kBase

kIcons

static final int kIcons

kFBase

static final int kFBase

kLColor

static final int kLColor

kHColor

static final int kHColor

kDColor

static final int kDColor

kBbody

static final int kBbody

kPtype

static final int kPtype

kPboard

static final int kPboard

kPhtml

static final int kPhtml

kPhtmldef

static final int kPhtmldef

kPinterval

static final int kPinterval

kPcomm

static final int kPcomm

kCuser

static final int kCuser

kCname

static final int kCname

kPshort

static final int kPshort

kPdate

static final int kPdate

kServer

static final int kServer

kPnotif

static final int kPnotif

kTarea

static final int kTarea

kKFC

static final int kKFC
Constructor Detail

Form

public Form(ServerConfig config,
            HTTPResponse response,
            Gateway gateway)
Class constructor
Parameters:
config - Server configuration data
response - HTTP response object
gateway - Reference to client supervisor
Method Detail

static void ()

getOutputText

protected java.lang.StringBuffer getOutputText()
Gets a reference to the current html output page buffer
Returns:
StringBuffer reference

getForm

public java.lang.String getForm(java.lang.String tmplid,
                                java.lang.String codes)
Creates an HTML-formatted String from a template.
Parameters:
tmplid - Template id
codes - Special code string to control substitutions
Returns:
HTML text, with any substitutions made referring to userData

form

public void form(java.lang.String tmplid)
Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings. Takes data for those transformations from the current userData object.
Parameters:
tmplid - Id of template

form

public void form(java.lang.String tmplid,
                 java.lang.String codes)
Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings. Takes data for those transformations from the current userData object.
Parameters:
tmplid - Id of template
codes - Special codes to be checked in the template

form

public void form(java.lang.String tmplid,
                 KomData ht)
Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings. Takes data for those transformations from a KomData object passed as parameter.
Parameters:
tmplid - Id of template
ht - KomData instance

form

public void form(java.lang.String tmplid,
                 KomData ht,
                 java.lang.String codes)
Finds a template text and adds it to the current HTML buffer after performing any transformations indicated by special markup strings. Takes data for those transformations from a KomData object passed as parameter, and from "codes".
Parameters:
tmplid - Id of template
codes - Special codes to be checked in the template
ht - KomData instance

formsegment

public int formsegment(java.lang.String tmpl,
                       int pos,
                       int last,
                       KomData ht)
Handles a segment of a form (template). Looks for special strings starting with '$', ending at the next '(', which may refer to global or local data (from the ht structure). Any unrecognized $xx string is assumed to be a language markup, such as $sv(svensk text)$en(English text), which shows two versions of a text fragment, the first one containing the Swedish version, the second containing the English version. If the current language matches one of these markers, the corresponding text (inside the parentheses) is copied to the current HTML page, otherwise the English version is chosen.
Parameters:
tmpl - Template name
pos - First position in template text
last - Last position in template text + 1
ht - Data structure containing values which may be substituted into the final form
Returns:
Start of next segment, or -1

nextmatching

int nextmatching(java.lang.String tmpl,
                 java.lang.String key,
                 int pos,
                 int end)

transform

public void transform(int keyindex,
                      java.lang.String arg,
                      java.lang.String value,
                      KomData ht)

addv

private void addv(java.lang.String value)

disptype

private void disptype(java.lang.String type,
                      java.lang.String arg)
Shows object type in HTML form or adds a check mark to a choice.
Parameters:
type - Object type code
arg - = "1": Show attributes of the current object. other: If part of type, add check mark.

dispcheck

private final void dispcheck(java.lang.String property,
                             java.lang.String wanted)
Adds " checked" to the desired choice.
Parameters:
property - Identifier of some property
wanted - Desired property

dispselect

private final void dispselect(java.lang.String sel,
                              java.lang.String wanted)
Adds " selected" to the desired selection item.
Parameters:
sel - Selection key
wanted - Desired selection key

dispbody

private final void dispbody(java.lang.String body,
                            KomData ht)
Adds body text to page buffer. May add
tags to simple text
Parameters:
body - Raw text
ht - Current internal message representation

addBody

final void addBody(java.lang.String body)
Adds body text to page buffer. Adds
tags to simple text
Parameters:
body - Raw text

checkHTTP

private void checkHTTP(java.lang.String line)

dispauth

void dispauth(KomData ht)

dispname

void dispname(java.lang.String name,
              KomData ht,
              java.lang.String limit)
Displays a name in the current HTML page buffer.
Parameters:
name - Name string
ht - Data determining HTML text status
limit - Truncate if name is longer than limit+3

checkHTML

java.lang.String checkHTML(java.lang.String body,
                           KomData ht)

getHTML

private java.lang.String getHTML(java.lang.String body,
                                 java.util.Hashtable lev)

checkTag

private void checkTag(java.lang.String tag,
                      java.util.Hashtable lev)

getTag

private void getTag(java.lang.String tag,
                    int inc,
                    java.util.Hashtable lev)

complete

private java.lang.String complete(java.lang.String tag,
                                  java.lang.String text,
                                  java.util.Hashtable lev)

checkVote

private java.lang.String checkVote(java.lang.String text,
                                   java.util.Hashtable lev)

getVote

private void getVote(java.lang.String text,
                     KomData ht)

getVoteArea

private int getVoteArea(java.lang.String tag,
                        java.lang.String norm,
                        int end,
                        KomData vote,
                        java.lang.String text,
                        KomData ht,
                        boolean pub)

getVoteSelect

private int getVoteSelect(java.lang.String tag,
                          java.lang.String norm,
                          int end,
                          KomData vote,
                          java.lang.String text,
                          KomData ht,
                          boolean pub)

getSelect1

private java.util.Vector getSelect1(java.lang.String old,
                                    java.lang.String text,
                                    java.lang.String norm)

getSelect2

private java.lang.String getSelect2(java.lang.String old,
                                    java.lang.String inside,
                                    java.lang.String outside)

normalize

private java.lang.String normalize(java.lang.String text)

getVoteTag

private java.lang.String getVoteTag(KomData ht,
                                    java.lang.String text,
                                    KomData vote,
                                    boolean pub)

getResultBox

private void getResultBox(KomData ht,
                          java.lang.String name,
                          java.lang.String value,
                          boolean pub)

getResultText

private void getResultText(KomData ht,
                           java.lang.String name,
                           boolean pub)

getVoteCheck

private void getVoteCheck(java.lang.String text,
                          java.lang.String norm,
                          java.lang.String old)

getVoteText

private void getVoteText(java.lang.String text,
                         java.lang.String norm,
                         java.lang.String old)

getVoteSubmit

private void getVoteSubmit(KomData ht,
                           java.lang.String text,
                           boolean pub)

getAreaResult

private void getAreaResult(KomData ht,
                           java.lang.String name,
                           boolean pub)

trbody

private KomData trbody(java.lang.String place,
                       KomData ht,
                       java.lang.String key,
                       java.lang.String name)

getSelectResult

private void getSelectResult(KomData ht,
                             java.lang.String name,
                             java.util.Vector vals,
                             boolean pub)

insertSelect

private void insertSelect(KomData ht,
                          java.lang.String name,
                          java.lang.String value,
                          boolean pub)

contains

private boolean contains(java.lang.String result,
                         java.lang.String value)
Checks if a string contains another string (delimited by ,-s)
Parameters:
result - String containing some values delimited by commas
value - Value to be checked for
Returns:
true if ",value," is found in "result"

translate

public void translate(java.lang.String lang,
                      java.lang.String text)
Adds a text string to the output HTML buffer if the language matches.
Parameters:
lang - Language code for the text string. Checked against command language
text - Text string in that language, or in English (default) The variable added is set to true if a match is found. The English text is assumed to be the last alternative, as in $sv(svensk text)$en(English text).

saveOutput

void saveOutput()
Saves the HTML output buffer as oldOutput and starts another output buffer. Restore the saved output by calling restoreOutput.

restoreOutput

java.lang.String restoreOutput()
Restores the old HTML output buffer
Returns:
the current output buffer, as a String

add

public void add(java.lang.String str)
Adds a string to the page buffer
Parameters:
str - String to be added

makeHTML

public java.lang.String makeHTML()
Creates the HTML page

textareaSubst

java.lang.String textareaSubst(java.lang.String t,
                               boolean back)
Replaces "textarea" with $Tarea() to avoid confusion with actual textarea tag, or reverses the substitution.
Parameters:
t - (HTML) text
back - Reverse replacement
Returns:
t, or copy of t with any
replaced by
<$Tarea() ...>
, or vice versa.

getQryValues

java.util.Vector getQryValues()
Returns a Vector of KomData.toString() values, containing one value each, with key = "Bscaletext". Those are the default values for the evaluation scale, in the language preferred by the query constructor. The values are taken from the database file via the DBHigh.getQryDefault method.
Returns:
Vector of String objects, representing KomData.