Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.List;
import java.util.Map;

public class Main {
    private static final String DATABASE_TITLE_PREFIX = "Database Connector Result";

    /**
     * Generates the title of the DB document.
     *
     * @param primaryKeys primary keys of the database.
     * @param row row corresponding to the document.
     * @return title String.
     */
    private static String getTitle(List<String> primaryKeys, Map<String, Object> row) {
        StringBuilder title = new StringBuilder();
        title.append(DATABASE_TITLE_PREFIX);
        for (String primaryKey : primaryKeys) {
            Object keyValue = row.get(primaryKey);
            String strKeyValue;
            if (keyValue == null || keyValue.toString().trim().length() == 0) {
                strKeyValue = "";
            } else {
                strKeyValue = keyValue.toString();
            }
            title.append(" ").append(primaryKey).append("=").append(strKeyValue);
        }
        return title.toString();
    }
}