Example usage for java.lang StringBuilder replace

List of usage examples for java.lang StringBuilder replace

Introduction

In this page you can find the example usage for java.lang StringBuilder replace.

Prototype

@Override
public StringBuilder replace(int start, int end, String str) 

Source Link

Usage

From source file:org.schemaspy.view.StyleSheet.java

private StyleSheet(BufferedReader cssReader) throws IOException {
    String lineSeparator = System.getProperty("line.separator");
    StringBuilder data = new StringBuilder();
    String line;//from www .j a v a  2s  .c om

    while ((line = cssReader.readLine()) != null) {
        data.append(line);
        data.append(lineSeparator);
    }

    css = data.toString();

    int startComment = data.indexOf("/*");
    while (startComment != -1) {
        int endComment = data.indexOf("*/");
        data.replace(startComment, endComment + 2, "");
        startComment = data.indexOf("/*");
    }

    StringTokenizer tokenizer = new StringTokenizer(data.toString(), "{}");
    String id = null;
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken().trim();
        if (id == null) {
            id = token.toLowerCase();
            ids.add(id);
        } else {
            Map<String, String> attribs = parseAttributes(token);
            if (id.equals(".diagram"))
                bodyBackgroundColor = attribs.get("background");
            else if (id.equals("th.diagram"))
                tableHeadBackgroundColor = attribs.get("background-color");
            else if (id.equals("td.diagram"))
                tableBackgroundColor = attribs.get("background-color");
            else if (id.equals(".diagram .primarykey"))
                primaryKeyBackgroundColor = attribs.get("background");
            else if (id.equals(".diagram .indexedcolumn"))
                indexedColumnBackgroundColor = attribs.get("background");
            else if (id.equals(".selectedtable"))
                selectedTableBackgroundColor = attribs.get("background");
            else if (id.equals(".excludedcolumn"))
                excludedColumnBackgroundColor = attribs.get("background");
            else if (id.equals("a:link"))
                linkColor = attribs.get("color");
            else if (id.equals("a:visited"))
                linkVisitedColor = attribs.get("color");
            id = null;
        }
    }
}

From source file:nl.ru.cmbi.vase.parse.StockholmParser.java

