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

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

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

Property.getLong介绍

[英]Returns a long representation of the value of this property. A shortcut for Property.getValue().getLong().
[中]返回此属性值的long表示形式。Property.getValue().getLong()的快捷方式。

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.javascript

public Object jsGet_long() {
  try {
    return property.getLong();
  } catch (RepositoryException re) {
    return Undefined.instance;
  }
}

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

@Override
protected int getMaxResults() {
  try {
    if (content.hasProperty("maxResults")) {
      return (int) content.getProperty("maxResults").getLong();
    }
    return Integer.MAX_VALUE;
  } catch (RepositoryException e) {
    return Integer.MAX_VALUE;
  }
}

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

public static Long getLong(Node node, String name, Long defaultValue) {
  if (node != null) {
    try {
      if (node.hasProperty(name)) {
        return node.getProperty(name).getLong();
      }
    } catch (RepositoryException e) {
      log.error("can't read value '{}' of the Node '{}' will return default value", name, node.toString(), e);
    }
  }
  return defaultValue;
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * long)</code> works with <code>Session.save()</code>
 */
public void testNewLongPropertySession() throws Exception {
  testNode.setProperty(propertyName1, l1);
  superuser.save();
  assertEquals("Setting property with Node.setProperty(String, long) and Session.save() not working",
      new Long(l1),
      new Long(testNode.getProperty(propertyName1).getLong()));
}

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

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * long)</code> works with <code>parentNode.save()</code>
 */
public void testNewLongPropertyParent() throws Exception {
  testNode.setProperty(propertyName1, l1);
  testRootNode.getSession().save();
  assertEquals("Setting property with Node.setProperty(String, long) and parentNode.save() not working",
      new Long(l1),
      new Long(testNode.getProperty(propertyName1).getLong()));
}

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

public long getLongProperty(String name) {
  try {
    final Property property = getJCRProperty(name);
    if (property != null) {
      return property.getLong();
    }
  } catch (RepositoryException re) {
    log.error(re.getMessage(), re);
  }
  return 0L;
}

代码示例来源:origin: exoplatform/platform

private ForumsWeeklyStatistic getForumsWeeklyStatistic(Node node) throws Exception {
 ForumsWeeklyStatistic statistic = new ForumsWeeklyStatistic();
 statistic.setId(node.getName());
 statistic.setStartDate(node.getProperty("exo:startDate").getDate().getTime());
 statistic.setStartPostsCountOfWeek(node.getProperty("exo:startPostsCountOfWeek").getLong());
 statistic.setPostsCountOfWeek(node.getProperty("exo:postsCountOfWeek").getLong());
 statistic.setLastStatEntry(node.getProperty("exo:lastStatEntry").getDate().getTime());
 return statistic;
}

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

@Override
public long getContentSize() {
  try {
    if (hasDescriptionProperty(CONTENT_SIZE)) {
      return getDescriptionProperty(CONTENT_SIZE).getLong();
    }
  } catch (final RepositoryException e) {
    LOGGER.warn("Could not get contentSize(): {}", e.getMessage());
  }
  return -1L;
}

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

@Override
public long getLong() {
  if (isExist()) {
    try {
      return getJCRProperty().getLong();
    } catch (RepositoryException e) {
      throw new RuntimeException("Can't read value of nodedata " + toString(), e);
    }
  }
  return 0;
}

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

public long getLong(Property property) throws RepositoryException {
  if (getPrevious() != null) {
    return getPrevious().getLong(property);
  } else {
    return property.getLong();
  }
}

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

@Override
  protected void entering(Node node, int level) throws RepositoryException {
    if (node.isNodeType("rep:Permissions")
        && node.hasProperty("rep:accessControlledPath")
        && path.equals(node.getProperty("rep:accessControlledPath").getString())) {
      assertEquals(index, node.getProperty("rep:index").getLong());
      assertEquals(isAllow, node.getProperty("rep:isAllow").getBoolean());
    }
  }
};

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

private static void check(Session session) throws RepositoryException {
  if (session.getNode("/testNode").getProperty("p1").getLong() +
      session.getNode("/testNode").getProperty("p2").getLong() < 0) {
    fail("p1 + p2 < 0");
  }
}

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

