Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.InvalidPathException


            if (segment == null) {
                CheckArg.containsNoNulls(segments, "segments");
            }
            assert segment != null;
            if (segment.isIdentifier()) {
                throw new InvalidPathException(
                                               GraphI18n.unableToCreateRelativePathWithIdentifierSegment.text(segments.toString()));
            }
            segmentsList.add(segment);
        }
        return new BasicPath(segmentsList, false);
View Full Code Here


            if (segment == null) {
                CheckArg.containsNoNulls(segments, "segments");
            }
            assert segment != null;
            if (segment.isIdentifier()) {
                throw new InvalidPathException(
                                               GraphI18n.unableToCreateRelativePathWithIdentifierSegment.text(segments.toString()));
            }
            segmentsList.add(segment);
        }
        if (segmentsList.isEmpty()) return BasicPath.EMPTY_RELATIVE;
View Full Code Here

                        Segment... segments ) {
        CheckArg.isNotNull(parentPath, "parent path");
        if (segments == null || segments.length == 0) return RootPath.INSTANCE;
        if (segments.length == 1 && segments[0] != null) {
            if (parentPath.isIdentifier()) {
                throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath,
                                                                                                        segments.toString()));
            }
            if (segments[0].isIdentifier()) {
                throw new InvalidPathException(
                                               GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath,
                                                                                                                  segments.toString()));
            }
            return new ChildPath(parentPath, segments[0]);
        }

        List<Segment> segmentsList = new ArrayList<Segment>(parentPath.size() + 1);
        segmentsList.addAll(parentPath.getSegmentsList());
        for (Segment segment : segments) {
            if (segment == null) {
                CheckArg.containsNoNulls(segments, "segments");
            }
            assert segment != null;
            if (segment.isIdentifier()) {
                throw new InvalidPathException(
                                               GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath,
                                                                                                                  segments.toString()));
            }
            segmentsList.add(segment);
        }
View Full Code Here

    @Override
    public Path create( Path parentPath,
                        Iterable<Segment> segments ) {
        CheckArg.isNotNull(parentPath, "parent path");
        if (parentPath.isIdentifier()) {
            throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath,
                                                                                                    segments.toString()));
        }

        List<Segment> segmentsList = new LinkedList<Segment>();
        segmentsList.addAll(parentPath.getSegmentsList());
        for (Segment segment : segments) {
            if (segment == null) {
                CheckArg.containsNoNulls(segments, "segments");
            }
            assert segment != null;
            if (segment.isIdentifier()) {
                throw new InvalidPathException(
                                               GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath,
                                                                                                                  segments.toString()));
            }
            segmentsList.add(segment);
        }
View Full Code Here

    public Path create( Path parentPath,
                        String subpath ) {
        CheckArg.isNotNull(parentPath, "parentPath");
        CheckArg.isNotNull(subpath, "subpath");
        if (parentPath.isIdentifier()) {
            throw new InvalidPathException(GraphI18n.unableToCreatePathBasedUponIdentifierPath.text(parentPath, subpath));
        }
        subpath = subpath.trim();
        boolean singleChild = subpath.indexOf(Path.DELIMITER) == -1;
        if (!singleChild && subpath.startsWith("./")) {
            if (subpath.length() == 2) return parentPath; // self reference
            // Remove the leading parent reference and try again to see if single child ...
            subpath = subpath.substring(2);
            singleChild = subpath.indexOf(Path.DELIMITER) == -1;
        }
        if (singleChild) {
            try {
                Path.Segment childSegment = createSegment(subpath);
                if (childSegment.isIdentifier()) {
                    throw new InvalidPathException(GraphI18n.unableToCreatePathUsingIdentifierPathAndAnotherPath.text(parentPath,
                                                                                                                      subpath));
                }
                return new ChildPath(parentPath, childSegment);
            } catch (IllegalArgumentException t) {
                // Catch and eat, letting the slower implementation catch anything ...
View Full Code Here

    @Override
    public Path getCanonicalPath() {
        if (!this.isAbsolute()) {
            String msg = GraphI18n.pathIsNotAbsolute.text(this);
            throw new InvalidPathException(msg);
        }
        if (this.isNormalized()) return this;
        return this.getNormalizedPath();
    }
View Full Code Here

        for (Segment segment : this) {
            if (segment.isSelfReference()) continue;
            if (segment.isParentReference()) {
                if (newSegments.isEmpty()) {
                    if (this.isAbsolute()) {
                        throw new InvalidPathException(CommonI18n.pathCannotBeNormalized.text(this));
                    }
                } else if (!newSegments.getLast().isParentReference()) {
                    newSegments.removeLast();
                    continue;
                }
View Full Code Here

    @Override
    public Path relativeTo( Path startingPath ) {
        CheckArg.isNotNull(startingPath, "to");
        if (!this.isAbsolute()) {
            String msg = GraphI18n.pathIsNotAbsolute.text(this);
            throw new InvalidPathException(msg);
        }
        if (startingPath.isRoot()) {
            // We just want a relative path containing the same segments ...
            return relativeToRoot();
        }
        if (!startingPath.isAbsolute()) {
            String msg = GraphI18n.pathIsNotAbsolute.text(startingPath);
            throw new InvalidPathException(msg);
        }

        // Count the number of segments up to the common ancestor (relative path is what remains) ...
        int lengthOfCommonAncestor = 0;
        Iterator<Segment> thisIter = this.getNormalizedPath().iterator();
View Full Code Here

    @Override
    public Path resolve( Path relativePath ) {
        CheckArg.isNotNull(relativePath, "relative path");
        if (!this.isAbsolute()) {
            String msg = GraphI18n.pathIsNotAbsolute.text(this);
            throw new InvalidPathException(msg);
        }
        if (relativePath.isAbsolute()) {
            String msg = GraphI18n.pathIsNotRelative.text(relativePath);
            throw new InvalidPathException(msg);
        }
        // If the relative path is the self or parent reference ...
        relativePath = relativePath.getNormalizedPath();
        if (relativePath.size() == 1) {
            Segment onlySegment = relativePath.getSegment(0);
View Full Code Here

        CheckArg.isNonNegative(degree, "degree");
        if (degree == 0) {
            return this;
        }
        String msg = GraphI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree));
        throw new InvalidPathException(msg);
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.InvalidPathException

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.