本文整理汇总了Java中javax.jcr.PropertyIterator类的典型用法代码示例。如果您正苦于以下问题:Java PropertyIterator类的具体用法?Java PropertyIterator怎么用?Java PropertyIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyIterator类属于javax.jcr包,在下文中一共展示了PropertyIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyNode
import javax.jcr.PropertyIterator; //导入依赖的package包/类
/**
* Copies nodes.
*
* @param node Node to copy
* @param destinationParent Destination parent node
* @throws RepositoryException if problem with jcr repository occurred
*/
public void copyNode(Node node, Node destinationParent) throws RepositoryException {
LOG.debug("Copying node '{}' into '{}'", node.getPath(), destinationParent.getPath());
Node newNode = destinationParent.addNode(node.getName(), node.getPrimaryNodeType().getName());
PropertyIterator it = node.getProperties();
while (it.hasNext()) {
Property property = it.nextProperty();
if (!property.getDefinition().isProtected()) {
newNode
.setProperty(property.getName(), property.getValue().getString(), property.getType());
}
}
NodeIterator nodeIterator = node.getNodes();
while (nodeIterator.hasNext()) {
copyNode(nodeIterator.nextNode(), newNode);
}
}
示例2: getPropertiesWithDefaultValuesReturnsNonEmptyProperties
import javax.jcr.PropertyIterator; //导入依赖的package包/类
@Test
public void getPropertiesWithDefaultValuesReturnsNonEmptyProperties() throws Exception {
Node testObj = aNode("/content");
PropertyIterator actual = testObj.getProperties();
assertTrue(actual.hasNext());
}
示例3: getFieldsForCard
import javax.jcr.PropertyIterator; //导入依赖的package包/类
public Map<String, Object> getFieldsForCard(Card card,
ObjectContentManager ocm) throws RepositoryException {
Map<String, Object> result = new HashMap<String, Object>();
Node node = ocm.getSession().getNode(
String.format(URI.FIELDS_URI, card.getBoard(), card.getPhase(),
card.getId()));
if(node==null){
return result;
}
PropertyIterator properties = node.getProperties();
while (properties.hasNext()) {
Property property = properties.nextProperty();
Object value = getRealValue(property);
result.put(property.getName(), value);
}
return result;
}
示例4: mapPropertiesToMap
import javax.jcr.PropertyIterator; //导入依赖的package包/类
void mapPropertiesToMap(Object obj, Field field, Class<?> valueType, PropertyIterator propIterator, boolean ignoreReadOnlyProperties) throws RepositoryException, IOException, IllegalAccessException {
Map<String, Object> map = new HashMap<String, Object>();
while (propIterator.hasNext()) {
Property p = propIterator.nextProperty();
// we ignore the read-only properties added by the repository
if (!ignoreReadOnlyProperties || (!p.getName().startsWith("jcr:") && !p.getName().startsWith(NamespaceRegistry.NAMESPACE_JCR) && !p.getName().startsWith("nt:") && !p.getName().startsWith(NamespaceRegistry.NAMESPACE_NT))) {
if (valueType.isArray()) {
if (p.getDefinition().isMultiple()) {
map.put(p.getName(), valuesToArray(valueType.getComponentType(), p.getValues()));
} else {
Value[] values = new Value[1];
values[0] = p.getValue();
map.put(p.getName(), valuesToArray(valueType.getComponentType(), values));
}
} else {
map.put(p.getName(), JcrUtils.getValue(valueType, p.getValue()));
}
}
}
setObject(field, obj, map);
}
示例5: mapPropertyToField
import javax.jcr.PropertyIterator; //导入依赖的package包/类
void mapPropertyToField(Object obj, Field field, Node node, int depth, NodeFilter nodeFilter) throws RepositoryException, IllegalAccessException, IOException {
String name = getPropertyName(field);
if (nodeFilter == null || nodeFilter.isIncluded(NodeFilter.PROPERTY_PREFIX + field.getName(), node, depth)) {
if (isMap(field)) {
// map of properties
Class<?> valueType = ReflectionUtils.getParameterizedClass(field, 1);
try {
Node childrenContainer = node.getNode(name);
PropertyIterator propIterator = childrenContainer.getProperties();
mapPropertiesToMap(obj, field, valueType, propIterator, true);
} catch (PathNotFoundException pne) {
// ignore here as the Field could have been added to the model
// since the Node was created and not yet been populated.
}
} else {
mapToField(name, field, obj, node);
}
}
}
示例6: mapProtectedPropertyToField
import javax.jcr.PropertyIterator; //导入依赖的package包/类
void mapProtectedPropertyToField(Object obj, Field field, Node node) throws RepositoryException, IllegalAccessException, IOException
{
String name = getProtectedPropertyName(field);
if (ReflectionUtils.implementsInterface(field.getType(), Map.class))
{
// map of properties
Class<?> valueType = ReflectionUtils.getParameterizedClass(field, 1);
Node childrenContainer = node.getNode(name);
PropertyIterator propIterator = childrenContainer.getProperties();
mapPropertiesToMap(obj, field, valueType, propIterator, false);
}
else
{
mapToField(name, field, obj, node);
}
}
示例7: getAttributes
import javax.jcr.PropertyIterator; //导入依赖的package包/类
/**
* Writes the mail attributes from the <code>jamesattr:*</code> property.
*
* @param node
* mail node
* @param mail
* mail message
* @throws RepositoryException
* if a repository error occurs
* @throws IOException
* if an IO error occurs
*/
private void getAttributes(Node node, Mail mail) throws RepositoryException, IOException {
PropertyIterator iterator = node.getProperties("jamesattr:*");
while (iterator.hasNext()) {
Property property = iterator.nextProperty();
String name = Text.unescapeIllegalJcrChars(property.getName().substring("jamesattr:".length()));
if (property.getType() == PropertyType.BINARY) {
InputStream input = property.getStream();
try {
ObjectInputStream stream = new ObjectInputStream(input);
mail.setAttribute(name, (Serializable) stream.readObject());
} catch (ClassNotFoundException e) {
throw new IOException(e.getMessage());
} finally {
input.close();
}
} else {
mail.setAttribute(name, property.getString());
}
}
}
示例8: propertyNames
import javax.jcr.PropertyIterator; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.modelspace.ModelObject#propertyNames()
*/
@Override
public String[] propertyNames() throws ModelspaceException {
return modelspace.run( new TaskWithResult< String[] >() {
@Override
public String[] run( final Session session ) throws Exception {
final List< String > names = new ArrayList<>();
for ( final PropertyIterator iter = session.getNode( path ).getProperties(); iter.hasNext(); ) {
final String name = iter.nextProperty().getName();
if ( !name.startsWith( JcrLexicon.Namespace.PREFIX ) && !name.startsWith( ModelspaceLexicon.NAMESPACE_PREFIX ) )
names.add( name );
}
return names.toArray( new String[ names.size() ] );
}
} );
}
示例9: createInventory
import javax.jcr.PropertyIterator; //导入依赖的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());
}
}
}
}
}
示例10: getNodePropertySize
import javax.jcr.PropertyIterator; //导入依赖的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;
}
示例11: getPropertyNames
import javax.jcr.PropertyIterator; //导入依赖的package包/类
/**
* @see Entity#getPropertyNames(String)
*/
public Iterator<String> getPropertyNames(String relPath) throws RepositoryException {
Node n = node.getNode(relPath);
if (n.isSame(node)) {
// same as #getPropertyNames()
return getPropertyNames();
} else if (Text.isDescendant(node.getPath(), n.getPath())) {
List<String> l = new ArrayList<String>();
for (PropertyIterator it = n.getProperties(); it.hasNext();) {
Property prop = it.nextProperty();
if (isEntityProperty(prop, false)) {
l.add(prop.getName());
}
}
return l.iterator();
} else {
throw new IllegalArgumentException("Relative path " + relPath + " refers to items outside of scope of authorizable " + getId());
}
}
示例12: getProperties
import javax.jcr.PropertyIterator; //导入依赖的package包/类
public static Properties getProperties(BOContent a_content) throws Throwable{
Properties properties = new Properties();
Node node = a_content.getNode();
PropertyIterator props = node.getProperties();
while(props.hasNext()) {
Property prop = props.nextProperty();
properties.put(prop.getName(), prop.getString());
}
return properties;
}
示例13: getProperties
import javax.jcr.PropertyIterator; //导入依赖的package包/类
@Override
public PropertyIterator getProperties() throws RepositoryException {
List<Property> children = new ArrayList<>();
for (Item item : session.getChildren(this))
if (!item.isNode())
children.add((Property)item);
return new PropertyIteratorImpl(children);
}
示例14: mapProtectedPropertyToField
import javax.jcr.PropertyIterator; //导入依赖的package包/类
void mapProtectedPropertyToField(Object obj, Field field, Node node) throws RepositoryException, IllegalAccessException, IOException {
String name = getProtectedPropertyName(field);
if (isMap(field)) {
// map of properties
Class<?> valueType = ReflectionUtils.getParameterizedClass(field, 1);
Node childrenContainer = node.getNode(name);
PropertyIterator propIterator = childrenContainer.getProperties();
mapPropertiesToMap(obj, field, valueType, propIterator, false);
} else {
mapToField(name, field, obj, node);
}
}
示例15: getReferenceMap
import javax.jcr.PropertyIterator; //导入依赖的package包/类
Map<String, Object> getReferenceMap(Field field, String containerName, Class<?> mapParamClass, Node node, Object obj, int depth, NodeFilter nodeFilter, Mapper mapper, JcrReference jcrReference) throws ClassNotFoundException, InstantiationException, RepositoryException, IllegalAccessException, IOException {
Map<String, Object> references = new HashMap<String, Object>();
if (node.hasNode(containerName)) {
Node containerNode = node.getNode(containerName);
PropertyIterator propertyIterator = containerNode.getProperties();
while (propertyIterator.hasNext()) {
Property p = propertyIterator.nextProperty();
if (!p.getName().startsWith("jcr:") && !p.getName().startsWith(NamespaceRegistry.NAMESPACE_JCR)) {
if (isList(mapParamClass)) {
if (jcrReference.lazy()) {
references.put(p.getName(), ProxyFactory.createReferenceListProxy(Object.class, obj, containerNode.getPath(), p.getName(), node.getSession(), mapper, depth, nodeFilter, field));
} else {
references.put(p.getName(), getReferenceList(field, p.getName(), Object.class, containerNode, obj, depth, nodeFilter, mapper));
}
} else {
if (jcrReference.lazy()) {
Node referencedNode = getSingleReferencedNode(jcrReference, p.getValue(), node.getSession());
references.put(p.getName(), ProxyFactory.createReferenceProxy(mapper.findClassFromNode(Object.class, referencedNode), obj, containerNode.getPath(), p.getName(), node.getSession(), mapper, depth, nodeFilter, field));
} else {
references.put(p.getName(), createReferencedObject(field, p.getValue(), obj, containerNode.getSession(), Object.class, depth, nodeFilter, mapper));
}
}
}
}
}
return references;
}