Example usage for java.lang StringBuffer deleteCharAt

List of usage examples for java.lang StringBuffer deleteCharAt

Introduction

In this page you can find the example usage for java.lang StringBuffer deleteCharAt.

Prototype

@Override
public synchronized StringBuffer deleteCharAt(int index) 

Source Link

Usage

From source file:org.crawler.LinkExtractor.java

public String extractLinkedIds(Question thisQuestion) throws Exception {
    StringBuffer links = new StringBuffer();
    final String key = "SljJ5BMNJM*UKmsOMwMx4w(("; //"R7HIsOi63KTX52j*7XK6mg((";
    final String userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0";

    String urlPrefix = "https://api.stackexchange.com/2.2/questions/";
    //String urlSuffix = "/linked?pagesize=100&site=stackoverflow&filter=!LURkzC_(wGQOeHiFvabvfS&key=SkjoA6hPLw50*v8PEShiUw((";
    String urlSuffix = "/linked?pagesize=100&site=stackoverflow&filter=!LURkzC_(wGQOeHiFvabvfS&key=" + key;

    String url = urlPrefix + String.valueOf(thisQuestion.getID()) + urlSuffix;

    String json = null;//  w w w  .  j  a va2  s  . co m

    json = Jsoup.connect(url).userAgent(userAgent).timeout(20000). // timeout 20s
            ignoreContentType(true).execute().body();

    // Now parse the JSON returned to obtain a list of ids
    if (json.length() == 0)
        return "";

    // parse this JSON to see if there's more to be fetched
    JSONObject jsonObject = new JSONObject(json);
    JSONArray items = (JSONArray) jsonObject.get("items");

    for (int i = 0; i < items.length(); i++) {
        try {
            JSONObject item = items.getJSONObject(i);
            links.append(item.get("question_id").toString()).append(",");
            String backoff = (String) item.get("backoff");
            if (backoff != null) {
                int backoffDelay = Integer.parseInt(backoff);
                Thread.sleep((backoffDelay + 1) * 1000);
            }
            String quotaLeft = (String) item.get("quota_remaining");
            int quotaRemVal = -1;
            if (quotaLeft != null) {
                try {
                    quotaRemVal = Integer.parseInt(quotaLeft);
                } catch (NumberFormatException nex) {
                }
            }
            System.out.println("#requests left: " + quotaRemVal + ", #requests sent: " + numRequests);
            if (quotaRemVal <= 1)
                break;
        } catch (JSONException jex) {
            System.err.println("JSON parse exception" + jex);
        }
    }

    if (links.length() > 0)
        links.deleteCharAt(links.length() - 1); // remove trailing comma
    return links.toString();
}

From source file:edu.wustl.geneconnect.metadata.MetadataCalculator.java

/**
 * Create following output files which will use sqlloader to populate database tables
 * O/p file for all paths -- populates PATH table
 *//*from   w w w .  java2  s.  c o m*/