private static void goThroughStockholm(InputStream stockholmIn,

        final AlignmentSet alignments, // output
        final ResidueInfoSet residueInfoSet, // output
        char requestedChain // '*' for all chains

) throws Exception {

    final StringBuilder pdbID = new StringBuilder();

    final boolean takeAllChains = (requestedChain == '*');

    final BufferedReader reader = new BufferedReader(new InputStreamReader(stockholmIn));

    char currentChain = 'A';
    final Pattern vp = Pattern.compile(variabilityLinePattern), pp = Pattern.compile(profileLinePattern),
            sp = Pattern.compile(seqLinePattern), cp = Pattern.compile(chainLinePattern);

    String line;/*from w w  w  .j  a va2 s  .  com*/
    int linenr = 0;
    while ((line = reader.readLine()) != null) {
        linenr++;

        Matcher vm = vp.matcher(line), pm = pp.matcher(line), sm = sp.matcher(line), cm = cp.matcher(line);

        if (line.trim().equals("//")) { // indicates the end of the current chain

            if (!takeAllChains && currentChain == requestedChain) {

                break; // end of the requested chain
            }

            currentChain = ' ';
        } else if (line.matches(pdbIDLinePattern)) {

            final String[] s = line.trim().split("\\s+");

            pdbID.replace(0, pdbID.length(), s[s.length - 1]);

        } else if (cm.matches()) {

            final String ac = cm.group(1);
            currentChain = cm.group(2).charAt(0);

            if (!pdbID.toString().equalsIgnoreCase(ac)) {
                throw new Exception("line " + linenr + ": got id " + ac + ", but expected: " + pdbID);
            }

            pdbID.replace(0, pdbID.length(), ac);

            if (!takeAllChains && currentChain != requestedChain) {
                continue;
            }

            alignments.addChain(currentChain);

        } else if (line.matches(dbRefLinePattern)) {

            // DBRefs don't indicate the current chain
            continue;

        } else if (vm.matches()) {

            char chain = vm.group(3).charAt(0), AA = vm.group(4).charAt(0);
            String pdbno = vm.group(2).trim();
            int seqno = Integer.parseInt(vm.group(1).trim()), var = Integer.parseInt(vm.group(10).trim());

            if (!takeAllChains && chain != requestedChain) {
                continue;
            }

            ResidueInfo res = residueInfoSet.getResidue(chain, seqno);

            res.setPdbNumber(pdbno);
            res.setVar(var);
            res.setAa(AA);

        } else if (pm.matches()) {

            char chain = pm.group(3).charAt(0);

            int seqno = Integer.parseInt(pm.group(1).trim()), relent = Integer.parseInt(pm.group(9).trim());

            double entropy = Double.parseDouble(pm.group(8)), weight = Double.parseDouble(pm.group(10));

            if (!takeAllChains && chain != requestedChain) {
                continue;
            }

            ResidueInfo res = residueInfoSet.getResidue(chain, seqno);

            res.setEntropy(entropy);
            res.setRelent(relent);
            res.setWeight(weight);

        } else if (line.matches(equalchainsLinePattern)) {
            // these lines define references of one chain to the other

            final String[] s = line.trim().split("\\s+");
            final char sourceChain = s[3].charAt(0);

            // Chain listing starts at the 11th word in the expression.
            for (int i = 11; i < s.length; i++) {

                if (s.equals("and"))
                    continue; // 'and' is not a chain-ID, it's an interjection

                final char destChain = s[i].charAt(0); // Take the first character in the word, thus not the commas!

                if (!takeAllChains) {

                    if (destChain == requestedChain) {

                        // means we must parse this chain instead
                        requestedChain = sourceChain;
                        alignments.addChain(sourceChain);

                    } else
                        continue;
                }

                residueInfoSet.addChainReference(sourceChain, destChain);
                alignments.addChainReference(sourceChain, destChain);
            }
        } else if ((takeAllChains || currentChain == requestedChain) && sm.matches()) {

            final String label = sm.group(1), seq = sm.group(2);

            alignments.addToSeq(currentChain, label, seq);
        }
    }

    reader.close();
}

From source file:raptor.connector.ics.IcsUtils.java

/**
 * Maciejg format, named after him because of his finger notes. Unicode
 * chars are represented as &#x3b1; &#x3b2; &#x3b3; &#x3b4; &#x3b5; &#x3b6;
 * unicode equivalent \u03B1,\U03B2,...//from   w  w  w. j  av  a 2  s .  c  om
 */
public static String maciejgFormatToUnicode(String inputString) {
    StringBuilder builder = new StringBuilder(inputString);
    int unicodePrefix = 0;
    while ((unicodePrefix = builder.indexOf("&#x", unicodePrefix)) != -1) {
        int endIndex = builder.indexOf(";", unicodePrefix);
        if (endIndex == -1) {
            break;
        }
        String maciejgWord = builder.substring(unicodePrefix + 3, endIndex);
        maciejgWord = StringUtils.replaceChars(maciejgWord, " \\\n", "").toUpperCase();
        if (maciejgWord.length() <= 5) {
            try {
                int intValue = Integer.parseInt(maciejgWord, 16);
                String unicode = new String(new char[] { (char) intValue });
                builder.replace(unicodePrefix, endIndex + 1, unicode);
            } catch (NumberFormatException nfe) {
                unicodePrefix = endIndex + 1;
            }
        } else {
            unicodePrefix = endIndex + 1;
        }
    }
    return builder.toString();
}

From source file:org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingConverter.java

/**
 * Currently this is a quick-hack implementation. TODO implement using a real templating library
 *///from w w  w . ja  v  a 2s  .  c o  m
private String applyTemplate(String uriTemplate, SimpleObject object) {
    StringBuilder sb = new StringBuilder(uriTemplate);
    while (sb.indexOf("{") >= 0) {
        int startIndex = sb.indexOf("{");
        int endIndex = sb.indexOf("}", startIndex + 1);
        if (endIndex < 0) {
            throw new IllegalArgumentException("Cannot find matching } in " + uriTemplate);
        }
        String varName = sb.substring(startIndex + 1, endIndex);
        String replaceWithValue = (String) ConversionUtil.convert(object.get(varName), String.class);
        sb.replace(startIndex, endIndex + 1, replaceWithValue);
    }
    return sb.toString();
}

