org.apache.jackrabbit.spi.QNodeDefinition.getRequiredPrimaryTypes()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(58)

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

QNodeDefinition.getRequiredPrimaryTypes介绍

[英]Returns the array of names of the required primary types.
[中]返回所需主要类型的名称数组。

代码示例

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
   * @see NodeDefinition#getRequiredPrimaryTypeNames()
   * @since JCR 2.0
   */
  public String[] getRequiredPrimaryTypeNames() {
    Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
    try {
      if (ntNames == null || ntNames.length == 0) {
        // return "nt:base"
        return new String[] { resolver.getJCRName(NameConstants.NT_BASE) };
      } else {
        String[] jcrNames = new String[ntNames.length];
        for (int i = 0; i < ntNames.length; i++) {
          jcrNames[i] = resolver.getJCRName(ntNames[i]);
        }
        return jcrNames;
      }
    } catch (NamespaceException e) {
      // should never get here
      log.error("required node type does not exist", e);
      return new String[0];
    }
  }
}

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

/**
   * @see NodeDefinition#getRequiredPrimaryTypeNames()
   * @since JCR 2.0
   */
  public String[] getRequiredPrimaryTypeNames() {
    Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
    try {
      if (ntNames == null || ntNames.length == 0) {
        // return "nt:base"
        return new String[] { resolver.getJCRName(NameConstants.NT_BASE) };
      } else {
        String[] jcrNames = new String[ntNames.length];
        for (int i = 0; i < ntNames.length; i++) {
          jcrNames[i] = resolver.getJCRName(ntNames[i]);
        }
        return jcrNames;
      }
    } catch (NamespaceException e) {
      // should never get here
      log.error("required node type does not exist", e);
      return new String[0];
    }
  }
}

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

/**
 * {@inheritDoc}
 */