private void writePaths(String fileName, int fileFormat) {
    // All paths 
    // This portion fills the following tables:
    // a) ALL_PATH 

    int loopCount = 1;

    try {
        FileWriter opFile3 = new FileWriter(new File(fileName));
        if (fileFormat == DB_FORMAT) {
            opFile3.write("LOAD DATA INFILE * APPEND INTO TABLE PATH FIELDS TERMINATED BY '" + FIELD_DELIMITER
                    + "' " + "(PATH_ID, SOURCE_DATASOURCE_ID, PATH, TARGET_DATASOURCE_ID)\n" + "BEGINDATA\n");
        }

        for (int srcID = 0; srcID < m_numSources; ++srcID) {
            // Get all paths for 'srcID' 
            MultiMap nodePaths = (MultiMap) m_masterPathList.get(srcID);

            Iterator mapIter = nodePaths.entrySet().iterator();

            // This 'for' loop denotes all paths from a given srcID to all possible destinations
            for (Iterator iter = nodePaths.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                int destID = ((Integer) (entry.getKey())).intValue();

                List nodeList = (List) entry.getValue();

                // below 'for' loop denotes all paths to a given destination with 'srcID' as starting node
                for (int i = 0; i < nodeList.size(); ++i) {
                    StringBuffer temp = new StringBuffer();
                    if (fileFormat == DB_FORMAT) {
                        // Write Record count in the o/p 
                        temp.append((new Integer(loopCount)).toString() + FIELD_DELIMITER);

                        //Write source datasource node ID 
                        temp.append(new Integer(srcID).toString() + FIELD_DELIMITER);
                    } else {
                        //Write source datasource node ID 
                        temp.append(new Integer(srcID).toString() + PATH_NODES_DELIMITER);
                    }

                    // 'nodeIDList' contains a single path (of node IDs) excluding srcID 
                    // ########################################################################
                    List nodeIDList = (List) nodeList.get(i);

                    for (int h = 0; h < nodeIDList.size() - 1; ++h) {
                        //Write intermediate datasource node ID 
                        temp.append(nodeIDList.get(h) + PATH_NODES_DELIMITER);
                    }

                    if (fileFormat == DB_FORMAT) {
                        if (nodeIDList.size() > 1) {
                            temp.deleteCharAt(temp.length() - 1);
                            temp.append(FIELD_DELIMITER);
                        } else {
                            temp.append(FIELD_DELIMITER);
                        }
                    }

                    // Write Destination datasource node ID 
                    temp.append(destID);
                    temp.append("\n");

                    opFile3.write(temp.toString());
                    opFile3.flush();

                    ++loopCount;
                    // ########################################################################   
                } // end of path
            }
        }
    } catch (IOException ioex) {
        System.out.println("Failed to create output file in current directory" + ioex.getMessage());
    }
}

From source file:com.wabacus.system.component.application.report.configbean.crosslist.AbsCrossListReportColAndGroupBean.java

protected void createStatisForWholeRow(CrossListReportType crossListReportType, StringBuffer dynselectedColsBuf,
        List lstChildren, String allColConditions, Map<String, Boolean> mDynamicColGroupDisplayType) {
    if (this.lstDisplayStatisBeansOfReport == null || this.lstDisplayStatisBeansOfReport.size() == 0)
        return;/*from  w  w  w .ja  v  a2  s.  c o  m*/
    DisplayBean disbean = this.getOwner().getReportBean().getDbean();
    ReportRequest rrequest = crossListReportType.getReportRequest();
    for (CrossListReportStatiDisplayBean statisdBeanTmp : this.lstDisplayStatisBeansOfReport) {//?
        if (!mDynamicColGroupDisplayType.get(statisdBeanTmp.getStatiBean().getId()))
            continue;
        int colidx = crossListReportType.generateColGroupIdxId();
        lstChildren.add(createDynamicCrossStatiColBean(disbean,
                rrequest.getI18NStringValue(statisdBeanTmp.getLabel()),
                statisdBeanTmp.getLabelstyleproperty(rrequest), statisdBeanTmp.getValuestyleproperty(rrequest),
                statisdBeanTmp.getStatiBean().getDatatypeObj(), colidx));
        dynselectedColsBuf.append(statisdBeanTmp.getStatiBean().getType() + "(");
        if (!allColConditions.trim().equals("")) {
            dynselectedColsBuf.append("case when ").append(allColConditions).append(" then ")
                    .append(statisdBeanTmp.getStatiBean().getColumn()).append("  end ");
        } else {
            dynselectedColsBuf.append(statisdBeanTmp.getStatiBean().getColumn());
        }
        dynselectedColsBuf.append(") as ").append("column_" + colidx).append(",");
    }
    if (dynselectedColsBuf.length() > 0 && dynselectedColsBuf.charAt(dynselectedColsBuf.length() - 1) == ',') {
        dynselectedColsBuf.deleteCharAt(dynselectedColsBuf.length() - 1);
    }
}

From source file:org.exoplatform.ecm.webui.form.UIDialogForm.java

