本文整理汇总了Java中javax.jcr.Value.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Value.getDouble方法的具体用法?Java Value.getDouble怎么用?Java Value.getDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Value
的用法示例。
在下文中一共展示了Value.getDouble方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: as
import javax.jcr.Value; //导入方法依赖的package包/类
/**
* Takes a generic type and a Value and turns the Value into the Object of that given type.
*
* @param type This is a type parameter
* @param value This is the value
* @return castedValue This is the value of the given type
* @throws Exception
*/
public static <T> T as(Class<T> type, Value value)
throws Exception {
if (type == Long.class)
return (T) new Long(value.getLong());
if (type == Double.class)
return (T) new Double(value.getDouble());
if (type == Boolean.class)
return (T) new Boolean(value.getBoolean());
if (type == String.class)
return (T) value.getString();
if (type == Date.class)
return (T) value.getString();
if (type == Calendar.class)
return (T) value.getDate();
return null;
}
示例2: getValue
import javax.jcr.Value; //导入方法依赖的package包/类
/**
* Returns a representation of the given {@link Value} by using the given {@link Class}.
*
* @param c {@link Class} used to return the representation with correct type
* @param value {@link Value} object
* @return a representation of {@link Value}.
* @throws RepositoryException
* @throws IOException
*/
public static Object getValue(Class<?> c, Value value) throws RepositoryException, IOException {
if (c == String.class || StringProperty.class.isAssignableFrom(c)) {
return value.getString();
} else if (c == Date.class) {
return value.getDate().getTime();
} else if (c == Timestamp.class) {
return new Timestamp(value.getDate().getTimeInMillis());
} else if (c == Calendar.class) {
return value.getDate();
} else if (c == InputStream.class) {
//return value.getStream();
return value.getBinary().getStream();
} else if (c.isArray() && c.getComponentType() == byte.class) {
// byte array...we need to read from the stream
//return Mapper.readBytes(value.getStream());
return IOUtils.toByteArray(value.getBinary().getStream());
} else if (c == Integer.class || c == int.class || IntegerProperty.class.isAssignableFrom(c)) {
return (int) value.getDouble();
} else if (c == Long.class || c == long.class || LongProperty.class.isAssignableFrom(c)) {
return value.getLong();
} else if (c == Double.class || c == double.class || DoubleProperty.class.isAssignableFrom(c)) {
return value.getDouble();
} else if (c == Boolean.class || c == boolean.class || BooleanProperty.class.isAssignableFrom(c)) {
return value.getBoolean();
} else if (c == Locale.class) {
return parseLocale(value.getString());
} else if (c.isEnum()) {
return Enum.valueOf((Class<? extends Enum>) c, value.getString());
}
return null;
}
示例3: getValue
import javax.jcr.Value; //导入方法依赖的package包/类
/**
* Returns a representation of the given {@link Value} by using the given {@link Class}.
*
* @param c {@link Class} used to return the representation with correct type
* @param value {@link Value} object
* @return a representation of {@link Value}.
* @throws RepositoryException
* @throws IOException
*/
public static Object getValue(Class<?> c, Value value) throws RepositoryException, IOException {
if (c == String.class) {
return value.getString();
} else if (c == Date.class) {
return value.getDate().getTime();
} else if (c == Timestamp.class) {
return new Timestamp(value.getDate().getTimeInMillis());
} else if (c == Calendar.class) {
return value.getDate();
} else if (c == InputStream.class) {
//return value.getStream();
return value.getBinary().getStream();
} else if (c.isArray() && c.getComponentType() == byte.class) {
// byte array...we need to read from the stream
//return Mapper.readBytes(value.getStream());
return IOUtils.toByteArray(value.getBinary().getStream());
} else if (c == Integer.class || c == int.class) {
return (int) value.getDouble();
} else if (c == Long.class || c == long.class) {
return value.getLong();
} else if (c == Double.class || c == double.class) {
return value.getDouble();
} else if (c == Boolean.class || c == boolean.class) {
return value.getBoolean();
} else if (c == Locale.class) {
return parseLocale(value.getString());
} else if (c.isEnum()) {
return Enum.valueOf((Class<? extends Enum>) c, value.getString());
}
return null;
}
示例4: getValue
import javax.jcr.Value; //导入方法依赖的package包/类
@Override
protected Double getValue(Value value) throws RepositoryException {
return value.getDouble();
}