private boolean needsFullMapping()

in oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/impl/NamePathMapperImpl.java [227:284]


    private boolean needsFullMapping(String path) {
        int length = path.length();
        if (length == 0) {
            return true;
        }

        int slash = -1; // index of the last slash in the path
        int colon = -1; // index of the last colon in the path

        switch (path.charAt(0)) {
            case '{': // possibly an expanded name
            case '[': // starts with an identifier
            case '.': // possibly "." or ".."
            case ':': // colon as the first character
                return true;
            case '/':
                if (length == 1) {
                    return false; // the root path
                }
                slash = 0;
                break;
        }

        for (int i = 1; i < length; i++) {
            switch (path.charAt(i)) {
                case '{': // possibly an expanded name
                case '[': // possibly an index
                case ']': // illegal character if not part of index
                case '|': // illegal character
                case '*': // illegal character
                    return true;
                case '.':
                    if (i == slash + 1) {
                        return true; // possibly "." or ".."
                    }
                    break;
                case ':':
                    if (i == slash + 1              // "x/:y"
                            || i == colon + i       // "x::y"
                            || colon > slash        // "x:y:z"
                            || i + 1 == length) {   // "x:"
                        return true;
                    }
                    colon = i;
                    break;
                case '/':
                    if (i == slash + 1              // "x//y"
                            || i == colon + i       // "x:/y"
                            || i + 1 == length) {   // "x/"
                        return true;
                    }
                    slash = i;
                    break;
            }
        }

        return colon != -1 && !nameMapper.getSessionLocalMappings().isEmpty();
    }