@SuppressWarnings("unchecked")
public void addActionField(String name, String label, String[] arguments) throws Exception {
    UIFormActionField formActionField = new UIFormActionField(name, label, arguments);
    if (formActionField.useSelector()) {
        componentSelectors.put(name, formActionField.getSelectorInfo());
    }//from   w w  w.  j  av a  2  s  . com
    String jcrPath = formActionField.getJcrPath();
    JcrInputProperty inputProperty = new JcrInputProperty();
    inputProperty.setJcrPath(jcrPath);
    inputProperty.setChangeInJcrPathParam(formActionField.getChangeInJcrPathParam());
    setInputProperty(name, inputProperty);
    Node node = getNode();
    UIComponent uiInput;
    boolean isFirstTimeRender = false;
    if (formActionField.isMultiValues()) {
        uiInput = findComponentById(name);
        if (uiInput == null) {
            isFirstTimeRender = true;
            uiInput = addMultiValuesInput(UIFormStringInput.class, name, label);
            String defaultValue = formActionField.getDefaultValue();
            if (defaultValue != null) {
                if (UIFormMultiValueInputSet.class.isInstance(uiInput)) {
                    String[] arrDefaultValues = defaultValue.split(",");
                    List<String> lstValues = new ArrayList<String>();
                    for (String itemDefaultValues : arrDefaultValues) {
                        if (!lstValues.contains(itemDefaultValues.trim()))
                            lstValues.add(itemDefaultValues.trim());
                    }
                    ((UIFormMultiValueInputSet) uiInput).setValue(lstValues);
                }
            }
        }
        ((UIFormMultiValueInputSet) uiInput).setEditable(formActionField.isEditable());
        if (node == null) {
            renderField(name);
            return;
        }
    } else {
        uiInput = findComponentById(name);
        if (uiInput == null) {
            isFirstTimeRender = true;
            uiInput = formActionField.createUIFormInput();
            addUIFormInput((UIFormInput) uiInput);
        }
        ((UIFormStringInput) uiInput).setEditable(formActionField.isEditable());
    }
    String propertyName = getPropertyName(jcrPath);
    propertiesName.put(name, propertyName);
    fieldNames.put(propertyName, name);

    if (node != null && !isShowingComponent && !isRemovePreference && !isRemoveActionField) {
        if (jcrPath.equals("/node") && (!formActionField.isEditable() || formActionField.isEditableIfNull())) {
            ((UIFormStringInput) uiInput).setDisabled(true);
        }
    }

    if (node != null && !isShowingComponent && !isRemovePreference && !isRemoveActionField
            && isFirstTimeRender) {
        if (jcrPath.equals("/node") && (!formActionField.isEditable() || formActionField.isEditableIfNull())) {
            ((UIFormStringInput) uiInput).setValue(node.getName());
        } else if (node.hasProperty(propertyName) && !isUpdateSelect) {
            String relPath = "";
            String itemRelPath = "";
            if (node.getProperty(propertyName).getDefinition().isMultiple()) {
                StringBuffer buffer = new StringBuffer();
                Value[] values = node.getProperty(propertyName).getValues();
                if (UIFormStringInput.class.isInstance(uiInput)) {
                    for (Value value : values) {
                        buffer.append(value).append(",");
                    }
                    if (buffer.toString().endsWith(","))
                        buffer.deleteCharAt(buffer.length() - 1);
                    ((UIFormStringInput) uiInput).setValue(buffer.toString());
                }
                if (UIFormMultiValueInputSet.class.isInstance(uiInput)) {
                    List<String> lstValues = new ArrayList<String>();
                    for (Value value : values) {
                        lstValues.add(value.getString());
                    }
                    ((UIFormMultiValueInputSet) uiInput).setValue(lstValues);
                }
            } else {
                String value = node.getProperty(propertyName).getValue().getString();
                if (node.getProperty(propertyName).getDefinition().getRequiredType() == PropertyType.REFERENCE)
                    value = getNodePathByUUID(value);
                ((UIFormStringInput) uiInput).setValue(value);
            }
        }
    }
    Node childNode = getChildNode();
    if (isNotEditNode && !isShowingComponent && !isRemovePreference && !isRemoveActionField) {
        if (childNode != null) {
            ((UIFormInput) uiInput).setValue(propertyName);
        } else if (childNode == null && jcrPath.equals("/node") && node != null) {
            ((UIFormInput) uiInput).setValue(node.getName());
        } else {
            ((UIFormInput) uiInput).setValue(null);
        }
    }
    renderField(name);
}

From source file:com.wabacus.system.inputbox.AbsInputBox.java

