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;
}
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;
}
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;
}
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;
}
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();
}
}
Aggregations