public void diff()

in vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/VltFile.java [268:324]


    public void diff() throws VltException {
        State state = getStatus();
        if (entry == null || entry.isDirectory()) {
            return;
        }
        VltEntryInfo work = entry.work();
        VltEntryInfo base = entry.base();
        if (work == null || base == null) {
            return;
        }
        switch (state) {
            case ADDED:
            case CONFLICTED:
            case DELETED:
            case MODIFIED:
                break;
            case IGNORED:
            case MISSING:
            case OBSTRUCTED:
            case REPLACED:
            case UNKNOWN:
            case VOID:
            case CLEAN:
                return;
        }
        if (MimeTypes.isBinary(work.getContentType()) || MimeTypes.isBinary(base.getContentType())) {
            PrintStream s = parent.getContext().getStdout();
            s.printf(Locale.ENGLISH, "Index: %s%n", getName());
            s.println("===================================================================");
            s.println("Cannot display: file marked as binary type.");
            s.printf(Locale.ENGLISH, "vlt:mime-type = %s%n", work.getContentType());
            s.flush();
            return;
        }
        try {
            // do the actual diff
            PrintStream s = parent.getContext().getStdout();
            DiffWriter out = new DiffWriter(new OutputStreamWriter(s, Constants.ENCODING));
            out.write("Index: ");
            out.write(getName());
            out.writeNewLine();
            out.write("===================================================================");
            out.writeNewLine();

            try (Reader r0 = getBaseFile(false) == null ? null : getBaseFile(false).getReader();
                 Reader r1 = file.exists() ? new InputStreamReader(FileUtils.openInputStream(file), Constants.ENCODING) : null) {
                Document d0 = new Document(this, LineElementsFactory.create(this, r0, false));
                Document d1 = new Document(this, LineElementsFactory.create(this, r1, false));
                DocumentDiff diff = d0.diff(d1);
                diff.write(out, 3);
            }
            out.flush();
        } catch (IOException e) {
            throw exception("Error while writing diff.", e);
        }

    }