public NodeType[] getRequiredPrimaryTypes() {
  if (ntMgr == null) {
    // not attached to an existing node type
    return null;
  }
  Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
  try {
    if (ntNames == null || ntNames.length == 0) {
      // return "nt:base"
      return new NodeType[] { ntMgr.getNodeType(NameConstants.NT_BASE) };
    } else {
      NodeType[] nodeTypes = new NodeType[ntNames.length];
      for (int i = 0; i < ntNames.length; i++) {
        nodeTypes[i] = ntMgr.getNodeType(ntNames[i]);
      }
      return nodeTypes;
    }
  } catch (NoSuchNodeTypeException e) {
    // should never get here
    log.error("required node type does not exist", e);
    return new NodeType[0];
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
 * {@inheritDoc}
 */
public NodeType[] getRequiredPrimaryTypes() {
  if (ntMgr == null) {
    // not attached to an existing node type
    return null;
  }
  Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes();
  try {
    if (ntNames == null || ntNames.length == 0) {
      // return "nt:base"
      return new NodeType[] { ntMgr.getNodeType(NameConstants.NT_BASE) };
    } else {
      NodeType[] nodeTypes = new NodeType[ntNames.length];
      for (int i = 0; i < ntNames.length; i++) {
        nodeTypes[i] = ntMgr.getNodeType(ntNames[i]);
      }
      return nodeTypes;
    }
  } catch (NoSuchNodeTypeException e) {
    // should never get here
    log.error("required node type does not exist", e);
    return new NodeType[0];
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
 * Compares two node definitions for equality. Returns <code>true</code>
 * if the given object is a node definition and has the same attributes
 * as this node definition.
 *
 * @param obj the object to compare this node definition with
 * @return <code>true</code> if the object is equal to this node definition,
 *         <code>false</code> otherwise
 * @see Object#equals(Object)
 */
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (obj instanceof QNodeDefinition) {
    QNodeDefinition other = (QNodeDefinition) obj;
    return super.equals(obj)
        && requiredPrimaryTypes.equals(new HashSet<Name>(
            Arrays.asList(other.getRequiredPrimaryTypes())))
        && (defaultPrimaryType == null
            ? other.getDefaultPrimaryType() == null
            : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
        && allowsSameNameSiblings == other.allowsSameNameSiblings();
  }
  return false;
}

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

/**
 * Compares two node definitions for equality. Returns <code>true</code>
 * if the given object is a node definition and has the same attributes
 * as this node definition.
 *
 * @param obj the object to compare this node definition with
 * @return <code>true</code> if the object is equal to this node definition,
 *         <code>false</code> otherwise
 * @see Object#equals(Object)
 */
@Override
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (obj instanceof QNodeDefinition) {
    QNodeDefinition other = (QNodeDefinition) obj;
    return super.equals(obj)
        && requiredPrimaryTypes.equals(new HashSet<Name>(
            Arrays.asList(other.getRequiredPrimaryTypes())))
        && (defaultPrimaryType == null
            ? other.getDefaultPrimaryType() == null
            : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
        && allowsSameNameSiblings == other.allowsSameNameSiblings();
  }
  return false;
}

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

Set<Name> s1 = new HashSet<Name>(Arrays.asList(getOldDef().getRequiredPrimaryTypes()));
Set<Name> s2 = new HashSet<Name>(Arrays.asList(getNewDef().getRequiredPrimaryTypes()));

代码示例来源:origin: org.apache.jackrabbit/com.springsource.org.apache.jackrabbit.spi.commons

/**
 * Compares two node definitions for equality. Returns <code>true</code>
 * if the given object is a node defintion and has the same attributes
 * as this node definition.
 *
 * @param obj the object to compare this node definition with
 * @return <code>true</code> if the object is equal to this node definition,
 *         <code>false</code> otherwise
 * @see Object#equals(Object)
 */
public boolean equals(Object obj) {
  if (this == obj) {
    return true;
  }
  if (obj instanceof QNodeDefinition) {
    QNodeDefinition other = (QNodeDefinition) obj;
    return super.equals(obj)
        && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes())
        && (defaultPrimaryType == null
            ? other.getDefaultPrimaryType() == null
            : defaultPrimaryType.equals(other.getDefaultPrimaryType()))
        && allowsSameNameSiblings == other.allowsSameNameSiblings();
  }
  return false;
}

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

/** Test for the <code>requiredPrimaryTypes</code> child node attributes. */
public void testRequiredTypeNode() {
  QNodeDefinition def = getChildNode("childNodeType", "requiredTypeNode");
  assertEquals("requiredTypeNode requiredPrimaryTypes",
      2, def.getRequiredPrimaryTypes().length);
  Name[] types = def.getRequiredPrimaryTypes();
  Arrays.sort(types);
  assertEquals("requiredTypeNode requiredPrimaryTypes[0]",
      FACTORY.create(Name.NS_NT_URI, "base"), types[0]);
  assertEquals("requiredTypeNode requiredPrimaryTypes[1]",
      FACTORY.create(Name.NS_NT_URI, "unstructured"), types[1]);
}

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

private NodeDefinitionTemplate createNodeDefinitionTemplate(NodeTypeManager ntMgr, QNodeDefinition def) throws RepositoryException {
  NodeDefinitionTemplate tmpl = ntMgr.createNodeDefinitionTemplate();
  Name name = def.getName();
  if (name != null) {
    tmpl.setName(getOakName(name));
  }
  tmpl.setAutoCreated(def.isAutoCreated());
  tmpl.setMandatory(def.isMandatory());
  tmpl.setOnParentVersion(def.getOnParentVersion());
  tmpl.setProtected(def.isProtected());
  tmpl.setSameNameSiblings(def.allowsSameNameSiblings());
  List<String> names = newArrayListWithCapacity(def.getRequiredPrimaryTypes().length);
  for (Name type : def.getRequiredPrimaryTypes()) {
    names.add(getOakName(type));
  }
  tmpl.setRequiredPrimaryTypeNames(names.toArray(new String[names.size()]));
  Name type = def.getDefaultPrimaryType();
  if (type != null) {
    tmpl.setDefaultPrimaryTypeName(getOakName(type));
  }
  return tmpl;
}

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

private NodeDefinitionTemplate createNodeDefinitionTemplate(NodeTypeManager ntMgr, QNodeDefinition def) throws RepositoryException {
  NodeDefinitionTemplate tmpl = ntMgr.createNodeDefinitionTemplate();
  Name name = def.getName();
  if (name != null) {
    tmpl.setName(getOakName(name));
  }
  tmpl.setAutoCreated(def.isAutoCreated());
  tmpl.setMandatory(def.isMandatory());
  tmpl.setOnParentVersion(def.getOnParentVersion());
  tmpl.setProtected(def.isProtected());
  tmpl.setSameNameSiblings(def.allowsSameNameSiblings());
  List<String> names = newArrayListWithCapacity(def.getRequiredPrimaryTypes().length);
  for (Name type : def.getRequiredPrimaryTypes()) {
    names.add(getOakName(type));
  }
  tmpl.setRequiredPrimaryTypeNames(names.toArray(new String[names.size()]));
  Name type = def.getDefaultPrimaryType();
  if (type != null) {
    tmpl.setDefaultPrimaryTypeName(getOakName(type));
  }
  return tmpl;
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
 * Copy constructor.
 *
 * @param nodeDef some other node definition.
 */
public QNodeDefinitionImpl(QNodeDefinition nodeDef) {
  this(nodeDef.getName(), nodeDef.getDeclaringNodeType(),
      nodeDef.isAutoCreated(), nodeDef.isMandatory(),
      nodeDef.getOnParentVersion(), nodeDef.isProtected(),
      nodeDef.getDefaultPrimaryType(),
      nodeDef.getRequiredPrimaryTypes(),
      nodeDef.allowsSameNameSiblings());
}

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

/**
 * Copy constructor.
 *
 * @param nodeDef some other node definition.
 */
public QNodeDefinitionImpl(QNodeDefinition nodeDef) {
  this(nodeDef.getName(), nodeDef.getDeclaringNodeType(),
      nodeDef.isAutoCreated(), nodeDef.isMandatory(),
      nodeDef.getOnParentVersion(), nodeDef.isProtected(),
      nodeDef.getDefaultPrimaryType(),
      nodeDef.getRequiredPrimaryTypes(),
      nodeDef.allowsSameNameSiblings());
}

代码示例来源:origin: org.apache.jackrabbit/com.springsource.org.apache.jackrabbit.spi.commons

/**
 * Copy constructor.
 *
 * @param nodeDef some other node definition.
 */
public QNodeDefinitionImpl(QNodeDefinition nodeDef) {
  this(nodeDef.getName(), nodeDef.getDeclaringNodeType(),
      nodeDef.isAutoCreated(), nodeDef.isMandatory(),
      nodeDef.getOnParentVersion(), nodeDef.isProtected(),
      nodeDef.getDefaultPrimaryType(),
      nodeDef.getRequiredPrimaryTypes(),
      nodeDef.allowsSameNameSiblings());
}

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

/**
 * Package private constructor
 *
 * @param def
 * @param resolver
 * @throws javax.jcr.nodetype.ConstraintViolationException
 */
NodeDefinitionTemplateImpl(NodeDefinition def, NamePathResolver resolver) throws ConstraintViolationException {
  super(def, resolver);
  requiredPrimaryTypes = def.getRequiredPrimaryTypes();
  allowSameNameSiblings = def.allowsSameNameSiblings();
  if (def instanceof NodeDefinitionImpl) {
    QNodeDefinition qDef = (QNodeDefinition) ((NodeDefinitionImpl) def).itemDef;
    requiredPrimaryTypeNames = qDef.getRequiredPrimaryTypes();
    defaultPrimaryTypeName = qDef.getDefaultPrimaryType();
  } else {
    setRequiredPrimaryTypeNames(def.getRequiredPrimaryTypeNames());
    setDefaultPrimaryTypeName(def.getDefaultPrimaryTypeName());
  }        
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
 * Package private constructor
 *
 * @param def
 * @param resolver
 * @throws javax.jcr.nodetype.ConstraintViolationException
 */
NodeDefinitionTemplateImpl(NodeDefinition def, NamePathResolver resolver) throws ConstraintViolationException {
  super(def, resolver);
  requiredPrimaryTypes = def.getRequiredPrimaryTypes();
  allowSameNameSiblings = def.allowsSameNameSiblings();
  if (def instanceof NodeDefinitionImpl) {
    QNodeDefinition qDef = (QNodeDefinition) ((NodeDefinitionImpl) def).itemDef;
    requiredPrimaryTypeNames = qDef.getRequiredPrimaryTypes();
    defaultPrimaryTypeName = qDef.getDefaultPrimaryType();
  } else {
    setRequiredPrimaryTypeNames(def.getRequiredPrimaryTypeNames());
    setDefaultPrimaryTypeName(def.getDefaultPrimaryTypeName());
  }        
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(cnDef.isProtected()));
pState.setPropertyValues(NameConstants.JCR_REQUIREDPRIMARYTYPES,
    PropertyType.NAME, InternalValue.create(cnDef.getRequiredPrimaryTypes()));
if (cnDef.getDefaultPrimaryType() != null) {
  pState.setPropertyValue(NameConstants.JCR_DEFAULTPRIMARYTYPE, InternalValue.create(cnDef.getDefaultPrimaryType()));

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

pState.setPropertyValue(NameConstants.JCR_PROTECTED, InternalValue.create(cnDef.isProtected()));
pState.setPropertyValues(NameConstants.JCR_REQUIREDPRIMARYTYPES,
    PropertyType.NAME, InternalValue.create(cnDef.getRequiredPrimaryTypes()));
if (cnDef.getDefaultPrimaryType() != null) {
  pState.setPropertyValue(NameConstants.JCR_DEFAULTPRIMARYTYPE, InternalValue.create(cnDef.getDefaultPrimaryType()));

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

/**
 * Create a new JCR node definition from the given <code>QNodeDefinition</code>.
 *
 * @param qNd A node definition.
 * @return The corresponding JCR node definition.
 * @throws RepositoryException if an error occurs.
 */
public NodeDefinition create(QNodeDefinition qNd)
    throws RepositoryException {
  NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
  nt.setName(getJCRName(qNd.getName()));
  nt.setAutoCreated(qNd.isAutoCreated());
  nt.setMandatory(qNd.isMandatory());
  nt.setOnParentVersion(qNd.getOnParentVersion());
  nt.setProtected(qNd.isProtected());
  nt.setSameNameSiblings(qNd.allowsSameNameSiblings());
  nt.setDefaultPrimaryTypeName(getJCRName(qNd.getDefaultPrimaryType()));
  nt.setRequiredPrimaryTypeNames(getJCRNames(qNd.getRequiredPrimaryTypes()));
  return nt;
}

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

/**
 * Create a new JCR node definition from the given <code>QNodeDefinition</code>.
 *
 * @param qNd A node definition.
 * @return The corresponding JCR node definition.
 * @throws RepositoryException if an error occurs.
 */
public NodeDefinition create(QNodeDefinition qNd)
    throws RepositoryException {
  NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
  nt.setName(getJCRName(qNd.getName()));
  nt.setAutoCreated(qNd.isAutoCreated());
  nt.setMandatory(qNd.isMandatory());
  nt.setOnParentVersion(qNd.getOnParentVersion());
  nt.setProtected(qNd.isProtected());
  nt.setSameNameSiblings(qNd.allowsSameNameSiblings());
  nt.setDefaultPrimaryTypeName(getJCRName(qNd.getDefaultPrimaryType()));
  nt.setRequiredPrimaryTypeNames(getJCRNames(qNd.getRequiredPrimaryTypes()));
  return nt;
}

相关文章