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


Java Property.getValues方法代码示例

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


在下文中一共展示了Property.getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMultiplePropertyAs

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Takes type, resource, and property name and returns the list of value of the object based on the given type
 *
 * @param type This is type parameter
 * @param resource The resource to fetch the value from
 * @param propertyName The property name to be used to fetch the value from the resource
 * @return valueList The list of values of the object based on the given type
 */
private static <T> List<T> getMultiplePropertyAs(Class<T> type, Resource resource, String propertyName) {
    List<T> val = Collections.EMPTY_LIST;
    try {
        if (null != resource) {
            Node node = resource.adaptTo(Node.class);
            if (null != node) {
                if (node.hasProperty(propertyName)) {
                    Property property = node.getProperty(propertyName);
                    if (property.isMultiple()) {
                        Value[] value = property.getValues();
                        val = PropertyUtils.as(type, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(ERROR, e);
    }
    return val;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:29,代码来源:ResourceUtils.java

示例2: getPropertyValues

import javax.jcr.Property; //导入方法依赖的package包/类
private Value[] getPropertyValues(Node node, String propertyName) throws RepositoryException {
    if (node.hasProperty(propertyName)) {
        Property prop = node.getProperty(propertyName);
        Value[] values;

        // This check is necessary to ensure a multi-valued field is applied...
        if (prop.isMultiple()) {
            values = prop.getValues();
        } else {
            values = new Value[1];
            values[0] = prop.getValue();
        }

        return values;
    }

    return new Value[0];
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:19,代码来源:PropagatePropertyInheritanceCancelled.java

示例3: getStoragePolicy

import javax.jcr.Property; //导入方法依赖的package包/类
private Response getStoragePolicy(final String nodeType) throws RepositoryException {
    LOGGER.debug("Get storage policy for: {}", nodeType);
    Response.ResponseBuilder response;
    final Node node =
            getJcrTools().findOrCreateNode(session, FEDORA_STORAGE_POLICY_PATH, "test");

    final Property prop = node.getProperty(nodeType);
    if (null == prop) {
        throw new PathNotFoundException("StoragePolicy not found: " + nodeType);
    }

    final Value[] values = prop.getValues();
    if (values != null && values.length > 0) {
        response = ok(values[0].getString());
    } else {
        throw new PathNotFoundException("StoragePolicy not found: " + nodeType);
    }

    return response.build();
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-storage-policy,代码行数:21,代码来源:FedoraStoragePolicy.java

示例4: getPropertyRepresentation

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Get a presentation of a JCR property.
 * @param property the property
 * @return a {@link org.onehippo.forge.webservices.jaxrs.jcr.model.JcrProperty}
 * @throws RepositoryException
 */
public static JcrProperty getPropertyRepresentation(Property property) throws RepositoryException {
    JcrProperty data = new JcrProperty();
    data.setName(property.getName());
    data.setType(PropertyType.nameFromValue(property.getType()));
    data.setMultiple(property.isMultiple());

    List<String> values = new ArrayList<String>();
    if (property.isMultiple()) {
        for (Value propertyValue : property.getValues()) {
            values.add(getPropertyValueAsString(propertyValue));
        }
    } else {
        values.add(getPropertyValueAsString(property.getValue()));
    }
    data.setValues(values);
    return data;
}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:24,代码来源:JcrDataBindingHelper.java

示例5: createInventory

import javax.jcr.Property; //导入方法依赖的package包/类
private void createInventory(Node webResourceGroup)
		throws RepositoryException, PathNotFoundException,
		ValueFormatException {
	if (webResourceGroup.hasNode(INVENTORY)) {
		Node inventoryNode = webResourceGroup.getNode(INVENTORY);
		PropertyIterator inventoryPropIt = inventoryNode.getProperties();
		while (inventoryPropIt.hasNext()) {
			Property currentInventoryProperty = inventoryPropIt
					.nextProperty();
			if (!currentInventoryProperty.getName().startsWith("jcr:")) {
				String inventoryType = currentInventoryProperty.getName();
				if (!inventory.containsKey(inventoryType)) {
					inventory.put(inventoryType, new ArrayList<String>());
				}
				List<String> inventoryTypeList = inventory
						.get(inventoryType);
				Value[] inventoryTypeValues = currentInventoryProperty
						.getValues();
				for (Value currentValue : inventoryTypeValues) {
					inventoryTypeList.add(currentValue.getString());
				}
			}
		}
	}
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:26,代码来源:WebResourceGroup.java

示例6: getNodePropertySize

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Get the total size of a Node's properties
 * 
 * @param node the node
 * @return size in bytes
 * @throws RepositoryException if repository exception occurred
 */
public static Long getNodePropertySize(final Node node)
    throws RepositoryException {
    Long size = 0L;
    for (final PropertyIterator i = node.getProperties(); i.hasNext();) {
        final Property p = i.nextProperty();
        if (p.isMultiple()) {
            for (final Value v : p.getValues()) {
                size += v.getBinary().getSize();
            }
        } else {
            size += p.getBinary().getSize();
        }
    }
    return size;
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:23,代码来源:ServiceHelpers.java

示例7: getPropertyValues

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Internal method to get all values for a multi-value property.
 *
 * @param resource The resource from which to get the property.
 * @param namePattern Property name.
 * @return Property values.
 */
private static Value[] getPropertyValues(Resource resource, String namePattern) throws RepositoryException {
    Property prop = getProperty(resource, namePattern);
    if (prop != null) {
        if (prop.isMultiple()) {
            return prop.getValues();
        } else {
            return (new Value[]{prop.getValue()});
        }
    }
    return new Value[0];
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:19,代码来源:ResourceUtil.java

示例8: printNode

import javax.jcr.Property; //导入方法依赖的package包/类
static void printNode(Node node, String indentation) throws Exception {
    System.out.println();
    System.out.println(indentation + "------- NODE -------");
    System.out.println(indentation + "Path: " + node.getPath());

    System.out.println(indentation + "------- Properties: ");
    PropertyIterator propertyIterator = node.getProperties();
    while (propertyIterator.hasNext()) {
        Property p = propertyIterator.nextProperty();
        if (!p.getName().equals("jcr:data") && !p.getName().equals("jcr:mixinTypes") && !p.getName().equals("fileBytes")) {
            System.out.print(indentation + p.getName() + ": ");
            if (p.getDefinition().getRequiredType() == PropertyType.BINARY) {
                System.out.print("binary, (length:" + p.getLength() + ") ");
            } else if (!p.getDefinition().isMultiple()) {
                System.out.print(p.getString());
            } else {
                for (Value v : p.getValues()) {
                    System.out.print(v.getString() + ", ");
                }
            }
            System.out.println();
        }

        if (p.getName().equals("jcr:childVersionHistory")) {
            System.out.println(indentation + "------- CHILD VERSION HISTORY -------");
            printNode(node.getSession().getNodeByIdentifier(p.getString()), indentation + "\t");
            System.out.println(indentation + "------- CHILD VERSION ENDS -------");
        }
    }

    NodeIterator nodeIterator = node.getNodes();
    while (nodeIterator.hasNext()) {
        printNode(nodeIterator.nextNode(), indentation + "\t");
    }
}
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:36,代码来源:TestMapping.java

示例9: dumpNode

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Recursive method for dumping a node. This method is separate to avoid the overhead of searching and
 * opening/closing JCR sessions.
 * @param node
 * @return
 * @throws RepositoryException
 */
protected String dumpNode(Node node) throws RepositoryException {
    StringBuffer buffer = new StringBuffer();
    buffer.append(node.getPath());

    PropertyIterator properties = node.getProperties();
    while (properties.hasNext()) {
        Property property = properties.nextProperty();
        buffer.append(property.getPath()).append("=");
        if (property.getDefinition().isMultiple()) {
            Value[] values = property.getValues();
            for (int i = 0; i < values.length; i++) {
                if (i > 0) {
                    buffer.append(",");
                }
                buffer.append(values[i].getString());
            }
        } else {
            buffer.append(property.getString());
        }
        buffer.append("\n");
    }

    NodeIterator nodes = node.getNodes();
    while (nodes.hasNext()) {
        Node child = nodes.nextNode();
        buffer.append(dumpNode(child));
    }
    return buffer.toString();

}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:38,代码来源:JcrTemplate.java

示例10: propertyToJavaObject

import javax.jcr.Property; //导入方法依赖的package包/类
@SuppressWarnings("squid:S3776")
private static Object propertyToJavaObject(Property property)
        throws RepositoryException {
    // multi-value property: return an array of values
    if (property.isMultiple()) {
        Value[] values = property.getValues();
        final Object firstValue = values.length > 0 ? valueToJavaObject(values[0]) : null;
        final Object[] result;
        if ( firstValue instanceof Boolean ) {
            result = new Boolean[values.length];
        } else if ( firstValue instanceof Calendar ) {
            result = new Calendar[values.length];
        } else if ( firstValue instanceof Double ) {
            result = new Double[values.length];
        } else if ( firstValue instanceof Long ) {
            result = new Long[values.length];
        } else if ( firstValue instanceof BigDecimal) {
            result = new BigDecimal[values.length];
        } else if ( firstValue instanceof InputStream) {
            result = new Object[values.length];
        } else {
            result = new String[values.length];
        }
        for (int i = 0; i < values.length; i++) {
            Value value = values[i];
            if (value != null) {
                result[i] = valueToJavaObject(value);
            }
        }
        return result;
    }

    // single value property
    return valueToJavaObject(property.getValue());
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:36,代码来源:EvolutionConfig.java

示例11: explore

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Utility method to display the contents of a node and its descendants
 * @param node
 * @throws RepositoryException 
 * @throws Exception
 */
public static void explore(Node node) throws RepositoryException  {
	log.info(node.getPath());
       // Skip the jcr:system subtree
       if (node.getName().equals("jcr:system")) {
           return;
       }
       // Output the properties
       PropertyIterator properties = node.getProperties();
       while (properties.hasNext()) {
           Property property = properties.nextProperty();
           if (property.getDefinition().isMultiple()) {
               // A multi-valued property, print all values
               Value[] values = property.getValues();
               for (int i = 0; i < values.length; i++) {
               	log.info(property.getPath() + " = " + values[i].getString());
               }
           } else {
               // A single-valued property
           	log.info(property.getPath() + " = " + property.getString());
           }
       }
       // Output all the child nodes recursively
       NodeIterator nodes = node.getNodes();
       while (nodes.hasNext()) {
           explore(nodes.nextNode());
       }	
}
 
开发者ID:sltang,项目名称:jackrabbit-migration,代码行数:34,代码来源:NodeUtils.java

示例12: getPropertySize

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Get size of value(s) as String of a property
 * @param property
 * @return length
 * @throws ValueFormatException
 * @throws RepositoryException
 */
public static long getPropertySize(Property property) throws ValueFormatException, RepositoryException {
	long size=0;
	if (property.getDefinition().isMultiple()) {
           Value[] values = property.getValues();
           for (int i=0; i < values.length; i++) {
           	size+=values[i].getString().getBytes().length;
           }
       } else {
       	size+=property.getValue().getString().getBytes().length;
       }
	return size;		
}
 
开发者ID:sltang,项目名称:jackrabbit-migration,代码行数:20,代码来源:NodeUtils.java

示例13: toJavaObject

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Converts the value(s) of a JCR Property to a corresponding Java Object.
 * If the property has multiple values the result is an array of Java
 * Objects representing the converted values of the property.
 */
public static Object toJavaObject(Property property)
        throws RepositoryException {
    // multi-value property: return an array of values
    if (property.isMultiple()) {
        Value[] values = property.getValues();
        final Object firstValue = values.length > 0 ? toJavaObject(values[0]) : null;
        final Object[] result;
        if ( firstValue instanceof Boolean ) {
            result = new Boolean[values.length];
        } else if ( firstValue instanceof Calendar ) {
            result = new Calendar[values.length];
        } else if ( firstValue instanceof Double ) {
            result = new Double[values.length];
        } else if ( firstValue instanceof Long ) {
            result = new Long[values.length];
        } else if ( firstValue instanceof BigDecimal) {
            result = new BigDecimal[values.length];
        } else if ( firstValue instanceof InputStream) {
            result = new Object[values.length];
        } else {
            result = new String[values.length];
        }
        for (int i = 0; i < values.length; i++) {
            Value value = values[i];
            if (value != null) {
                result[i] = toJavaObject(value);
            }
        }
        return result;
    }

    // single value property
    return toJavaObject(property.getValue());
}
 
开发者ID:hlta,项目名称:playweb,代码行数:40,代码来源:JcrUtil.java

示例14: getProperty

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * @see #hasProperty(String)
 * @see Entity#getProperty(String)
 */
public Value[] getProperty(String relPath) throws RepositoryException {
    if (node.hasProperty(relPath)) {
        Property prop = node.getProperty(relPath);
        if (isEntityProperty(prop, true)) {
            if (prop.isMultiple()) {
                return prop.getValues();
            } else {
                return new Value[]{prop.getValue()};
            }
        }
    }
    return null;
}
 
开发者ID:hlta,项目名称:playweb,代码行数:18,代码来源:EntityImpl.java

示例15: retrievePlanList

import javax.jcr.Property; //导入方法依赖的package包/类
/**
 * Retrieve a {@link PlanList} from Fedora
 * @param limit the maximum number of entries in the list
 * @param offset the offset of the list
 * @return a {@link Response} which maps to a corresponding HTTP response, containing a {@link PlanList}'s XML representation
 * @throws RepositoryException
 */
@GET
@Path("{limit}/{offset}")
public Response retrievePlanList(@PathParam("limit")
final long limit, @PathParam("offset")
final long offset) throws RepositoryException {
    final List<PlanData> plans = new ArrayList<>();
    NodeIterator nodes = this.retrievePlanNodes(limit, offset);
    while (nodes.hasNext()) {
        Node plan = (Node) nodes.next();
        PropertyIterator props = plan.getProperties("scape:*");
        PlanData.Builder data = new PlanData.Builder();
        data.identifier(new Identifier(plan.getPath().substring(plan.getPath().lastIndexOf('/') + 1)));
        while (props.hasNext()) {
            Property prop = (Property) props.next();
            for (Value val : prop.getValues()) {
                if (prop.getName().equals("scape:hasTitle")) {
                    data.title(val.getString());
                }
                if (prop.getName().equals("scape:hasDescription")) {
                    data.description(val.getString());
                }
                if (prop.getName().equals("scape:hasLifecycleState")) {
                    String state = val.getString();
                    int pos;
                    if ((pos = state.indexOf(':')) != -1) {
                        data.lifecycleState(new PlanLifecycleState(PlanState.valueOf(state.substring(0, pos)), state.substring(pos + 1)));
                    } else {
                        data.lifecycleState(new PlanLifecycleState(PlanState.valueOf(state), ""));
                    }
                }
            }
        }
        plans.add(data.build());
    }
    return Response.ok(new StreamingOutput() {

        @Override
        public void write(OutputStream sink) throws IOException, WebApplicationException {
            try {
                marshaller.serialize(new PlanDataCollection(plans), sink);
            } catch (JAXBException e) {
                throw new IOException(e);
            }
        }
    }).build();
}
 
开发者ID:openpreserve,项目名称:scape-fcrepo4-planmanagement,代码行数:54,代码来源:PlanList.java


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