当前位置: 首页>>代码示例>>Java>>正文


Java Value.getLong方法代码示例

本文整理汇总了Java中javax.jcr.Value.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java Value.getLong方法的具体用法?Java Value.getLong怎么用?Java Value.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Value的用法示例。


在下文中一共展示了Value.getLong方法的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;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:26,代码来源:PropertyUtils.java

示例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;
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:41,代码来源:JcrUtils.java

示例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;
}
 
开发者ID:sbrinkmann,项目名称:jcrom-extended,代码行数:41,代码来源:JcrUtils.java

示例4: getValue

import javax.jcr.Value; //导入方法依赖的package包/类
@Override
protected Long getValue(Value value) throws RepositoryException {
    return value.getLong();
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:5,代码来源:LongConstraint.java


注:本文中的javax.jcr.Value.getLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。