protected String initDisplaySpanStart(ReportRequest rrequest) {
    StringBuffer resultBuf = new StringBuffer();
    resultBuf.append("<span id=\"span_" + this.owner.getInputBoxId() + "_span\" style=\"display:none;\"");
    if (this.owner instanceof EditableReportColBean) {
        String formatemplate = ((EditableReportColBean) this.owner).getFormatemplate(rrequest);
        if (formatemplate != null && !formatemplate.trim().equals("")) {
            resultBuf.append(" formatemplate=\"").append(Tools.onlyHtmlEncode(formatemplate)).append("\"");
            resultBuf.append(" formatemplate_dyncols=\"")
                    .append(((EditableReportColBean) this.owner).getColPropertyAndPlaceHoldersInFormatemplate())
                    .append("\"");
        }/*ww w  . j  av a2s  .com*/
    }
    String style2 = this.getStyleproperty2(rrequest);
    if (style2 != null && !style2.trim().equals("")) {
        resultBuf.append(" styleproperty=\"" + Tools.jsParamEncode(style2) + "\"");
    }
    if (this.mStyleProperties2 != null) {
        for (Entry<String, String> entryTmp : this.mStyleProperties2.entrySet()) {
            if (entryTmp.getValue() == null || entryTmp.getValue().trim().equals(""))
                continue;
            resultBuf.append(" ").append(entryTmp.getKey()).append("_propertyvalue=\"")
                    .append(entryTmp.getValue()).append("\"");
        }
    }
    if (this.inputboxparams != null && !this.inputboxparams.trim().equals("")) {
        resultBuf.append(" inputboxparams=\"" + this.inputboxparams.trim() + "\"");
    }
    if (this.lstChildids != null && this.lstChildids.size() > 0) {
        resultBuf.append(" childboxids=\"");
        for (String childidTmp : this.lstChildids) {
            resultBuf.append(childidTmp).append(";");
        }
        if (resultBuf.charAt(resultBuf.length() - 1) == ';')
            resultBuf.deleteCharAt(resultBuf.length() - 1);
        resultBuf.append("\"");
    }
    return resultBuf.toString();
}

From source file:org.zkoss.poi.ss.format.CellNumberFormatter.java