private static void assertCounter(@NotNull final Node counter, final long expectedCount) 
                throws RepositoryException {
  checkNotNull(counter);
  
  assertTrue(counter.hasProperty(PROP_COUNTER));
  assertEquals(expectedCount, counter.getProperty(PROP_COUNTER).getLong());
  assertFalse(counter.hasProperty(PROP_INCREMENT));
}

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

protected void assertFile( Node node,
              File file ) throws Exception {
  assertThat(node.getName(), is(file.getName()));
  assertThat(node.getIndex(), is(1));
  assertThat(node.getPrimaryNodeType().getName(), is("nt:file"));
  assertThat(node.getProperty("jcr:created").getLong(), is(createdTimeFor(file)));
  Node content = node.getNode("jcr:content");
  assertThat(content.getName(), is("jcr:content"));
  assertThat(content.getIndex(), is(1));
  assertThat(content.getPrimaryNodeType().getName(), is("nt:resource"));
  assertThat(content.getProperty("jcr:lastModified").getLong(), is(file.lastModified()));
}

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

@Test
public void shouldSequenceTextTemplate() throws Exception {
  // GIVEN
  String filename = "text.ott";
  // WHEN
  createNodeWithContentFromFile(filename, filename);
  // THEN
  Node sequencedNode = getOutputNode(rootNode, "sequenced/odf/" + filename);
  assertThat(sequencedNode.getProperty(JcrConstants.JCR_MIME_TYPE).getString(), is("application/vnd.oasis.opendocument.text-template"));
  assertThat(sequencedNode.getProperty(PAGES).getLong(), is(2L));
  assertCommonMetadata(sequencedNode);
}

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

private void checkACL(String path, long right, String permissionNodeName) throws RepositoryException {
    assertTrue(userRoleSession.nodeExists("/superuser/acl_userroles"));
    aclUserrolesNode = userRoleSession.getNode("/superuser/acl_userroles");
    assertTrue(aclUserrolesNode.hasNode(permissionNodeName));
    Node permission = aclUserrolesNode.getNode(permissionNodeName);
    assertTrue(permission.hasProperty("path"));
    assertEquals(path, permission.getProperty("path").getString());
    assertTrue(permission.hasProperty("permissions"));
    assertEquals(right, permission.getProperty("permissions").getLong());
  }
}

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

@Test
public void setPropertyToInteger() throws Exception {
  // GIVEN
  final int value = 123;
  PropertyUtil.setProperty(root, PROPERTY_NAME, value);
  // WHEN
  Long longValue = root.getProperty(PROPERTY_NAME).getLong();
  // THEN
  assertEquals(value, longValue.intValue());
}

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

@Test
public void setPropertyToLong() throws Exception {
  // GIVEN
  final Object value = Long.valueOf(123l);
  PropertyUtil.setProperty(root, PROPERTY_NAME, value);
  // WHEN
  long resr = root.getProperty(PROPERTY_NAME).getLong();
  // THEN
  assertEquals(value, resr);
}

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

public void testReset() throws Exception {
  TokenInfo info = tokenProvider.createToken(testuser, new SimpleCredentials(userId, userId.toCharArray()));
  long expTime = getTokenNode(info).getProperty("rep:token.exp").getLong();
  long loginTime = waitForSystemTimeIncrement(System.currentTimeMillis());
  assertFalse(info.resetExpiration(loginTime));
  assertFalse(info.resetExpiration(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION));
  assertTrue(info.resetExpiration(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION / 2));
  long expTime2 = getTokenNode(info).getProperty("rep:token.exp").getLong();
  assertFalse(expTime == expTime2);
}

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

@Test
public void shouldCreateProjectionWithoutAlias() throws Exception {
  // link the first external document
  federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, null);
  assertEquals(1, testRoot.getNodes().getSize());
  Node doc1Federated = assertNodeFound("/testRoot" + MockConnector.DOC1_LOCATION);
  assertEquals(testRoot.getIdentifier(), doc1Federated.getParent().getIdentifier());
  assertEquals("a string", doc1Federated.getProperty("federated1_prop1").getString());
  assertEquals(12, doc1Federated.getProperty("federated1_prop2").getLong());
}

相关文章