use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class ChildNodeEntriesImpl method reorderAfter.
/**
*
* @param insertLN
* @param afterLN
*/
private void reorderAfter(LinkedEntries.LinkNode insertLN, LinkedEntries.LinkNode afterLN) {
// the link node to move
if (insertLN == null) {
throw new NoSuchElementException();
}
// the link node where insertLN is ordered after
if (afterLN == null) {
// move to first position
afterLN = entries.getHeader();
}
LinkedEntries.LinkNode currentAfter = afterLN.getNextLinkNode();
if (currentAfter == insertLN) {
log.debug("Already ordered behind 'afterEntry'.");
// nothing to do
return;
} else {
// reorder named map
Name insertName = insertLN.qName;
if (entriesByName.containsSiblings(insertName)) {
// default: reorder to the end.
int position = -1;
if (afterLN == entries.getHeader()) {
// move to the beginning
position = 0;
} else {
// count all SNS-entries that are before 'afterLN' in order to
// determine the new position of the reordered node regarding
// his siblings.
position = 0;
for (Iterator<LinkedEntries.LinkNode> it = entries.linkNodeIterator(); it.hasNext(); ) {
LinkedEntries.LinkNode ln = it.next();
if (insertName.equals(ln.qName) && (ln != insertLN)) {
position++;
}
if (ln == afterLN) {
break;
}
}
}
entriesByName.reorder(insertName, insertLN, position);
}
// reorder in linked list
entries.reorderNode(insertLN, currentAfter);
}
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class ChildNodeEntriesImpl method internalAdd.
/**
*
* @param entry
* @param index
* @return the <code>LinkNode</code> belonging to the added entry.
*/
private LinkedEntries.LinkNode internalAdd(NodeEntry entry, int index) {
Name nodeName = entry.getName();
// retrieve ev. sibling node with same index. if index is 'undefined'
// the existing entry is always null and no reordering occurs.
LinkedEntries.LinkNode existing = null;
if (index >= Path.INDEX_DEFAULT) {
existing = entriesByName.getLinkNode(nodeName, index);
}
// TODO: TOBEFIXED in case of orderable node the order in the 'linked-entries' must be respected.
for (int i = Path.INDEX_DEFAULT; i < index; i++) {
LinkedEntries.LinkNode previous = entriesByName.getLinkNode(nodeName, i);
if (previous == null) {
NodeEntry sibling = factory.createNodeEntry(parent, nodeName, null);
internalAdd(sibling, i);
}
}
// add new entry
LinkedEntries.LinkNode ln = entries.add(entry, index);
entriesByName.put(nodeName, index, ln);
// than appended at the end of the list.
if (existing != null) {
reorder(nodeName, ln, existing);
}
return ln;
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class ChildPropertyEntriesImpl method remove.
/**
* @see ChildPropertyEntries#remove(PropertyEntry)
*/
public boolean remove(PropertyEntry propertyEntry) {
synchronized (properties) {
Name pName = propertyEntry.getName();
PropertyEntry pe = get(pName);
if (pe == propertyEntry) {
properties.remove(pName);
return true;
} else {
return false;
}
}
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class PropertyImpl method getName.
//-----------------------------------------------------< Item interface >---
/**
* @see Item#getName()
*/
@Override
public String getName() throws RepositoryException {
checkStatus();
Name name = getQName();
return session.getNameResolver().getJCRName(name);
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class NodeImpl method getMixinTypes.
/**
* Retrieves the value of the jcr:mixinTypes property present with this
* Node including those that have been transiently added and excluding
* those, that have been transiently removed.<br>
* NOTE, that the result of this method, does NOT represent the list of
* mixin-types that currently affect this node.
*
* @return mixin names present with the jcr:mixinTypes property.
*/
private List<Name> getMixinTypes() {
Name[] mixinValue;
if (getNodeState().getStatus() == Status.EXISTING) {
// jcr:mixinTypes must correspond to the mixins present on the nodestate.
mixinValue = getNodeState().getMixinTypeNames();
} else {
try {
PropertyEntry pe = getNodeEntry().getPropertyEntry(NameConstants.JCR_MIXINTYPES);
if (pe != null) {
// prop entry exists (and ev. has been transiently mod.)
// -> retrieve mixin types from prop
mixinValue = StateUtility.getMixinNames(pe.getPropertyState());
} else {
// prop entry has not been loaded yet -> not modified
mixinValue = getNodeState().getMixinTypeNames();
}
} catch (RepositoryException e) {
// should never occur
log.warn("Internal error", e);
mixinValue = Name.EMPTY_ARRAY;
}
}
List<Name> l = new ArrayList<Name>();
l.addAll(Arrays.asList(mixinValue));
return l;
}
Aggregations