/** {@inheritDoc} */
public void formatValue(StringBuffer toAppendTo, Object valueObject) {
    double value = ((Number) valueObject).doubleValue();
    value *= scale;//from w w w  .  j ava2s . c  om

    // For negative numbers:
    // - If the cell format has a negative number format, this method
    // is called with a positive value and the number format has
    // the negative formatting required, e.g. minus sign or brackets.
    // - If the cell format does not have a negative number format,
    // this method is called with a negative value and the number is
    // formatted with a minus sign at the start.
    boolean negative = value < 0;
    if (negative)
        value = -value;

    // Split out the fractional part if we need to print a fraction
    double fractional = 0;
    if (slash != null) {
        if (improperFraction) {
            fractional = value;
            value = 0;
        } else {
            fractional = value % 1.0;
            //noinspection SillyAssignment
            value = (long) value;
        }
    }

    Set<StringMod> mods = new TreeSet<StringMod>();
    StringBuffer output = new StringBuffer(desc);

    if (exponent != null) {
        writeScientific(value, output, mods);
    } else if (improperFraction) {
        writeFraction(value, null, fractional, output, mods);
    } else {
        StringBuffer result = new StringBuffer();
        Formatter f = new Formatter(result, locale); //ZSS-68
        f.format(locale, printfFmt, value); //ZSS-68

        if (numerator == null) {
            writeFractional(result, output);
            writeInteger(result, output, integerSpecials, mods, integerCommas, false);
        } else {
            writeFraction(value, result, fractional, output, mods);
        }
    }

    // Now strip out any remaining '#'s and add any pending text ...
    ListIterator<Special> it = specials.listIterator();
    Iterator<StringMod> changes = mods.iterator();
    StringMod nextChange = (changes.hasNext() ? changes.next() : null);
    int adjust = 0;
    BitSet deletedChars = new BitSet(); // records chars already deleted
    final String groupSeparator = "" + Formatters.getGroupingSeparator(locale); //ZSS-68
    while (it.hasNext()) {
        Special s = it.next();
        int adjustedPos = s.pos + adjust;
        if (!deletedChars.get(s.pos) && output.charAt(adjustedPos) == '#') {
            output.deleteCharAt(adjustedPos);
            adjust--;
            deletedChars.set(s.pos);
        }
        while (nextChange != null && s == nextChange.special) {
            int lenBefore = output.length();
            int modPos = s.pos + adjust;
            int posTweak = 0;
            switch (nextChange.op) {
            case StringMod.AFTER:
                // ignore adding a comma after a deleted char (which was a '#')
                if (nextChange.toAdd.equals(groupSeparator) && deletedChars.get(s.pos)) //20110321, henrichen@zkoss.org: respect current locale
                    break;
                posTweak = 1;
                //noinspection fallthrough
            case StringMod.BEFORE:
                output.insert(modPos + posTweak, nextChange.toAdd);
                break;

            case StringMod.REPLACE:
                int delPos = s.pos; // delete starting pos in original coordinates
                if (!nextChange.startInclusive) {
                    delPos++;
                    modPos++;
                }

                // Skip over anything already deleted
                while (deletedChars.get(delPos)) {
                    delPos++;
                    modPos++;
                }

                int delEndPos = nextChange.end.pos; // delete end point in original
                if (nextChange.endInclusive)
                    delEndPos++;

                int modEndPos = delEndPos + adjust; // delete end point in current

                if (modPos < modEndPos) {
                    if (nextChange.toAdd == "")
                        output.delete(modPos, modEndPos);
                    else {
                        char fillCh = nextChange.toAdd.charAt(0);
                        for (int i = modPos; i < modEndPos; i++)
                            output.setCharAt(i, fillCh);
                    }
                    deletedChars.set(delPos, delEndPos);
                }
                break;

            default:
                throw new IllegalStateException("Unknown op: " + nextChange.op);
            }
            adjust += output.length() - lenBefore;

            if (changes.hasNext())
                nextChange = changes.next();
            else
                nextChange = null;
        }
    }

    // Finally, add it to the string
    if (negative)
        toAppendTo.append('-');
    toAppendTo.append(output);
}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsListReportType.java

protected String showMetaDataDisplayStringStart() {
    StringBuffer resultBuf = new StringBuffer();
    resultBuf.append(super.showMetaDataDisplayStringStart());
    String rowselecttype = this.alrbean.getRowSelectType();
    if (rowselecttype != null && !rowselecttype.trim().equals("")) {//
        resultBuf.append(" rowselecttype=\"").append(rowselecttype).append("\"");
        resultBuf.append(" isSelectRowCrossPages=\"").append(this.alrbean.isSelectRowCrossPages()).append("\"");
        if (!rowselecttype.trim().equalsIgnoreCase(Consts.ROWSELECT_NONE)) {
            List<String> lstRowSelectCallBackFuns = this.alrbean.getLstRowSelectCallBackFuncs();
            if (lstRowSelectCallBackFuns != null && lstRowSelectCallBackFuns.size() > 0) {
                StringBuffer rowSelectMethodBuf = new StringBuffer();
                rowSelectMethodBuf.append("{rowSelectMethods:[");
                for (String callbackFunc : lstRowSelectCallBackFuns) {
                    if (callbackFunc != null && !callbackFunc.trim().equals("")) {
                        rowSelectMethodBuf.append("{value:").append(callbackFunc).append("},");
                    }/*from   ww  w.j  av  a 2 s  . c o  m*/
                }
                if (rowSelectMethodBuf.charAt(rowSelectMethodBuf.length() - 1) == ',')
                    rowSelectMethodBuf.deleteCharAt(rowSelectMethodBuf.length() - 1);
                rowSelectMethodBuf.append("]}");
                resultBuf.append(" rowSelectMethods=\"").append(rowSelectMethodBuf.toString()).append("\"");
            }
        }
    }
    return resultBuf.toString();
}

From source file:org.bibsonomy.scraper.converter.EndnoteToBibtexConverter.java

