com.app.simple.utils.gps.SimpleStringJoin.java Source code

Java tutorial

Introduction

Here is the source code for com.app.simple.utils.gps.SimpleStringJoin.java

Source

/*
 * Copyright 2002-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.app.simple.utils.gps;

import java.util.Date;

import org.apache.commons.lang.time.DateFormatUtils;

/**
 * 
 * @packageName com.dong.util
 * 
 * @createClass class SimpleStringJoin.java
 * 
 * @description <p>
 *              //?
 * 
 *              </p>
 * @author Chris Yu
 * 
 * @mail chao.yu.@sim.com
 * 
 * @createTime 2014-5-9 ?11:01:17
 * 
 * @version 1.0
 */
public class SimpleStringJoin {

    // ?
    private static String ANSWER_PREFIX = "[";
    // ?
    private static String ANSWER_SUFFIX = "]";
    // 
    private static String JOIN_STR = ",";
    // ?
    private static String DATE_FROMAT_STR = "yyyy-MM-dd HH:mm:ss";

    private StringBuilder simpleStrJoin = new StringBuilder();

    public static SimpleStringJoin newStrJoin() {
        return new SimpleStringJoin();
    }

    /**
     * 
     * 
     * @description <p>
     *              ?
     *              </p>
     * 
     * @Author Chris Yu
     * 
     * @createDate 2014-5-9 ?11:06:52
     * 
     * @return
     */
    public SimpleStringJoin startJoin() {
        simpleStrJoin.append(ANSWER_PREFIX);
        simpleStrJoin.append(DateFormatUtils.format(new Date(), DATE_FROMAT_STR));
        return this;
    }

    public SimpleStringJoin startJoin(String currentDate) {
        simpleStrJoin.append(ANSWER_PREFIX);
        simpleStrJoin.append(currentDate);
        return this;
    }

    /**
     * 
     * 
     * @description <p>
     *              
     *              </p>
     * 
     * @Author Chris Yu
     * 
     * @createDate 2014-5-9 ?11:08:59
     * 
     * @return
     */
    public SimpleStringJoin connectSymbol() {
        simpleStrJoin.append(JOIN_STR);
        return this;
    }

    /**
     * 
     * 
     * @description <p>
     *              ???
     *              egg
     *              CustomdataJoin("a").connectSymbol().CustomdataJoin("b")
     *              </p>
     * 
     * @Author Chris Yu
     * 
     * @createDate 2014-5-9 ?11:11:41
     * 
     * @return
     */
    public SimpleStringJoin customContext(String CustomStr) {
        simpleStrJoin.append(CustomStr);
        return this;
    }

    /**
     * 
     * 
     * @description <p>
     *              ?
     *              </p>
     * 
     * @Author Chris Yu
     * 
     * @createDate 2014-5-9 ?11:10:44
     * 
     * @return
     */
    public SimpleStringJoin endStrJoin() {
        simpleStrJoin.append(ANSWER_SUFFIX);
        return this;
    }

    public String build() {
        return simpleStrJoin.toString();
    }
}