require 'hpricot'
require 'hpricot/xchar'
Hpricot::XChar::PREDEFINED_U.merge!({" " => 32})←①
or
Hpricot::XChar::PREDEFINED_U.update({" " => 32})←②
doc = Hpricot('before after
')
puts doc.inner_text
①または②を記載する。
「 」へのエンコード対応表がないので原因。投稿を公開
Hpricot::XChar::PREDEFINED_U.merge!({" " => 32})←①
or
Hpricot::XChar::PREDEFINED_U.update({" " => 32})←②
doc = Hpricot('before after
')
puts doc.inner_text
①または②を記載する。
「 」へのエンコード対応表がないので原因。投稿を公開
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Iterator;
import org.apache.cayenne.CayenneException;
import org.apache.cayenne.access.Transaction;
public class NoTransaction extends Transaction {
@Override
public void begin() {
}
@Override
public void commit() throws IllegalStateException, SQLException, CayenneException {
close();
}
@Override
public void rollback() throws IllegalStateException, SQLException, CayenneException {
close();
}
protected void close() {
if (connections == null || connections.isEmpty()) {
return;
}
Iterator it = connections.values().iterator();
while (it.hasNext()) {
try {
((Connection) it.next()).close();
}
catch (Throwable th) {
}
}
}
}
Transaction tx = new NoTransaction();
try {
Transaction.bindThreadTransaction(tx);
Expression expression = ExpressionFactory.matchExp(~);
SelectQuery query = new SelectQuery(Ent.class, expression);
ListentList = getDataContext().performQuery(query);
if (CollectionUtils.isEmpty(entList))
return null;
return entList;
}
finally {
try {
tx.commit();
} catch (Exception e) {
}
}
if (Prototype.Browser.IE6)
alert('You are using IE6');
else if (Prototype.Browser.IE)
alert('You are using IE7');
else
alert('Not IE');
// -- 以下コード
import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
import java.util.List;
import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
public class ArrayTypeHandlerCallback implements TypeHandlerCallback {
public Object getResult(ResultGetter resultGetter) throws SQLException {
Array array = resultGetter.getArray();
if (array == null)
return null;
else
return Arrays.asList((Object[])array.getArray());
}
public void setParameter(ParameterSetter parameterSetter, Object obj)
throws SQLException {
if(obj == null){
parameterSetter.setNull(Types.ARRAY);
} else {
List lst = (List)obj;
parameterSetter.setArray(createArray(parameterSetter, lst));
}
}
public Object valueOf(String str) {
// 特につかっていないので今回は実装しない
return "";
}
public Array createArray(ParameterSetter parameterSetter, List list) throws SQLException {
Array array = null;
PreparedStatement ps = null;
try {
String arrayPhrase = toArrayPhrase(list);
if (arrayPhrase == null)
return null;
ps = parameterSetter.getPreparedStatement();
Connection cn = ps.getConnection();
String sql = "SELECT " + arrayPhrase;
ps = cn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
rs.next();
array = rs.getArray(1);
}
finally {
// 初回のPreparedStatementはIbatisによって制御されるのでcloseはしない
if (ps != null)
ps.close();
}
return array;
}
public String toArrayPhrase(List