本文整理汇总了Java中org.jcrom.annotations.JcrParentNode类的典型用法代码示例。如果您正苦于以下问题:Java JcrParentNode类的具体用法?Java JcrParentNode怎么用?Java JcrParentNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JcrParentNode类属于org.jcrom.annotations包,在下文中一共展示了JcrParentNode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findParentField
import org.jcrom.annotations.JcrParentNode; //导入依赖的package包/类
Field findParentField(Object obj) {
return findAnnotatedField(obj, JcrParentNode.class);
}
示例2: findParentField
import org.jcrom.annotations.JcrParentNode; //导入依赖的package包/类
Field findParentField(Object obj)
{
return findAnnotatedField(obj, JcrParentNode.class);
}
示例3: resolveParentObject
import org.jcrom.annotations.JcrParentNode; //导入依赖的package包/类
private Object resolveParentObject(Field field, Node node) throws RepositoryException
{
JcrParentNode jcrParentNode = getJcrom().getAnnotationReader().getAnnotation(field, JcrParentNode.class);
int relativeParentLevel = jcrParentNode.relativeParentLevel();
int absoluteParentLevel = jcrParentNode.absoluteParentLevel();
boolean relativeParentLevelDefined = JcrParentNode.DEFAULT_VALUE_PARENT_LEVEL != relativeParentLevel;
boolean absoluteParentLevelDefined = JcrParentNode.DEFAULT_VALUE_PARENT_LEVEL != absoluteParentLevel;
Node resolvedParentNode = null;
if (!JcrParentNode.DEFAULT_PARENT_PATH.equals(jcrParentNode.relativeParentPath()))
{
if (node.hasNode(jcrParentNode.relativeParentPath()))
{
resolvedParentNode = node.getNode(jcrParentNode.relativeParentPath());
}
else
{
LOG.debug("No node can be resolved with the relative path [{}] from the path [{}]", jcrParentNode.relativeParentPath(), node.getPath());
}
}
else if (relativeParentLevelDefined && absoluteParentLevelDefined)
{
throw new JcrParameterException("For field [" + field.getName() + "] of class [" + field.getDeclaringClass().getCanonicalName()
+ "] the parameters 'relativeParentLevel' as well as 'absoluteParentLevel' are defined but they are mutually exclusive to each other.");
}
else if (relativeParentLevelDefined && absoluteParentLevel < node.getDepth())
{
resolvedParentNode = node;
for (int i = 0; i < relativeParentLevel; i++)
{
resolvedParentNode = resolvedParentNode.getParent();
}
}
else if (absoluteParentLevelDefined && absoluteParentLevel < node.getDepth())
{
resolvedParentNode = node;
for (; resolvedParentNode.getDepth() > absoluteParentLevel; resolvedParentNode = resolvedParentNode.getParent())
;
}
else
{
resolvedParentNode = node.getParent();
}
Object resolvedParentObject = resolvedParentNode;
if (resolvedParentObject != null && !Node.class.equals(field.getType()))
{
resolvedParentObject = jcrom.fromNode(field.getType(), resolvedParentNode);
}
return resolvedParentObject;
}