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

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

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

Property.getValue介绍

[英]Returns the value of this property as a Value object.

The object returned is a copy of the stored value and is immutable.
[中]将此属性的值作为Value对象返回。
返回的对象是存储值的副本,是不可变的。

代码示例

代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-clone-component

private void setProperty(final Node newNode, final Node cloneNode, final String propertyName) throws RepositoryException {
  if (cloneNode.hasProperty(propertyName)) {
    final Property property = cloneNode.getProperty(propertyName);
    newNode.setProperty(propertyName, property.getValue());
  }
}

代码示例来源:origin: ModeShape/modeshape

protected void verifyProperty( Node node,
                String propertyName,
                String expectedValue ) throws RepositoryException {
  Property property = node.getProperty(propertyName);
  Value value = property.isMultiple() ? property.getValues()[0] : property.getValue();
  assertEquals(expectedValue, value.getString());
}

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

@Override
public boolean hasNodeData(String name) throws RepositoryException {
  if (this.node.hasProperty(name)) {
    return true;
  }
  if (this.node.hasNode(name) && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)) {
    return true;
  }
  return false;
}

代码示例来源:origin: ModeShape/modeshape

protected void verifyProperty( Node node,
                String propertyName,
                long expectedValue ) throws RepositoryException {
  Property property = node.getProperty(propertyName);
  Value value = property.isMultiple() ? property.getValues()[0] : property.getValue();
  assertEquals(expectedValue, value.getLong());
}

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

protected boolean hasBinaryNode(String name) throws RepositoryException {
    return this.node.hasNode(name) && (this.node.getNode(name).isNodeType(ItemType.NT_RESOURCE) ||
        (this.node.hasProperty("jcr:frozenPrimaryType") && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)));
  }
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Value, int)</code> works with <code>Session.save()</code>
 */
public void testNewValuePropertySessionWithPropertyType() throws Exception {
  testNode.setProperty(propertyName1, v1, PropertyType.STRING);
  superuser.save();
  assertEquals("Setting property with Node.setProperty(String, Value, int) and Session.save() not working",
      v1,
      testNode.getProperty(propertyName1).getValue());
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Value, int)</code> works with <code>parentNode.save()</code>
 */
public void testNewValuePropertyParentWithPropertyType() throws Exception {
  testNode.setProperty(propertyName1, v1, PropertyType.STRING);
  testRootNode.getSession().save();
  assertEquals("Setting property with Node.setProperty(String, Value, int) and parentNode.save() not working",
      v1,
      testNode.getProperty(propertyName1).getValue());
}

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

private void renameObsoleteProperty(Node controlNode, String oldName, String newName) throws RepositoryException {
  if (!controlNode.hasProperty(oldName)) {
    return;
  }
  Property property = controlNode.getProperty(oldName);
  controlNode.setProperty(newName, property.getValue());
  property.remove();
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Value)</code> works with <code>Session.save()</code>
 */
public void testNewValuePropertySession() throws Exception {
  testNode.setProperty(propertyName1, v1);
  superuser.save();
  assertEquals("Setting property with Node.setProperty(String, Value) and Session.save() not working",
      v1,
      testNode.getProperty(propertyName1).getValue());
}

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

/**
   * Tests equals method of Reference value.
   */
  public void testEquals() throws RepositoryException {
    Property prop2 = referencedNode.getProperty(jcrUUID);
    assertTrue("Incorrect equals method of Reference value.",
        PropertyUtil.equalValues(prop2.getValue(), prop.getValue()));
  }
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Value)</code> works with <code>parentNode.save()</code>
 */
public void testNewValuePropertyParent() throws Exception {
  testNode.setProperty(propertyName1, v1);
  testRootNode.getSession().save();
  assertEquals("Setting property with Node.setProperty(String, Value) and parentNode.save() not working",
      v1,
      testNode.getProperty(propertyName1).getValue());
}

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

private boolean isBinary(Node requestedData) throws RepositoryException {
  return requestedData.isNodeType(NodeTypes.Resource.NAME) ||
      (requestedData.hasProperty("jcr:frozenPrimaryType") && requestedData.getProperty("jcr:frozenPrimaryType").getValue().getString().equals(NodeTypes.Resource.NAME));
}

代码示例来源:origin: org.onehippo.cms7/hippo-essentials-plugin-gallery-manager

private void copyTemplateTranslations(final Session session, final String sourceKey, final String destinationKey) throws RepositoryException {
  final Node bundles = session.getNode("/hippo:configuration/hippo:translations/hippo:templates");
  for (Node bundle : new NodeIterable(bundles.getNodes())) {
    if (bundle.hasProperty(sourceKey)) {
      bundle.setProperty(destinationKey, bundle.getProperty(sourceKey).getValue());
    } else {
      log.debug("Cannot set translation for template {}, cannot find source {}", destinationKey, sourceKey);
    }
  }
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Calendar)</code> works with <code>parentNode.save()</code>
 */
public void testNewCalendarPropertyParent() throws Exception {
  testNode.setProperty(propertyName1, c1);
  testRootNode.getSession().save();
  assertEquals("Setting property with Node.setProperty(String, Calendar) and parentNode.save() not working",
      vf.createValue(c1),
      testNode.getProperty(propertyName1).getValue());
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-dashboard

public String getMethod() {
  try {
    Node node = getNode();
    if (node.hasProperty("hippolog:eventMethod")) {
      return node.getProperty("hippolog:eventMethod").getValue().getString();
    }
  } catch (RepositoryException e) {
    log.error(e.getMessage());
  }
  return null;
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-dashboard

public String getDocument() {
  try {
    Node node = getNode();
    if (node.hasProperty("hippolog:eventDocument")) {
      return node.getProperty("hippolog:eventDocument").getValue().getString();
    }
  } catch (RepositoryException e) {
    log.error(e.getMessage());
  }
  return null;
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * Calendar)</code> works with <code>Session.save()</code>
 */
public void testNewCalendarPropertySession() throws Exception {
  testNode.setProperty(propertyName1, c1);
  superuser.save();
  assertEquals("Setting property with Node.setProperty(String, Calendar) and Session.save() not working",
      vf.createValue(c1),
      testNode.getProperty(propertyName1).getValue());
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.jcr

public Value getValue(String s) throws ItemNotFoundException, RepositoryException {
  if (getNode().getProperty(s) != null) {
    return getNode().getProperty(s).getValue();
  } else {
    return null;
  }
}

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

/**
 * Checks that the given property does not exist and creates it with the given value, logs otherwise.
 */
protected void newProperty(InstallContext ctx, Node node, String propertyName, Object value) throws RepositoryException {
  if (!node.hasProperty(propertyName)) {
    PropertyUtil.setProperty(node, propertyName, value);
  } else {
    final String msg = format("Property \"{0}\" was expected not to exist at {1}, but exists with value \"{2}\" and was going to be created with value \"{3}\".",
        propertyName, node.getPath(), node.getProperty(propertyName).getValue().getString(), value);
    ctx.warn(msg);
  }
}

代码示例来源:origin: org.jcrom/jcrom

@Override
  protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("Lazy loading single reference for " + nodePath + " " + propertyName);
    }
    Node node = PathUtils.getNode(nodePath, session);
    return mapper.getReferenceMapper().createReferencedObject(field, node.getProperty(propertyName).getValue(), parentObject, session, objClass, depth, nodeFilter, mapper);
  }
}

相关文章