Search in sources :

Example 11 with CsvArrayList

use of jp.ossc.nimbus.util.CsvArrayList in project nimbus by nimbus-org.

the class StringSequenceService method startService.

/**
 * サービスの開始処理を行う。<p>
 *
 * @exception Exception サービスの開始処理に失敗した場合
 */
public void startService() throws Exception {
    mInitialFlag = true;
    mInitialNumber = "";
    // formatを桁区切りで分解する
    CsvArrayList parser = new CsvArrayList();
    parser.split(mFormat, C_SEMICORON);
    CsvArrayList persist = null;
    if (persistFile != null) {
        final File file = new File(persistFile);
        if (file.exists()) {
            final FileReader fr = new FileReader(file);
            final BufferedReader br = new BufferedReader(fr);
            try {
                persist = new CsvArrayList();
                persist.split(br.readLine(), C_SEMICORON);
                if (parser.size() != persist.size()) {
                    persist = null;
                }
            } finally {
                fr.close();
            }
        } else if (file.getParentFile() != null && !file.getParentFile().exists()) {
            file.mkdirs();
        }
    }
    // 各桁情報をインスタンシングしてリストに格納する
    for (int i = 0, max = parser.size(); i < max; i++) {
        String formatItem = (String) parser.get(i);
        String persistItem = null;
        if (persist != null) {
            persistItem = (String) persist.get(i);
        }
        SequenceVariable item = null;
        if (formatItem.startsWith(TimeSequenceVariable.FORMAT_KEY)) {
            item = new TimeSequenceVariable(formatItem);
        } else if (formatItem.indexOf(SimpleSequenceVariable.DELIMITER) != -1) {
            item = new SimpleSequenceVariable(formatItem, persistItem);
        } else if (formatItem.length() > 2 && formatItem.charAt(0) == ContextSequenceVariable.DELIMITER && formatItem.charAt(formatItem.length() - 1) == ContextSequenceVariable.DELIMITER) {
            item = new ContextSequenceVariable(formatItem, contextServiceName);
        } else {
            item = new ConstSequenceVariable(formatItem);
        }
        this.mSequenceNo.add(item);
    }
}
Also used : CsvArrayList(jp.ossc.nimbus.util.CsvArrayList)

Example 12 with CsvArrayList

use of jp.ossc.nimbus.util.CsvArrayList in project nimbus by nimbus-org.

the class CsvArrayListTest method testSetAddDelimitaFlg.

public void testSetAddDelimitaFlg() throws Exception {
    CsvArrayList ary = new CsvArrayList();
    ary.setAddDelimitaFlg(true);
    ary.add("nakano");
    ary.add("hirotaka");
    String ret = ary.join(";");
    if (!ret.endsWith(";")) {
        throw new Exception();
    }
    ary.clear();
    ary.split("nakano,hirotaka,baka,");
    if (ary.size() != 3) {
        throw new Exception();
    }
    ary.setAddDelimitaFlg(false);
    ary.clear();
    ary.add("nakano");
    ary.add("hirotaka");
    ret = ary.join(";");
    if (ret.endsWith(";")) {
        throw new Exception();
    }
    ary.clear();
    ary.split("nakano,hirotaka,baka,");
    assertEquals(ary.size(), 4);
}
Also used : CsvArrayList(jp.ossc.nimbus.util.CsvArrayList)

Example 13 with CsvArrayList

use of jp.ossc.nimbus.util.CsvArrayList in project nimbus by nimbus-org.

the class CsvArrayListTest method testSplitCL.

public void testSplitCL() throws Exception {
    CsvArrayList ary = new CsvArrayList();
    ary.splitCL("nakano\r\nhirotaka");
    assertEquals(ary.size(), 2);
    ary.clear();
    ary.splitCL("nakano\nhirotaka");
    assertEquals(ary.size(), 2);
    ary.clear();
    ary.splitCL("nakano\rhirotaka");
    assertEquals(ary.size(), 2);
    ary.clear();
    ary.splitCL("nakano hirotaka");
    assertEquals(ary.size(), 1);
}
Also used : CsvArrayList(jp.ossc.nimbus.util.CsvArrayList)

Example 14 with CsvArrayList

use of jp.ossc.nimbus.util.CsvArrayList in project nimbus by nimbus-org.

the class CsvArrayListTest method testJoin.

/*
	 * String join のテスト()
	 */
public void testJoin() throws Exception {
    CsvArrayList ary = new CsvArrayList();
    ary.add("nakano");
    ary.add("hirotaka");
    String tmp = ary.join();
    if (!tmp.equals("nakano,hirotaka")) {
        throw new Exception();
    }
    tmp = ary.join("@");
    if (!tmp.equals("nakano@hirotaka")) {
        throw new Exception();
    }
    ary.clear();
    ary.setEscapeString("@");
    ary.add("naka@no,");
    ary.add("hirotaka,");
    tmp = ary.join(",");
    if (!tmp.equals("naka@@no@,,hirotaka@,")) {
        throw new Exception();
    }
}
Also used : CsvArrayList(jp.ossc.nimbus.util.CsvArrayList)

Aggregations

CsvArrayList (jp.ossc.nimbus.util.CsvArrayList)14 ListIterator (java.util.ListIterator)4 ArrayList (java.util.ArrayList)3 Enumeration (java.util.Enumeration)2 Hashtable (java.util.Hashtable)2 Iterator (java.util.Iterator)1 ServiceException (jp.ossc.nimbus.lang.ServiceException)1