From source file:simplealbum.mvc.autocomplete.DController.java

private void colorInputText() {
    EventQueue.invokeLater(() -> {
        try {//from   w w  w.  j  a v a  2  s. c o m
            String inputText = jTextPaneDocument.getText(0, jTextPaneDocument.getLength());
            StringBuilder inputMut = new StringBuilder(inputText);
            String[] split = StringUtils.split(inputMut.toString());
            int i = 0;
            for (String string : split) {
                int start = inputMut.indexOf(string);
                int end = start + string.length();
                inputMut.replace(start, end, StringUtils.repeat(" ", string.length()));
                jTextPaneDocument.setCharacterAttributes(start, string.length(), styles[i++ % styles.length],
                        true);
            }
        } catch (BadLocationException ex) {
            Logger.getLogger(DController.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
}

From source file:org.opendaylight.controller.liblldp.Packet.java

@Override
public String toString() {
    StringBuilder ret = new StringBuilder();
    ret.append(this.getClass().getSimpleName());
    ret.append(": [");
    for (String field : hdrFieldCoordMap.keySet()) {
        byte[] value = hdrFieldsMap.get(field);
        ret.append(field);//from   www  .  j  a v  a2  s.  co m
        ret.append(": ");
        ret.append(HexEncode.bytesToHexString(value));
        ret.append(", ");
    }
    ret.replace(ret.length() - 2, ret.length() - 1, "]");
    return ret.toString();
}

From source file:com.hybris.mobile.adapter.FormAdapter.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override// ww w  .j  a  va2 s.  c  o m
public View getView(final int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.form_row, parent, false);

    LinearLayout lnr = (LinearLayout) rowView.findViewById(R.id.linear_layout_form);
    final Hashtable<String, Object> obj = (Hashtable<String, Object>) objects.get(position);

    String className = "com.hybris.mobile.view." + obj.get("cellIdentifier").toString();
    Object someObj = null;
    try {
        Class cell;

        cell = Class.forName(className);

        Constructor constructor = cell.getConstructor(new Class[] { Context.class });
        someObj = constructor.newInstance(this.context);
    } catch (Exception e) {
        LoggingUtils.e(LOG_TAG, "Error loading class \"" + className + "\". " + e.getLocalizedMessage(),
                Hybris.getAppContext());
    }
    /*
     * Text Cell
     */

    if (someObj != null && someObj instanceof HYFormTextEntryCell) {

        final HYFormTextEntryCell textCell = (HYFormTextEntryCell) someObj;

        if (isLastEditText(position)) {
            textCell.setImeDone(this);
        }

        lnr.addView(textCell);

        textCell.setId(position);
        if (obj.containsKey("inputType")) {
            Integer val = mInputTypes.get(obj.get("inputType").toString());
            textCell.setContentInputType(val);
        }
        if (obj.containsKey("value")) {
            textCell.setContentText(obj.get("value").toString());
        }

        if (obj.containsKey("keyboardType")
                && StringUtils.equals(obj.get("keyboardType").toString(), "UIKeyboardTypeEmailAddress")) {
            textCell.setContentInputType(mInputTypes.get("textEmailAddress"));
        }

        textCell.addContentChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                obj.put("value", s.toString());
                notifyFormDataChangedListner();
            }
        });
        textCell.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    textCell.setTextColor(context.getResources().getColor(R.color.textMedium));
                    if (!fieldIsValid(position)) {
                        setIsValid(false);
                        textCell.showMessage(true);
                    } else {
                        textCell.showMessage(false);
                    }
                    showInvalidField();
                    validateAllFields();
                } else {
                    textCell.setTextColor(context.getResources().getColor(R.color.textHighlighted));
                    setCurrentFocusIndex(position);
                }
            }
        });

        textCell.setContentTitle(obj.get("title").toString());
        if (obj.containsKey("error")) {
            textCell.setMessage(obj.get("error").toString());
        }

        if (obj.containsKey("showerror")) {
            Boolean showerror = Boolean.parseBoolean(obj.get("showerror").toString());
            textCell.showMessage(showerror);
        } else {
            textCell.showMessage(false);
        }

        if (currentFocusIndex == position) {
            textCell.setFocus();
        }
    }
    /*
     * Secure Text Cell
     */

    else if (someObj instanceof HYFormSecureTextEntryCell) {
        final HYFormSecureTextEntryCell secureTextCell = (HYFormSecureTextEntryCell) someObj;

        if (isLastEditText(position)) {
            secureTextCell.setImeDone(this);
        }
        lnr.addView(secureTextCell);

        secureTextCell.setId(position);
        if (obj.containsKey("value")) {
            secureTextCell.setContentText(obj.get("value").toString());
        }
        if (obj.containsKey("inputType")) {
            Integer val = mInputTypes.get(obj.get("inputType").toString());
            secureTextCell.setContentInputType(val);
        }
        secureTextCell.addContentChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                obj.put("value", s.toString());
                notifyFormDataChangedListner();
            }

        });
        secureTextCell.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    if (!fieldIsValid(position)) {
                        setIsValid(false);
                        secureTextCell.showMessage(true);
                    } else {
                        secureTextCell.showMessage(false);
                    }
                    showInvalidField();
                    validateAllFields();
                } else {
                    setCurrentFocusIndex(position);
                }
            }
        });

        secureTextCell.setContentTitle(obj.get("title").toString());
        if (obj.containsKey("error")) {
            secureTextCell.setMessage(obj.get("error").toString());
        }

        if (obj.containsKey("showerror")) {
            Boolean showerror = Boolean.parseBoolean(obj.get("showerror").toString());
            secureTextCell.showMessage(showerror);
        } else {
            secureTextCell.showMessage(false);
        }

        if (currentFocusIndex == position) {
            secureTextCell.setFocus();
        }
    } else if (someObj instanceof HYFormTextSelectionCell) {

        setIsValid(fieldIsValid(position));

        HYFormTextSelectionCell selectionTextCell = (HYFormTextSelectionCell) someObj;
        lnr.addView(selectionTextCell);

        if (StringUtils.isNotBlank((String) obj.get("value"))) {
            StringBuilder b = new StringBuilder(obj.get("value").toString());
            selectionTextCell.setSpinnerText(b.replace(0, 1, b.substring(0, 1).toUpperCase()).toString());
        } else {
            selectionTextCell.setSpinnerText(obj.get("title").toString());
        }
    } else if (someObj instanceof HYFormTextSelectionCell2) {
        HYFormTextSelectionCell2 selectionTextCell = (HYFormTextSelectionCell2) someObj;
        lnr.addView(selectionTextCell);
        selectionTextCell.init(obj);
    } else if (someObj instanceof HYFormSwitchCell) {
        HYFormSwitchCell checkBox = (HYFormSwitchCell) someObj;
        lnr.addView(checkBox);
        checkBox.setCheckboxText(obj.get("title").toString());
        if (StringUtils.isNotBlank((String) obj.get("value"))) {
            checkBox.setCheckboxChecked(Boolean.parseBoolean((String) obj.get("value")));
        }

        checkBox.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                HYFormSwitchCell chk = (HYFormSwitchCell) v;
                chk.toggleCheckbox();
                obj.put("value", String.valueOf(chk.isCheckboxChecked()));
                notifyFormDataChangedListner();
            }
        });
    } else if (someObj instanceof HYFormSubmitButton) {
        HYFormSubmitButton btnCell = (HYFormSubmitButton) someObj;
        lnr.addView(btnCell);
        btnCell.setButtonText(obj.get("title").toString());
        btnCell.setOnButtonClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                submit();
            }
        });
    }

    return rowView;
}

