javax.jcr.Property.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(99)

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

Property.getProperty介绍

[英]If this property is of type PATH (or convertible to this type) this method returns the Property to which this property refers.

If this property contains a relative path, it is interpreted relative to the parent node of this property. Therefore, when resolving such a relative path, the segment "." refers to the parent node itself, ".." to the parent of the parent node and "foo" to a sibling property of this property or this property itself.

For example, if this property is located at /a/b/c and it has a value of "../d" then this method will return the property at /a/d if such exists.

If this property is multi-valued, this method throws a ValueFormatException.

If this property cannot be converted to a PATH then a ValueFormatException is thrown.

If this property is currently part of the frozen state of a version in version storage, this method will throw a ValueFormatException.
[中]如果此属性的类型为PATH(或可转换为此类型),则此方法将返回此属性所引用的Property
如果此属性包含相对路径,则会相对于此属性的父节点进行解释。因此,在解析这种相对路径时,“.”段指的是父节点本身,“..”段指的是父节点的父节点,“foo”段指的是该属性或该属性本身的同级属性。
例如,如果此属性位于/a/b/c,且其值为“[$6$]”,则此方法将返回位于/a/d的属性(如果存在)。
如果这个属性是多值的,这个方法抛出一个ValueFormatException
如果此属性无法转换为PATH,则会抛出ValueFormatException
如果此属性当前是版本存储中某个版本的冻结状态的一部分,则此方法将抛出ValueFormatException

代码示例

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public Property getProperty() throws RepositoryException {
  Property internalProperty = delegate.getProperty();
  return new PropertyFacade<>(internalProperty, session);
}

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

/**
 * Tests dereferencing a REFERENCE property to a Property
 * @since JCR 2.0
 */
public void testGetProperty() throws RepositoryException {
  try {
    prop.getProperty();
    fail("A REFERENCE property cannot be resolved to a Property.");
  } catch (ValueFormatException e) {
    // ok
  }
}

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

@Override
public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
  return getWrappedProperty().getProperty();
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector

public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
  return factory.getPropertyDecorator(session, property.getProperty());
}

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

/**
 * Tests the conversion from Binary type to Path type. This conversion
 * passes through previous String conversion.
 */
public void testGetProperty() throws RepositoryException, NotExecutableException {
  if (!multiple) {
    // not testable since format of ID is implementation specific
  } else {
    try {
      prop.getProperty();
      fail("Property.getProperty() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
 * Tests conversion from String type to Reference or Path type.
 */
public void testGetProperty() throws RepositoryException, NotExecutableException {
  if (!multiple) {
    // not testable as a STRING may or may not be convertable to Path or Reference
  } else {
    try {
      prop.getProperty();
      fail("Property.getNode() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
 * Tests failure of conversion from Double type to Path type.
 */
public void testGetProperty() throws RepositoryException {
  if (!multiple) {
    try {
      prop.getProperty();
      fail("Conversion from a Double value to a Path value " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException e) {
      // success.
    }
  } else {
    try {
      prop.getProperty();
      fail("Property.getProperty() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
 * Tests failure of conversion from Long type to Path type.
 */
public void testGetProperty() throws RepositoryException {
  if (!multiple) {
    try {
      prop.getProperty();
      fail("Conversion from a Long value to a Path value " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException e) {
      // success.
    }
  } else {
    try {
      prop.getProperty();
      fail("Property.getProperty() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
 * Tests failure of conversion from Date type to Path type.
 */
public void testGetProperty() throws RepositoryException {
  if (!multiple) {
    try {
      prop.getProperty();
      fail("Conversion from a Date value to a Path value " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      //ok
    }
  } else {
    try {
      prop.getProperty();
      fail("Property.getProperty() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
 * Tests failure of conversion from Boolean type to Path type.
 */
public void testGetProperty() throws RepositoryException {
  if (!multiple) {
    try {
      prop.getProperty();
      fail("Conversion from a Boolean value to a Path value " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      //ok
    }
  } else {
    try {
      prop.getProperty();
      fail("Property.getProperty() called on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}

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

/**
   * Since JCR 2.0 a path property can be dereferenced if it points to a
   * Property.
   * TODO: create several tests out of this one
   */
  public void testGetProperty() throws RepositoryException {
    if (!multiple) {
      String path = prop.getString();
      if (prop.getParent().hasProperty(path)) {
        Property p = prop.getProperty();
        assertEquals("The name of the dereferenced property must be equal to the value", path, p.getName());
      } else {
        try {
          prop.getProperty();
          fail("Calling Property.getProperty() for a NAME value that doesn't have a corresponding Node, ItemNotFoundException is expected");
        } catch (ItemNotFoundException e) {
          // success.
        }
      }
    } else {
      try {
        prop.getProperty();
        fail("Property.getNode() called on a multivalue property " +
            "should throw a ValueFormatException.");
      } catch (ValueFormatException vfe) {
        // ok
      }
    }
  }
}

代码示例来源:origin: brix-cms/brix-cms

public Property getProperty() throws ItemNotFoundException, ValueFormatException,
    RepositoryException {
  return PropertyWrapper.wrap(getDelegate().getProperty(), getSessionWrapper());
}

代码示例来源:origin: brix-cms/brix-cms

public JcrProperty execute() throws Exception {
    return JcrProperty.Wrapper.wrap(getDelegate().getProperty(), getJcrSession());
  }
});

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public Property getProperty() throws RepositoryException {
  Property property = this.item.getProperty();
  return new PropertyProxy(property, new NodeProxy(property.getParent()));
}

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

Property p = prop.getProperty();
assertEquals("The path of the dereferenced property must be equal to the value", path, p.getPath());
assertTrue("The property value must be resolved to the correct property.", prop.isSame(p));
p = prop.getProperty();
assertEquals("The path of the dereferenced property must be equal to the value", path, p.getName());
assertTrue("The property value must be resolved to the correct property.", prop.getParent().getProperty(path).isSame(p));
  prop.getProperty();
  fail("Calling Property.getProperty() for a PATH value that doesn't have a corresponding Property, ItemNotFoundException is expected");
} catch (ItemNotFoundException e) {
  prop.getProperty();
  fail("Property.getNode() called on a multivalue property " +
      "should throw a ValueFormatException.");

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

@Test
public void testPropertyReturnedFromPropertyIsWrapped() throws Exception {
  MockSession session = new MockSession("sessionName");
  Node rootNode = session.getRootNode();
  Node referredTo = rootNode.addNode("referredTo");
  referredTo.setProperty("text", "<html/>");
  Node referrer = rootNode.addNode("referrer");
  referrer.setProperty("reference", "/referredTo/text"); // Reference to a property
  HTMLEscapingNodeWrapper wrapper = new HTMLEscapingNodeWrapper(referrer, false);
  Property property = wrapper.getProperty("reference").getProperty();
  assertTrue(property instanceof HTMLEscapingPropertyWrapper);
  assertEquals("&lt;html/&gt;", property.getString());
}

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

@Test
public void returnsWrappedPropertyGetPropertyFromProperty() throws Exception {
  // GIVEN
  MockSession session = new MockSession("blah");
  Node node = session.getRootNode().addNode("foo");
  ContentDecoratorNodeWrapper wrapped = new ContentDecoratorNodeWrapper(node, new ContentDecoratorSuperClass());
  // WHEN
  Property test = wrapped.setProperty("test", "/foo/test");
  // THEN
  assertEquals(wrapped.getProperty("test").getProperty(), test);
}

相关文章