private String buildBibtex(Map<String, String> data) {

    //the StringBuffer to store the complete String
    StringBuffer result = new StringBuffer();

    try {//w w  w . j a va  2s  . c  o m
        /*
         * if the data map is empty return null because it cant be an
         * endnote file.
         */
        if (data.isEmpty()) {
            return null;
        }

        /*
         * if no type is available the we use the following rules to specify the reference type
         * 
         * 1. %J and %V                -> article (Journal Article)
         * 2. %B                      -> incollection (Book Section)
         * 3. %R but not %T             -> misc (Report)
         * 4. %I without %B, %J, or %R       -> book (Book)
         * 5. Neither %B, %J, %R, nor %I    -> article (Journal Article)
         */
        if (!data.containsKey("type")) {
            if (data.containsKey("journal") && data.containsKey("volume")) {
                data.put("type", "article");
            } else if (data.containsKey("booktitle")) {
                data.put("type", "incollection");
            } else if (data.containsKey("address")
                    && !(data.containsKey("booktitle") || data.containsKey("journal"))) {
                data.put("type", "book");
            } else if (!data.containsKey("booktitle") && !data.containsKey("journal")
                    && !data.containsKey("%address")) {
                data.put("type", "article");
            }
        }

        // test if some necessary items were available, if not need to fix that with dummys
        if (!data.containsKey("type")) {
            data.put("type", "misc");
        }

        //now the bibtex part will be build completely starting with the type
        //clean up key (in InformaworldScraper a "," occurs in key, which results in a broken bibtex entry
        result.append("@" + data.get("type") + "{" + data.get("key").replace(",", "") + ",\n");
        data.remove("type");
        data.remove("key");

        //add every item of the data map to the stringbuffer
        for (String key : data.keySet()) {
            result.append(key + " = {" + data.get(key) + "},\n");
        }

        // remove "," before last "\n"
        result.deleteCharAt(result.length() - 2);

        // and at the end close the bibtexpart
        result.append("}");

    } catch (Exception e) {
        log.fatal("Could not build the bibtex part :" + e);
    }

    //return the final String
    return result.toString();
}

From source file:com.wabacus.system.ReportRequest.java

public String getDataExportFilename() {
    StringBuffer filenameBuf = new StringBuffer();
    if (this.lstComponentBeans == null || this.lstComponentBeans.size() == 0)
        return "NoData";
    String filenameTmp;/*from   w w  w  .j a va 2  s.c  o  m*/
    for (IComponentConfigBean ccbeanTmp : this.lstComponentBeans) {
        filenameTmp = null;
        if (ccbeanTmp.getDataExportsBean() != null) {
            filenameTmp = ccbeanTmp.getDataExportsBean().getFilename(this);
        }
        if (filenameTmp == null || filenameTmp.trim().equals("")) {//<dataexports/>?filename???
            filenameTmp = ccbeanTmp.getTitle(this);
        }
        if (filenameTmp == null || filenameTmp.trim().equals(""))
            continue;
        filenameBuf.append(filenameTmp).append(",");
    }
    if (filenameBuf.length() == 0)
        return "DataExport";
    if (filenameBuf.charAt(filenameBuf.length() - 1) == ',')
        filenameBuf.deleteCharAt(filenameBuf.length() - 1);
    return filenameBuf.toString();
}

From source file:com.jd.survey.service.util.SPSSHelperService.java

/**
 * Returns the SPSS variable value definitions for a survey
 * @param surveyDefinition//from  www  .ja v  a  2  s .  c  o m
 * @return
 */
