Package org.apache.commons.collections.iterators

Examples of org.apache.commons.collections.iterators.AbstractIteratorDecorator


        public void clear() {
            this.parent.clear();
        }

        public Iterator iterator() {
            return new AbstractIteratorDecorator(parent.entrySet().iterator()) {
                public Object next() {
                    return ((Map.Entry) super.next()).getKey();
                }
            };
        }
View Full Code Here


            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

                addedNodes.add(nodeUUID);
                removedNodes.add(nodeUUID);
            }
        }

        Iterator addedStates = new AbstractIteratorDecorator(addedNodes.iterator()) {
            public Object next() {
                ItemState item = null;
                String uuid = (String) super.next();
                try {
                    item = itemMgr.getItemState(new NodeId(uuid));
View Full Code Here

     * @throws IOException         if an error occurs while updating the index.
     */
    public void updateNodes(Iterator remove, Iterator add)
            throws RepositoryException, IOException {
        checkOpen();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                String uuid = (String) super.next();
                return new Term(FieldNames.UUID, uuid);
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
View Full Code Here

            // get iterator along specified axis
            Iterator<NodeState> nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = (Iterator<NodeState>) new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

            throws RepositoryException, IOException {
        checkOpen();
        final Map aggregateRoots = new HashMap();
        final Set removedNodeIds = new HashSet();
        final Set addedNodeIds = new HashSet();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId nodeId = (NodeId) super.next();
                removedNodeIds.add(nodeId);
                return nodeId.getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
                addedNodeIds.add(state.getNodeId());
                removedNodeIds.remove(state.getNodeId());
                Document doc = null;
                try {
                    doc = createDocument(state, getNamespaceMappings(),
                            index.getIndexFormatVersion());
                    retrieveAggregateRoot(state, aggregateRoots);
                } catch (RepositoryException e) {
                    log.warn("Exception while creating document for node: "
                            + state.getNodeId() + ": " + e.toString());
                }
                return doc;
            }
        });

        // remove any aggregateRoot nodes that are new
        // and therefore already up-to-date
        aggregateRoots.keySet().removeAll(addedNodeIds);

        // based on removed NodeIds get affected aggregate root nodes
        retrieveAggregateRoot(removedNodeIds, aggregateRoots);

        // update aggregates if there are any affected
        if (aggregateRoots.size() > 0) {
            index.update(new AbstractIteratorDecorator(
                    aggregateRoots.keySet().iterator()) {
                public Object next() {
                    return ((NodeId) super.next()).getUUID();
                }
            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                public Object next() {
                    NodeState state = (NodeState) super.next();
                    try {
                        return createDocument(state, getNamespaceMappings(),
                                index.getIndexFormatVersion());
View Full Code Here

            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

            // get iterator along specified axis
            Iterator<NodeState> nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = (Iterator<NodeState>) new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.iterators.AbstractIteratorDecorator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.