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


Java Value.getString方法代码示例

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


在下文中一共展示了Value.getString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: format

import javax.jcr.Value; //导入方法依赖的package包/类
@Nonnull
public static String format(@Nonnull Value value) throws RepositoryException {
    String s;
    switch (value.getType()) {
        case PropertyType.STRING:
        case PropertyType.BOOLEAN:
            return '\'' + QueryUtil.escapeForQuery(value.getString()) + '\'';

        case PropertyType.LONG:
        case PropertyType.DOUBLE:
            return value.getString();

        case PropertyType.DATE:
            return "xs:dateTime('" + value.getString() + "')";

        default:
            throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported");
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:QueryUtil.java

示例3: isPathInFormat

import javax.jcr.Value; //导入方法依赖的package包/类
private boolean isPathInFormat(Value value) {
    //TODO add more special characters to validate a path
    try {
        String path = value.getString();
        if (!"".equals(path)
                && (path.contains(":")
                || path.contains(",")
                || path.contains("%")
                || path.contains("^")
                || path.contains("*")
                || path.contains("(")
                || path.contains(")")
        )) {
            return false;
        }

    } catch (RepositoryException e) {
        return true;
    }
    return true;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:22,代码来源:RegistryNodeType.java

示例4: getFieldExternalDocuments

import javax.jcr.Value; //导入方法依赖的package包/类
@Override
public ExternalDocumentCollection<JSONObject> getFieldExternalDocuments(ExternalDocumentServiceContext context) {
    final String fieldName = context.getPluginConfig().getString(PARAM_EXTERNAL_DOCS_FIELD_NAME);

    if (StringUtils.isBlank(fieldName)) {
        throw new IllegalArgumentException("Invalid plugin configuration parameter for '" + PARAM_EXTERNAL_DOCS_FIELD_NAME + "': " + fieldName);
    }

    ExternalDocumentCollection<JSONObject> docCollection = new SimpleExternalDocumentCollection<JSONObject>();

    try {
        final Node contextNode = context.getContextModel().getNode();

        if (contextNode.hasProperty(fieldName)) {
            Value[] values = contextNode.getProperty(fieldName).getValues();

            // This is where it checks which values are selected.
            for (Value value : values) {
                String id = value.getString();
                JSONObject doc = findDocumentById(id);

                if (doc != null) {
                    docCollection.add(doc);
                }
            }
        }
    } catch (RepositoryException e) {
        log.error("Failed to retrieve related exdoc array field.", e);
    }

    return docCollection;
}
 
开发者ID:jenskooij,项目名称:hippo-external-document-picker-example-implementation,代码行数:33,代码来源:DocumentServiceFacade.java

示例5: collectDeepProps

import javax.jcr.Value; //导入方法依赖的package包/类
private Set<String> collectDeepProps(Value[] vals) throws RepositoryException {
    Set<String> deepProps = new HashSet<String>();
    if (vals != null) {
        for (Value val : vals) {
            String prop = val.getString();
            // Ignoring properties that start with '/' because that represents
            // an absolute path and this listener currently does not handle
            // that use case.
            if (!prop.startsWith("/") && prop.lastIndexOf("/") > 0) {
                deepProps.add(prop);
            }
        }
    }
    return deepProps;
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:16,代码来源:PropagatePropertyInheritanceCancelled.java

示例6: addOrRemoveProp

import javax.jcr.Value; //导入方法依赖的package包/类
private void addOrRemoveProp(Node pageContentNode, String cancelInheritancePropName, boolean addToCancel) throws RepositoryException {
    int propPos = cancelInheritancePropName.lastIndexOf("/");
    String childNodePath = cancelInheritancePropName.substring(0, propPos);
    String childPropName = cancelInheritancePropName.substring(propPos + 1);

    log.debug("{} property '{}' for {} on child node '{}'", (addToCancel ? "Adding" : "Removing"), childPropName, CANCELLED_INHERITANCE_PROPERTY, childNodePath);

    // Create the child node if it does not yet exist
    Node childNode = JcrUtil.createPath(pageContentNode, childNodePath, false, "nt:unstructured", "nt:unstructured", session, false);

    Value[] existingChildCancelInheritanceProp = getPropertyValues(childNode, CANCELLED_INHERITANCE_PROPERTY);

    List<String> updatedChildCancelInheritanceFields = new ArrayList<String>();
    for (Value existingCancelFieldValue : existingChildCancelInheritanceProp) {
        String existingCancelFieldString = existingCancelFieldValue.getString();
        if (!existingCancelFieldString.equals(childPropName)) {
            updatedChildCancelInheritanceFields.add(existingCancelFieldString);
        }
    }

    if (addToCancel) {
        updatedChildCancelInheritanceFields.add(childPropName);
    }

    if (updatedChildCancelInheritanceFields.size() != existingChildCancelInheritanceProp.length) {
        if (updatedChildCancelInheritanceFields.size() > 0) {
            childNode.setProperty(CANCELLED_INHERITANCE_PROPERTY, updatedChildCancelInheritanceFields.toArray(new String[updatedChildCancelInheritanceFields.size()]));
        } else {
            childNode.setProperty(CANCELLED_INHERITANCE_PROPERTY, (String[]) null);
        }
        session.save();
    }
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:34,代码来源:PropagatePropertyInheritanceCancelled.java

示例7: 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

示例8: getString

import javax.jcr.Value; //导入方法依赖的package包/类
private static String getString(Value value, int type) throws RepositoryException {
    if (value instanceof ValueImpl) {
        return ((ValueImpl) value).getOakString();
    }
    else if (type == PropertyType.NAME || type == PropertyType.PATH) {
        throw new IllegalArgumentException("Cannot create name of path property state from Value " +
                "of class '" + value.getClass() + '\'');
    } else {
        return value.getString();
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:12,代码来源:PropertyStates.java

示例9: apply

import javax.jcr.Value; //导入方法依赖的package包/类
@Override
public boolean apply(@Nullable Value value) {
    try {
        if (value == null || requiredValue == null) {
            return false;
        }

        if ("*".equals(requiredValue)) {
            return true;
        }

        String actual = value.getString();
        String required = requiredValue;
        if (required.endsWith("/*")) {
            required = required.substring(0, required.length() - 2);
            if (PathUtils.isAncestor(required, actual)) {
                return true;
            }
        }

        return required.equals(actual);
    }
    catch (RepositoryException e) {
        log.warn("Error checking path constraint " + this, e);
        return false;
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:28,代码来源:PathConstraint.java

示例10: 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

示例11: toString

import javax.jcr.Value; //导入方法依赖的package包/类
@Converter
public static String toString(Value value) throws RepositoryException {
    return value.getString();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:JcrConverter.java


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