SiteSearch Formatting Classes: A Forum

OCLC SiteSearch User's Group Meeting
March 23, 1999
Larry Baerveldt (larry@incolsa.palni.edu)
Private Academic Network of Indiana

addBookmarkField base method

  /**
   *  

* Method for displaying a field in the full bookmarked citation * display. By default, the field is broken up and a new line character * is inserted. The continuing line is indented three spaces by default, * unless the labelIndent boolean is set to true, in which the indent is * equal to the length of the label. The breaking point is determined by * the index of the first location of the breakStr after the * specified width, e.g. if the breakStr is a space and the width is set * to be 40, a new line character will be inserted at the location of * the first space after 40 characters. *

* * @param dir a DataDir that contains the record to be formatted * @param useLabel a Boolean that specified whether or not a label is needed * @param fieldLabel a String that contains the text to be displayed as the label * @param preText a String that contains the text to be displayed after the label * but before the field contents * @param usepreText a Boolean that specifies whether or not additional text is * to be displayed before the field contents * @param fieldTag a String containing the MARC tag of the field to be displayed * @param breakStr a String containing the character to break on * @param width an integer giving the length of the field, after which it should be * broken * @param labelIndent a Boolean that specifies whether to use an indent equal to * the length the label * @param useTrailer a Boolean that specifies whether to use a trailer or not * @return void *
*/ protected final void addBookmarkField(DataDir dir, boolean useLabel, String fieldLabel, String preText, boolean usepreText, String fieldTag, String breakStr, int width, boolean labelIndent, boolean useTrailer) { String data_in, data_out, terminator, fieldTerminator; int i = 0; terminator = trailer; if (fmtUtil.fieldsExist(dir, fieldTag)) { data_in = fmtUtil.getFormattedFields(dir, fieldTag); //Note - Using getFormattedFields here rather than the addFields method // because addFields actually does the text outputting and // returns VOID. getFormattedFields just gets the data and // returns a String. Since further editing of the String is // necessary, we must use this method. if (useLabel) { data_out = fieldLabel + ": "; //Initialize output string } else { data_out = ""; } // end if-else if (usepreText) { data_out = data_out + preText; //Add extra text after field label } // end if if (useTrailer) { fieldTerminator = trailer; } else { fieldTerminator = " "; } // end if-else // This section deals with the indent. By default, the indent will be // three spaces. If labelIndent is true, then additional spaces will be // added to the indent until it is the length of the label, plus 2, so // following lines will line up under the first line following the label. // Note - With later browsers, this may be immaterial as they may use a // proportional font by default. String indent = " "; //initializes the indent to 3 spaces if (labelIndent) { for (int j = 4; j <= fieldLabel.length(); j++) { indent = indent + " "; } // end for indent = indent + " "; // adds two spaces for the ": " part of label } // end if // The building of the output string now follows int l = data_in.length(); while (i < l) { int next = data_in.indexOf(breakStr, i+width); if (next == -1) { next = l; terminator = fieldTerminator; } // end if data_out = data_out + data_in.substring(i, next) + terminator; if (next != l) data_out = data_out + indent; i = next + 1; } // end while loop fmtUtil.addText(data_out); } }

Previous    Top    Next


©1999 Larry R. Baerveldt/PALNI
Revised April 5, 1999