Package org.jboss.dna.graph.property

Examples of org.jboss.dna.graph.property.Path

This class simplifies working with paths and using a Path is often more efficient that processing and manipulating the equivalent String. This class can easily {@link #iterator() iterate} over the segments, returnthe {@link #size() number of segments}, {@link #compareTo(Path) compare} with other paths, {@link #resolve(Path) resolve}relative paths, return the {@link #getParent() ancestor (or parent)}, determine whether one path is an {@link #isAncestorOf(Path) ancestor} or {@link #isDecendantOf(Path) decendent} of another path, and{@link #getCommonAncestor(Path) finding a common ancestor}.


        assert projection != null;
        if (projection.getRules().size() != 1) return null;
        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        List<Path> topLevelPaths = projection.getRules().get(0).getTopLevelPathsInRepository(pathFactory);
        if (topLevelPaths.size() != 1) return null;
        Path topLevelPath = topLevelPaths.get(0);
        assert topLevelPath != null;
        if (topLevelPath.isRoot()) return null;
        return new OffsetMirrorProjector(context, projections, topLevelPath);
    }
View Full Code Here


                                  boolean requiresUpdate ) {
        PlaceholderNode placeholder = isPlaceholder(location);
        if (placeholder != null) return placeholder;

        // Find the location of the desired node ...
        Path path = location.getPath();
        if (path == null) {
            // There are only identification properties, so return a ProxyNode for each source/workspace ...
            ProjectedNode result = null;
            for (Projection projection : projections) {
                if (requiresUpdate && projection.isReadOnly()) continue;
View Full Code Here

                                  boolean requiresUpdate ) {
        if (requiresUpdate && projection.isReadOnly()) return null;
        PlaceholderNode placeholder = isPlaceholder(location);
        if (placeholder != null) return placeholder;

        Path path = location.getPath();
        Location locationInSource = location;
        if (path != null) {
            if (path.size() == offsetSize) {
                // Make sure the path is the same ...
                if (path.equals(offset)) {
                    locationInSource = location.with(context.getValueFactories().getPathFactory().createRootPath());
                } else {
                    return null; // not in the path
                }
            } else {
                // Make sure the path begins with the offset ...
                if (path.isAtOrBelow(offset)) {
                    locationInSource = location.with(path.subpath(offsetSize));
                } else {
                    // Not in the path
                    return null;
                }
            }
View Full Code Here

        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        List<Path> firstTopLevelPaths = first.getRules().get(0).getTopLevelPathsInRepository(pathFactory);
        if (firstTopLevelPaths.size() != 1) return null;
        List<Path> secondTopLevelPaths = second.getRules().get(0).getTopLevelPathsInRepository(pathFactory);
        if (secondTopLevelPaths.size() != 1) return null;
        Path firstTopLevelPath = firstTopLevelPaths.get(0);
        Path secondTopLevelPath = secondTopLevelPaths.get(0);
        if (firstTopLevelPath.isRoot()) {
            // We're good, so create the instance ...
            return new BranchedMirrorProjector(context, projections, first, second, secondTopLevelPath,
                                               secondRule.getPathInSource(secondTopLevelPath, pathFactory));
        }
        // the second top-level path must be a root ...
        if (!secondTopLevelPath.isRoot()) return null;
        // We're good, so create the instance ...
        return new BranchedMirrorProjector(context, projections, second, first, firstTopLevelPath,
                                           firstRule.getPathInSource(firstTopLevelPath, pathFactory));
    }
View Full Code Here

    public ProjectedNode project( ExecutionContext context,
                                  Location location,
                                  boolean requiresUpdate ) {
        assert location != null;
        if (location.hasPath()) {
            Path path = location.getPath();
            if (path.isRoot()) {
                // It is a projection of the mirror's root and the placeholder for the branch root ...
                if (requiresUpdate && mirrorProjection.isReadOnly()) return null;
                ProxyNode result = new ProxyNode(mirrorProjection, location, location.with(branchSourcePath),
                                                 branchSourceUsesSamePath);
                result.add(isPlaceholder(location));
View Full Code Here

        // Otherwise it is within the brach ...
        Location locationInSource = location;
        if (!branchSourceUsesSamePath) {
            // The source uses a different path ...
            if (federIter.hasNext()) {
                Path subpath = federatedPath.subpath(branchFederatedPath.size());
                Path sourcePath = context.getValueFactories().getPathFactory().create(branchSourcePath, subpath);
                locationInSource = location.with(sourcePath);
            } else {
                locationInSource = location.with(branchSourcePath);
            }
        }
View Full Code Here

                throw new IllegalArgumentException(GraphI18n.pathIsNotAbsolute.text(path));
            }
        }

        public Node getNode( String pathStr ) {
            Path path = createPath(pathStr);
            checkIsAbsolute(path);
            return nodes.get(path);
        }
View Full Code Here

                public boolean hasNext() {
                    return pathIter.hasNext();
                }

                public Node next() {
                    Path nextPath = pathIter.next();
                    return getNode(nextPath);
                }

                public void remove() {
                    throw new UnsupportedOperationException();
View Full Code Here

     *
     * @param location the location of the node; may not be null
     * @return the placeholder node, or null if the supplied location does not designate a placeholder node
     */
    public PlaceholderNode isPlaceholder( Location location ) {
        Path path = location.getPath();
        if (path != null) {
            return placeholderNodesByPath.get(path);
        }
        UUID uuid = location.getUuid();
        if (uuid != null) {
View Full Code Here

                }
                // Walk up the in-repository path to create the placeholder nodes ...
                ProjectedNode child = previous;
                while (!path.isRoot()) {
                    // Create a projected node for the parent of this path ...
                    Path parent = path.getParent();
                    PlaceholderNode parentPlaceholder = placeholdersByPath.get(parent);
                    if (parentPlaceholder == null) {
                        // Need to create the placeholder ...
                        Map<Name, Property> properties = Collections.emptyMap();
                        Location location = Location.create(parent, UUID.randomUUID());
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.property.Path

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.