javax.jcr.Node.getProperties()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中javax.jcr.Node.getProperties()方法的一些代码示例,展示了Node.getProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getProperties()方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:getProperties

Node.getProperties介绍

[英]Returns all properties of this node accessible through the current Session. Does not include child nodes of this node. The same reacquisition semantics apply as with #getNode(String). If this node has no accessible properties, then an empty iterator is returned.
[中]返回可通过当前Session访问的此节点的所有属性。不包括此节点的子节点。与#getNode(String)相同的重新获取语义也适用。如果此节点没有可访问的属性,则返回一个空迭代器。

代码示例

代码示例来源:origin: javax.jcr/jcr

  1. if (maxLevel == -1 || currentLevel < maxLevel) {
  2. currentLevel++;
  3. PropertyIterator propIter = node.getProperties();
  4. while (propIter.hasNext()) {
  5. propIter.nextProperty().accept(this);
  6. PropertyIterator propIter = node.getProperties();
  7. while (propIter.hasNext()) {
  8. nextQueue.addLast(propIter.nextProperty());

代码示例来源:origin: info.magnolia/magnolia-i18n

  1. private boolean hasI18NKeys(Node node, String[] properties) {
  2. try {
  3. return node.getProperties(properties).hasNext();
  4. } catch (RepositoryException re) {
  5. log.warn("Got exception by checking if '{}' has i18n properties", NodeUtil.getName(node), re);
  6. return false;
  7. }
  8. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Sets up the fixture for this test.
  3. */
  4. protected void setUp() throws Exception {
  5. isReadOnly = true;
  6. super.setUp();
  7. session = getHelper().getReadOnlySession();
  8. testRootNode = session.getRootNode().getNode(testPath);
  9. PropertyIterator properties = testRootNode.getProperties();
  10. try {
  11. property = properties.nextProperty();
  12. } catch (NoSuchElementException e) {
  13. fail("Any node must have at least one property set: jcr:primaryType");
  14. }
  15. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Override
  2. public Set<String> keySet() {
  3. Set<String> keys = new HashSet<String>();
  4. try {
  5. PropertyIterator props = content.getProperties();
  6. while (props.hasNext()) {
  7. keys.add(props.nextProperty().getName());
  8. }
  9. } catch (RepositoryException e) {
  10. // ignore - has no access
  11. }
  12. for (String name : specialProperties.keySet()) {
  13. keys.add(name);
  14. }
  15. return keys;
  16. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm

  1. /**
  2. * @see AbstractCollectionConverterImpl#doIsNull(Session, Node, CollectionDescriptor, Class)
  3. */
  4. protected boolean doIsNull(Session session, Node parentNode,
  5. CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
  6. throws RepositoryException {
  7. String jcrName = getCollectionJcrName(collectionDescriptor);
  8. return (parentNode == null || !parentNode.getProperties(jcrName).hasNext());
  9. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

  1. /**
  2. * Returns a sorted map of the properties of the given node.
  3. *
  4. * @param node JCR node
  5. * @return sorted map (keyed by name) of properties
  6. * @throws RepositoryException if a repository error occurs
  7. */
  8. private SortedMap getProperties(Node node) throws RepositoryException {
  9. SortedMap properties = new TreeMap();
  10. PropertyIterator iterator = node.getProperties();
  11. while (iterator.hasNext()) {
  12. Property property = iterator.nextProperty();
  13. properties.put(property.getName(), property);
  14. }
  15. return properties;
  16. }

代码示例来源:origin: org.apache/jackrabbit-ocm

  1. /**
  2. * @see AbstractCollectionConverterImpl#doIsNull(Session, Node, CollectionDescriptor, Class)
  3. */
  4. protected boolean doIsNull(Session session, Node parentNode,
  5. CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
  6. throws RepositoryException {
  7. String jcrName = getCollectionJcrName(collectionDescriptor);
  8. return (parentNode == null || !parentNode.getProperties(jcrName).hasNext());
  9. }

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

  1. /**
  2. * Returns a sorted map of the properties of the given node.
  3. *
  4. * @param node JCR node
  5. * @return sorted map (keyed by name) of properties
  6. * @throws RepositoryException if a repository error occurs
  7. */
  8. private SortedMap getProperties(Node node) throws RepositoryException {
  9. SortedMap properties = new TreeMap();
  10. PropertyIterator iterator = node.getProperties();
  11. while (iterator.hasNext()) {
  12. Property property = iterator.nextProperty();
  13. properties.put(property.getName(), property);
  14. }
  15. return properties;
  16. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. /**
  2. * Gets all properties from node and returns them as {@link java.util.List}.
  3. * Also filters out "extends" property.
  4. */
  5. private static List<Property> getPropertiesAsList(Node node, String namePattern) throws RepositoryException {
  6. List<Property> properties = new ArrayList<Property>();
  7. PropertyIterator it = node.getProperties(namePattern);
  8. while (it.hasNext()) {
  9. Property prop = (Property) it.next();
  10. if (!prop.getName().equals(EXTENDING_NODE_PROPERTY)) {
  11. properties.add(prop);
  12. }
  13. }
  14. return properties;
  15. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Returns a sorted map of the properties of the given node.
  3. *
  4. * @param node JCR node
  5. * @return sorted map (keyed by name) of properties
  6. * @throws RepositoryException if a repository error occurs
  7. */
  8. private SortedMap getProperties(Node node) throws RepositoryException {
  9. SortedMap properties = new TreeMap();
  10. PropertyIterator iterator = node.getProperties();
  11. while (iterator.hasNext()) {
  12. Property property = iterator.nextProperty();
  13. properties.put(property.getName(), property);
  14. }
  15. return properties;
  16. }

代码示例来源:origin: org.chtijbug.drools/guvnor-repository

  1. private List<String> listOfPermTypes(Node userNode) throws RepositoryException {
  2. List<String> permTypes = new ArrayList<String>();
  3. Node permsNode = getNode(userNode, "permissions", "nt:file");
  4. Node content = getNode(permsNode, "jcr:content", "nt:unstructured");
  5. PropertyIterator perms = content.getProperties();
  6. while (perms.hasNext()) {
  7. Property p = (Property) perms.next();
  8. String name = p.getName();
  9. if (!name.startsWith("jcr")) {
  10. permTypes.add(name);
  11. }
  12. }
  13. return permTypes;
  14. }

代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.resource

  1. /**
  2. * Read all properties.
  3. * @throws IllegalArgumentException if a repository exception occurs
  4. */
  5. void readFully() {
  6. if (!fullyRead) {
  7. try {
  8. final PropertyIterator pi = node.getProperties();
  9. while (pi.hasNext()) {
  10. final Property prop = pi.nextProperty();
  11. this.cacheProperty(prop);
  12. }
  13. fullyRead = true;
  14. } catch (final RepositoryException re) {
  15. throw new IllegalArgumentException(re);
  16. }
  17. }
  18. }

代码示例来源:origin: org.drools/guvnor-repository

  1. private List<String> listOfPermTypes(Node userNode) throws RepositoryException {
  2. List<String> permTypes = new ArrayList<String>();
  3. Node permsNode = getNode(userNode, "permissions", "nt:file");
  4. Node content = getNode(permsNode, "jcr:content", "nt:unstructured");
  5. PropertyIterator perms = content.getProperties();
  6. while (perms.hasNext()) {
  7. Property p = (Property) perms.next();
  8. String name = p.getName();
  9. if (!name.startsWith("jcr")) {
  10. permTypes.add(name);
  11. }
  12. }
  13. return permTypes;
  14. }

代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.resource

  1. /**
  2. * Read all properties.
  3. * @throws IllegalArgumentException if a repository exception occurs
  4. */
  5. void readFully() {
  6. if (!fullyRead) {
  7. try {
  8. final PropertyIterator pi = node.getProperties();
  9. while (pi.hasNext()) {
  10. final Property prop = pi.nextProperty();
  11. this.cacheProperty(prop);
  12. }
  13. fullyRead = true;
  14. } catch (final RepositoryException re) {
  15. throw new IllegalArgumentException(re);
  16. }
  17. }
  18. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. protected Collection<NodeData> getPrimitiveNodeDatas(String namePattern) throws RepositoryException {
  2. final Collection<NodeData> nodeDatas = new ArrayList<NodeData>();
  3. final PropertyIterator propertyIterator;
  4. if (namePattern == null) {
  5. propertyIterator = this.node.getProperties();
  6. } else {
  7. propertyIterator = this.node.getProperties(namePattern);
  8. }
  9. while (propertyIterator.hasNext()) {
  10. Property property = (Property) propertyIterator.next();
  11. try {
  12. if (!property.getName().startsWith("jcr:") && !property.getName().startsWith("mgnl:")) {
  13. nodeDatas.add(getNodeData(property.getName()));
  14. }
  15. } catch (PathNotFoundException e) {
  16. log.error("Exception caught", e);
  17. } catch (AccessDeniedException e) {
  18. // ignore, simply wont add content in a list
  19. }
  20. }
  21. return nodeDatas;
  22. }

代码示例来源:origin: org.overlord.sramp/s-ramp-repository-jcr

  1. /**
  2. * Gets all of the custom s-ramp property names currently stored on the given
  3. * JCR node.
  4. * @param jcrNode
  5. * @throws RepositoryException
  6. */
  7. private static Set<String> getNodePropertyNames(Node jcrNode) throws RepositoryException {
  8. String srampPropsPrefix = JCRConstants.SRAMP_PROPERTIES + ":"; //$NON-NLS-1$
  9. int srampPropsPrefixLen = srampPropsPrefix.length();
  10. Set<String> rval = new HashSet<String>();
  11. PropertyIterator properties = jcrNode.getProperties();
  12. while (properties.hasNext()) {
  13. Property prop = properties.nextProperty();
  14. String propName = prop.getName();
  15. if (propName.startsWith(srampPropsPrefix)) {
  16. propName = propName.substring(srampPropsPrefixLen);
  17. rval.add(propName);
  18. }
  19. }
  20. return rval;
  21. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Test if all returned items are of type node.
  3. */
  4. public void testGetProperties() throws RepositoryException {
  5. PropertyIterator properties = testRootNode.getProperties();
  6. while (properties.hasNext()) {
  7. Item item = (Item) properties.next();
  8. assertFalse("Item is not a property", item.isNode());
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. private static Map<String, String> getLocalizedStringMap( final Session session,
  2. final PentahoJcrConstants pentahoJcrConstants, final Node localizedStringNode ) throws RepositoryException {
  3. Assert.isTrue( isLocalizedString( session, pentahoJcrConstants, localizedStringNode ) );
  4. String prefix = session.getNamespacePrefix( PentahoJcrConstants.PHO_NS );
  5. Assert.hasText( prefix );
  6. Map<String, String> localizedStringMap = new HashMap<String, String>();
  7. PropertyIterator propertyIter = localizedStringNode.getProperties();
  8. // Loop through properties and append the appropriate values in the map
  9. while ( propertyIter.hasNext() ) {
  10. Property property = propertyIter.nextProperty();
  11. String propertyKey = property.getName().substring( prefix.length() + 1 );
  12. localizedStringMap.put( propertyKey, property.getString() );
  13. }
  14. return localizedStringMap;
  15. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Override
  2. public Void call() throws Exception {
  3. for (int k = 0; k < 100000; k++) {
  4. session.refresh(false);
  5. PropertyIterator properties = testRoot.getProperties();
  6. properties.hasNext();
  7. }
  8. return null;
  9. }
  10. }));

代码示例来源:origin: info.magnolia/magnolia-i18n

  1. private void handleNode(Node node, String[] properties) throws RepositoryException {
  2. PropertyIterator propertyIterator = node.getProperties(properties);
  3. while (propertyIterator.hasNext()) {
  4. Property property = propertyIterator.nextProperty();
  5. if (DEPRECATED_I18N_PROPERTIES.contains(property.getName())) {
  6. log.info("SiteMap i18n property removed: '{}' ", property.getPath());
  7. property.remove();
  8. }
  9. }
  10. }

相关文章