private StringBuffer getSurveySPSSVaribaleValues(SurveyDefinition surveyDefinition) {
    try {
        DataSet dataset;
        StringBuffer sb = new StringBuffer();
        for (SurveyDefinitionPage page : surveyDefinition.getPages()) {
            for (Question question : page.getQuestions()) {

                Policy policy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION));
                AntiSamy as = new AntiSamy();
                CleanResults cr = as.scan(question.getQuestionText(), policy);
                question.setQuestionText(cr.getCleanHTML());

                switch (question.getType()) {
                case YES_NO_DROPDOWN: //Yes No DropDown
                    sb.append("VALUE LABELS ").append(getSPSSVariableName(question))
                            .append(" 1 'Yes' 0 'No'.\n");
                    break;
                case SHORT_TEXT_INPUT: //Short Text Input
                    break;
                case LONG_TEXT_INPUT: //Long Text Input
                    break;
                case HUGE_TEXT_INPUT: //Huge Text Input
                    break;
                case INTEGER_INPUT: //Integer Input
                    break;
                case CURRENCY_INPUT: //Currency Input
                    break;
                case DECIMAL_INPUT: //Decimal Input
                    break;
                case DATE_INPUT: //Date Input
                    break;
                case SINGLE_CHOICE_DROP_DOWN: //Single choice Drop Down
                    sb.append("VALUE LABELS ").append(getSPSSVariableName(question)).append("\n");
                    for (QuestionOption option : question.getOptions()) {
                        sb.append("'").append(option.getValue().replace("'", "").replace("\"", "")).append("' ")
                                .append("'").append(option.getText().replace("'", "").replace("\"", ""))
                                .append("' ");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    sb.append(".\n");
                    break;
                case MULTIPLE_CHOICE_CHECKBOXES: //Multiple Choice Checkboxes
                    for (QuestionOption option : question.getOptions()) {
                        sb.append("VALUE LABELS ").append(getSPSSVariableName(option))
                                .append(" 1 'Yes' 0 'Not selected'.\n");

                    }
                    break;
                /*   
                case DATASET_DROP_DOWN: //DataSet Drop Down
                   sb.append("VALUE LABELS ").append(getSPSSVariableName(question)).append("\n");
                   dataset = dataSetDAO.findByName(question.getDataSetCode());
                   for (DataSetItem dataSetItem :dataset.getItems()) {   
                      sb.append("'").append(dataSetItem.getValue().replace("'", "").replace("\"", "")).append("' ").append("'").append(dataSetItem.getText().replace("'", "").replace("\"", "")).append("' ");
                   }
                   sb.deleteCharAt(sb.length()-1); 
                   sb.append(".\n"); 
                   break;
                */
                case SINGLE_CHOICE_RADIO_BUTTONS: //Single Choice Radio Buttons
                    sb.append("VALUE LABELS ").append(getSPSSVariableName(question)).append("\n");
                    for (QuestionOption option : question.getOptions()) {
                        sb.append("'").append(option.getValue().replace("'", "").replace("\"", "")).append("' ")
                                .append("'").append(option.getText().replace("'", "").replace("\"", ""))
                                .append("' ");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    sb.append(".\n");
                    break;

                case YES_NO_DROPDOWN_MATRIX:
                    for (QuestionRowLabel questionRowLabel : question.getRowLabels()) {
                        for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
                            sb.append("VALUE LABELS ").append(
                                    getSPSSVariableName(question, questionRowLabel, questionColumnLabel))
                                    .append(" 1 'Yes' 0 'No'.\n");
                        }
                    }
                    break;

                case SHORT_TEXT_INPUT_MATRIX:
                    break;
                case INTEGER_INPUT_MATRIX:
                    break;
                case CURRENCY_INPUT_MATRIX:
                    break;
                case DECIMAL_INPUT_MATRIX:
                    break;
                case DATE_INPUT_MATRIX:
                    break;
                case IMAGE_DISPLAY:
                    break;

                case VIDEO_DISPLAY:
                    break;

                case FILE_UPLOAD:
                    break;
                case STAR_RATING:
                    sb.append("VALUE LABELS ").append(getSPSSVariableName(question)).append("\n");
                    for (QuestionOption option : question.getOptions()) {
                        sb.append("'").append(option.getValue().replace("'", "").replace("\"", "")).append("' ")
                                .append("'").append(option.getText().replace("'", "").replace("\"", ""))
                                .append("' ");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    sb.append(".\n");
                    break;
                case SMILEY_FACES_RATING:
                    sb.append("VALUE LABELS ").append(getSPSSVariableName(question)).append("\n");
                    for (QuestionOption option : question.getOptions()) {
                        sb.append("'").append(option.getValue().replace("'", "").replace("\"", "")).append("' ")
                                .append("'").append(option.getText().replace("'", "").replace("\"", ""))
                                .append("' ");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    sb.append(".\n");
                    break;
                }

            }
        }
        return sb;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}