private int getNextChildIndex ( InternalQName nameToAdd , InternalQName primaryTypeName , NodeData parentNode , NodeDefinitionData def ) throws RepositoryException , ItemExistsException { boolean allowSns = def . isAllowsSameNameSiblings ( ) ; int ind = 1 ; boolean hasSibling = dataManager . hasItemData ( parentNode , new QPathEntry ( nameToAdd , ind ) , ItemType . NODE ) ; while ( hasSibling ) { if ( allowSns ) { ind ++ ; hasSibling = dataManager . hasItemData ( parentNode , new QPathEntry ( nameToAdd , ind ) , ItemType . NODE ) ; } else { throw new ItemExistsException ( "The node " + nameToAdd + " already exists in " + getPath ( ) + " and same name sibling is not allowed " ) ; } } ; return ind ; }
Calculates next child node index . Is used existed node definition if no - get one based on node name and node type .