From source file:org.opencb.commons.utils.CommandLineUtils.java

/**
 * Create the following strings from the jCommander to create AutoComplete bash script:
 * commands="users projects studies files jobs individuals families samples variables cohorts alignments variant"
 * users="create info update change-password delete projects login logout reset-password"
 * ...//www .j  a  v  a2  s .  c  o m
 * users_create_options="--password --help --log-file --email --name --log-level --conf --organization --output-format --session-id"
 * ...
 * This accepts two levels: commands and subcommands
 *
 * @param jCommander    JComander object to extractt commands and subcommonds
 * @param fileName      Filename destination
 * @param bashFunctName Name of the bash function to autocomplete
 * @param excludeParams List of params to be excluded
 * @throws IOException If the destination file cannot be written
 */
public static void generateBashAutoComplete(JCommander jCommander, String fileName, String bashFunctName,
        List<String> excludeParams) throws IOException {
    Map<String, JCommander> jCommands = jCommander.getCommands();
    StringBuilder mainCommands = new StringBuilder();
    StringBuilder subCommmands = new StringBuilder();
    StringBuilder subCommmandsOptions = new StringBuilder();

    // Create a HashSet to skip excluded parameters
    Set<String> excludeParamsSet;
    if (excludeParams == null) {
        excludeParamsSet = new HashSet<>();
    } else {
        excludeParamsSet = new HashSet<>(excludeParams);
    }

    for (String command : jCommands.keySet()) {
        JCommander subCommand = jCommands.get(command);
        mainCommands.append(command).append(" ");
        subCommmands.append(command + "=" + "\"");
        Map<String, JCommander> subSubCommands = subCommand.getCommands();
        for (String sc : subSubCommands.keySet()) {
            subCommmands.append(sc).append(" ");
            subCommmandsOptions.append(command + "_");
            // - is not allowed in bash main variable name, replacing it with _
            subCommmandsOptions.append(sc.replaceAll("[-.]+", "_") + "_" + "options=" + "\"");
            JCommander subCommandOptions = subSubCommands.get(sc);
            for (ParameterDescription param : subCommandOptions.getParameters()) {
                // Add parameter if it is not excluded
                if (!excludeParamsSet.contains(param.getLongestName())) {
                    subCommmandsOptions.append(param.getLongestName()).append(' ');
                }
            }
            subCommmandsOptions.replace(0, subCommmandsOptions.length(), subCommmandsOptions.toString().trim())
                    .append("\"" + "\n");
        }
        subCommmands.replace(0, subCommmands.length(), subCommmands.toString().trim()).append("\"" + "\n");
    }

    // Commands(Commands, subCommands and subCommandOptions) are populated intro three strings until this point,
    // Now we write bash script commands and blend these strings into those as appropriate
    StringBuilder autoComplete = new StringBuilder();
    autoComplete.append("_" + bashFunctName + "() \n { \n local cur prev opts \n COMPREPLY=() \n cur=" + "$"
            + "{COMP_WORDS[COMP_CWORD]} \n prev=" + "$" + "{COMP_WORDS[COMP_CWORD-1]} \n");

    autoComplete.append("commands=\"").append(mainCommands.toString().trim()).append('"').append('\n');
    autoComplete.append(subCommmands.toString());
    autoComplete.append(subCommmandsOptions.toString());
    autoComplete
            .append("if [[ ${#COMP_WORDS[@]} > 2 && ${#COMP_WORDS[@]} < 4 ]] ; then \n local options \n case "
                    + "$" + "{prev} in \n");

    for (String command : mainCommands.toString().split(" ")) {
        autoComplete.append("\t" + command + ") options=" + "\"" + "${" + command + "}" + "\"" + " ;; \n");
    }

    autoComplete.append("*) ;; \n esac \n COMPREPLY=( $( compgen -W " + "\"" + "$" + "options" + "\""
            + " -- ${cur}) ) \n return 0 \n elif [[ ${#COMP_WORDS[@]} > 3 ]] ; then \n local options \n case "
            + "$" + "{COMP_WORDS[1]} in \n");

    int subCommandIndex = 0;
    for (String command : mainCommands.toString().split(" ")) {
        String[] splittedSubCommands = subCommmands.toString().split("\n")[subCommandIndex]
                .replace(command + "=" + "\"", "").replace("\"", "").split(" ");

        if (splittedSubCommands[0].isEmpty()) {
            ++subCommandIndex;
        } else {
            autoComplete.append('\t').append(command).append(") \n");
            autoComplete.append("\t\t case " + "$" + "{COMP_WORDS[2]} in \n");

            for (String subCommand : splittedSubCommands) {
                autoComplete.append("\t\t").append(subCommand).append(") options=").append("\"").append("${")
                        .append(command).append("_").append(subCommand.replaceAll("[-.]+", "_"))
                        .append("_options}").append("\"").append(" ;; \n");
            }
            autoComplete.append("\t\t *) ;; esac ;; \n");
            ++subCommandIndex;
        }
    }
    autoComplete.append("*) ;;  esac \n COMPREPLY=( $( compgen -W " + "\"" + "$" + "options" + "\""
            + " -- ${cur}) )" + " \n return 0 \n fi \n if [[ ${cur} == * ]] ; then \n COMPREPLY=( $(compgen -W "
            + "\"" + "$" + "{commands}" + "\"" + " -- ${cur}) ) \n return 0 \n fi \n } \n");

    autoComplete.append("\n");
    autoComplete.append("complete -F _" + bashFunctName + " " + bashFunctName + ".sh").append('\n');
    //        autoComplete.append("complete -F _" + bashFunctName + " ./bin/" + bashFunctName + ".sh").append('\n');
    //        autoComplete.append("complete -F _" + bashFunctName + " /opt/" + bashFunctName + "/bin/" + bashFunctName + ".sh").append('\n');

    try {
        PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
        pw.write(autoComplete.toString());
        pw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.rhq.enterprise.server.measurement.util.MeasurementDataManagerUtility.java

private void replaceNextPlaceHolders(StringBuilder sqlWithQuestionMarks, Object... valuesToReplace) {
    for (Object nextValue : valuesToReplace) {
        int index = sqlWithQuestionMarks.indexOf("?");
        sqlWithQuestionMarks.replace(index, index + 1, String.valueOf(nextValue));
    }//w w w.ja v a2  s.c  o m
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.views.scm.SCMLabelProvider.java

/**
 * Gets the text for a history info. This may be overridden by subclasses to
 * change the behavior (e.g. if info should be distributed across multiply
 * label providers)// w  w  w  .j  a va 2s . c o m
 * 
 * @param historyInfo
 *            The historInfo the text is retrieved for.
 * @return The text for the given historyInfo.
 */
protected String getText(HistoryInfo historyInfo) {
    if (historyInfo.getPrimarySpec() != null && historyInfo.getPrimarySpec().getIdentifier() == -1) {
        return LOCAL_REVISION;
    }

    String baseVersion = StringUtils.EMPTY;
    if (historyInfo.getPrimarySpec().getIdentifier() == ESWorkspaceProviderImpl.getProjectSpace(project)
            .getBaseVersion().getIdentifier()) {
        baseVersion = "*"; //$NON-NLS-1$
    }
    final StringBuilder builder = new StringBuilder();

    if (!historyInfo.getTagSpecs().isEmpty()) {
        builder.append("["); //$NON-NLS-1$
        for (final TagVersionSpec versionSpec : historyInfo.getTagSpecs()) {
            builder.append(versionSpec.getName());
            builder.append(","); //$NON-NLS-1$
        }
        builder.replace(builder.length() - 1, builder.length(), "] "); //$NON-NLS-1$
    }

    builder.append(baseVersion);
    builder.append("Version ");
    builder.append(historyInfo.getPrimarySpec().getIdentifier());
    LogMessage logMessage = null;

    if (historyInfo.getLogMessage() != null) {
        logMessage = historyInfo.getLogMessage();
    } else if (historyInfo.getChangePackage() != null
            && historyInfo.getChangePackage().getLogMessage() != null) {
        logMessage = historyInfo.getChangePackage().getLogMessage();
    }
    if (logMessage != null) {
        builder.append(" ["); //$NON-NLS-1$
        builder.append(logMessage.getAuthor());
        final Date clientDate = logMessage.getClientDate();
        if (clientDate != null) {
            builder.append(" @ "); //$NON-NLS-1$
            builder.append(dateFormat.format(clientDate));
        }
        builder.append("] "); //$NON-NLS-1$
        builder.append(logMessage.getMessage());
    }
    return builder.toString();
}