Search in sources :

Example 81 with CharArrayReader

use of java.io.CharArrayReader in project tetrad by cmu-phil.

the class DataReader method parseTabular.

/**
 * Parses the given character array for a tabular data set, returning a
 * RectangularDataSet if successful. Log messages are written to the
 * LogUtils log; to view them, add System.out to that.
 */
@Override
public DataSet parseTabular(char[] chars) {
    // Do first pass to get a description of the file.
    CharArrayReader reader = new CharArrayReader(chars);
    DataSetDescription description = doFirstTabularPass(reader);
    // Close the reader and re-open for a second pass to load the data.
    reader.close();
    CharArrayReader reader2 = new CharArrayReader(chars);
    DataSet dataSet = doSecondTabularPass(description, reader2);
    this.logger.log("info", "\nData set loaded!");
    this.logger.reset();
    return dataSet;
}
Also used : CharArrayReader(java.io.CharArrayReader)

Example 82 with CharArrayReader

use of java.io.CharArrayReader in project tetrad by cmu-phil.

the class DataReader method parseKnowledge.

/**
 * Parses knowledge from the char array, assuming that's all there is in the
 * char array.
 */
@Override
public IKnowledge parseKnowledge(char[] chars) {
    CharArrayReader reader = new CharArrayReader(chars);
    Lineizer lineizer = new Lineizer(reader, commentMarker);
    IKnowledge knowledge = parseKnowledge(lineizer, delimiterType.getPattern());
    this.logger.reset();
    return knowledge;
}
Also used : CharArrayReader(java.io.CharArrayReader)

Example 83 with CharArrayReader

use of java.io.CharArrayReader in project new-cloud by xie-summer.

the class XmlUtils method getDocument.

public static Document getDocument(String xml) {
    SAXReader reader = new SAXReader();
    Document document = null;
    try {
        document = reader.read(new CharArrayReader(xml.toCharArray()));
    } catch (DocumentException e) {
        DB_LOGGER.error(LoggerUtils.getExceptionTrace(e, 100));
    }
    // 读取XML文件
    return document;
}
Also used : CharArrayReader(java.io.CharArrayReader) SAXReader(org.dom4j.io.SAXReader)

Example 84 with CharArrayReader

use of java.io.CharArrayReader in project new-cloud by xie-summer.

the class NSXmlUtils method getDocument.

/**
 * Map<String, String> nameSpaceMap = new HashMap<String, String>();
 * example: nameSpaceMap.put("gm", "http://earth.google.com/kml/2.0");
 * Xpath like: /gm:root/gm:sub
 * @param xml
 * @param
 * @return
 */
public Document getDocument(String xml) {
    SAXReader reader = new SAXReader(factory);
    Document document = null;
    try {
        document = reader.read(new CharArrayReader(xml.toCharArray()));
    } catch (DocumentException e) {
        DB_LOGGER.error(LoggerUtils.getExceptionTrace(e, 100));
    }
    // 读取XML文件
    return document;
}
Also used : CharArrayReader(java.io.CharArrayReader) SAXReader(org.dom4j.io.SAXReader) DocumentException(org.dom4j.DocumentException) Document(org.dom4j.Document)

Example 85 with CharArrayReader

use of java.io.CharArrayReader in project nimbus by nimbus-org.

the class TransactionLoggingConnection method writeLog.

protected void writeLog(String sql, int queryType, PrepareValue[] params) throws SQLException {
    if (!isUpdateQuery(sql)) {
        return;
    }
    initTransactionStatement();
    Sequence sequence = this.sequence;
    if (sequence == null && sequenceServiceName != null) {
        try {
            sequence = (Sequence) ServiceManagerFactory.getServiceObject(sequenceServiceName);
        } catch (ServiceNotFoundException e) {
        }
    }
    if (sequence == null) {
        throw new SQLException("Sequence is null.");
    }
    final String seq = sequence.increment();
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            if (params[i] == null) {
                continue;
            }
            transactionParamInsertStatement.setString(1, seq);
            transactionParamInsertStatement.setInt(2, i + 1);
            setParam(params[i]);
            if (isBatch) {
                transactionParamInsertStatement.addBatch();
            } else {
                transactionParamInsertStatement.executeUpdate();
            }
        }
        if (isBatch && getAutoCommit()) {
            transactionParamInsertStatement.executeBatch();
        }
    }
    transactionInsertStatement.setString(1, seq);
    transactionInsertStatement.setCharacterStream(2, new CharArrayReader(sql.toCharArray()), sql.length());
    transactionInsertStatement.setInt(3, queryType);
    transactionInsertStatement.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
    transactionInsertStatement.setString(5, updateUser);
    if (!isBatch || getAutoCommit()) {
        transactionInsertStatement.executeUpdate();
    } else {
        transactionInsertStatement.addBatch();
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) SQLException(java.sql.SQLException) ServiceNotFoundException(jp.ossc.nimbus.core.ServiceNotFoundException) Sequence(jp.ossc.nimbus.service.sequence.Sequence) Timestamp(java.sql.Timestamp)

Aggregations

CharArrayReader (java.io.CharArrayReader)102 IOException (java.io.IOException)45 BufferedReader (java.io.BufferedReader)22 Reader (java.io.Reader)19 File (java.io.File)11 InputStreamReader (java.io.InputStreamReader)10 Test (org.junit.Test)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 StringReader (java.io.StringReader)8 FileReader (java.io.FileReader)7 PreparedStatement (java.sql.PreparedStatement)7 BufferedWriter (java.io.BufferedWriter)5 CharArrayWriter (java.io.CharArrayWriter)5 FileWriter (java.io.FileWriter)5 InputStream (java.io.InputStream)5 ResultSet (java.sql.ResultSet)5 InputSource (org.xml.sax.InputSource)5 PipedReader (java.io.PipedReader)4 CharBuffer (java.nio.CharBuffer)4 Signature (java.security.Signature)4