本文整理汇总了Java中org.postgresql.util.PGobject.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java PGobject.getValue方法的具体用法?Java PGobject.getValue怎么用?Java PGobject.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.util.PGobject
的用法示例。
在下文中一共展示了PGobject.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseValueObj
import org.postgresql.util.PGobject; //导入方法依赖的package包/类
/**
* 解析json值
*
* @param field
* @param pGobject
* @return
*/
private Object parseValueObj(Field field, PGobject pGobject) {
String value = pGobject.getValue();
if (value == null) {
return null;
}
Object obj;
if (field.getType().equals(List.class)) { // List类型
Class<?>[] genericTypes = GenericTypeUtils.getGenericType(field.getGenericType());
obj = JSON.parseArray(value, genericTypes[0]);
} else if (field.getType().equals(Map.class)) { // Map类型
obj = JSON.parseObject(value, field.getGenericType());
} else {
obj = JSON.parseObject(value, field.getType());
}
return obj;
}
示例2: doNullSafeGet
import org.postgresql.util.PGobject; //导入方法依赖的package包/类
@Override
public Map<String, String> doNullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
Object identifier = rs.getObject(names[0]);
if (rs.wasNull()) {
return null;
}
final String jsonText;
if (identifier instanceof PGobject) {
PGobject pg = (PGobject) identifier;
jsonText = pg.getValue();
} else if (identifier instanceof String) { // some PostgreSQL Dialects /
// Versions return String
// not PGObject
jsonText = (String) identifier;
} else {
throw new IllegalArgumentException("PersistentJsonObjectAsPostgreSQLJson type expected PGobject, received "
+ identifier.getClass().getName() + " with value of '" + identifier + "'");
}
return toMap(jsonText);
}
示例3: cubeToFloat
import org.postgresql.util.PGobject; //导入方法依赖的package包/类
private static float[] cubeToFloat(PGobject object) {
String cubeString = object.getValue();
String[] cubeArray = cubeString.substring(1, cubeString.length() - 1).split(", ");
float[] target = new float[cubeArray.length];
for (int i = 0; i < cubeArray.length; i++) {
target[i] = Float.valueOf(cubeArray[i]);
}
return target;
}
示例4: nullSafeGet
import org.postgresql.util.PGobject; //导入方法依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
Object value = rs.getString(names[0]);
if (value == null || rs.wasNull()) {
return null;
}
PGobject pgObject = (PGobject) value;
return pgObject.getValue();
}
示例5: pgObjectValue
import org.postgresql.util.PGobject; //导入方法依赖的package包/类
public static String pgObjectValue(PGobject o, String type) {
if (o == null) {
return null;
}
if (type != null && !o.getType().equals(type)) {
throw new IllegalStateException("expected type " + type + ", found " + o.getType());
}
return o.getValue();
}