xref: /OpenGrok/opengrok-web/src/main/java/org/opengrok/web/DiffData.java (revision 379f387bb45bfdf48c20082e1ed6e0dcd8314c14)
1*379f387bSVladimir Kotal /*
2*379f387bSVladimir Kotal  * CDDL HEADER START
3*379f387bSVladimir Kotal  *
4*379f387bSVladimir Kotal  * The contents of this file are subject to the terms of the
5*379f387bSVladimir Kotal  * Common Development and Distribution License (the "License").
6*379f387bSVladimir Kotal  * You may not use this file except in compliance with the License.
7*379f387bSVladimir Kotal  *
8*379f387bSVladimir Kotal  * See LICENSE.txt included in this distribution for the specific
9*379f387bSVladimir Kotal  * language governing permissions and limitations under the License.
10*379f387bSVladimir Kotal  *
11*379f387bSVladimir Kotal  * When distributing Covered Code, include this CDDL HEADER in each
12*379f387bSVladimir Kotal  * file and include the License file at LICENSE.txt.
13*379f387bSVladimir Kotal  * If applicable, add the following below this CDDL HEADER, with the
14*379f387bSVladimir Kotal  * fields enclosed by brackets "[]" replaced with your own identifying
15*379f387bSVladimir Kotal  * information: Portions Copyright [yyyy] [name of copyright owner]
16*379f387bSVladimir Kotal  *
17*379f387bSVladimir Kotal  * CDDL HEADER END
18*379f387bSVladimir Kotal  */
19*379f387bSVladimir Kotal 
20*379f387bSVladimir Kotal /*
21*379f387bSVladimir Kotal  * Copyright (c) 2009, 2011, Jens Elkner.
22*379f387bSVladimir Kotal  * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
23*379f387bSVladimir Kotal  * Portions Copyright (c) 2020, Chris Fraire <cfraire@me.com>.
24*379f387bSVladimir Kotal  */
25*379f387bSVladimir Kotal package org.opengrok.web;
26*379f387bSVladimir Kotal 
27*379f387bSVladimir Kotal import org.opengrok.indexer.analysis.AbstractAnalyzer;
28*379f387bSVladimir Kotal import org.suigeneris.jrcs.diff.Revision;
29*379f387bSVladimir Kotal 
30*379f387bSVladimir Kotal /**
31*379f387bSVladimir Kotal  * A simple container to store the data required to generate a view of diffs
32*379f387bSVladimir Kotal  * for a certain versioned file.
33*379f387bSVladimir Kotal  *
34*379f387bSVladimir Kotal  * @author  Jens Elkner
35*379f387bSVladimir Kotal  */
36*379f387bSVladimir Kotal public class DiffData {
37*379f387bSVladimir Kotal     /** the directory which contains the given file wrt. to the source root directory. */
38*379f387bSVladimir Kotal     private final String path;
39*379f387bSVladimir Kotal     /** the HTML escaped filename used. */
40*379f387bSVladimir Kotal     private final String filename;
41*379f387bSVladimir Kotal     /** the genre of the requested diff. */
42*379f387bSVladimir Kotal     AbstractAnalyzer.Genre genre;
43*379f387bSVladimir Kotal     /** the original and new revision container. */
44*379f387bSVladimir Kotal     Revision revision;
45*379f387bSVladimir Kotal     /**
46*379f387bSVladimir Kotal      * the URI encoded parameter values of the request. {@code param[0]}
47*379f387bSVladimir Kotal      * belongs to {@code r1}, {@code param[1]} to {@code r2}.
48*379f387bSVladimir Kotal      */
49*379f387bSVladimir Kotal     String[] param;
50*379f387bSVladimir Kotal     /** the revision names extracted from {@link #param}. */
51*379f387bSVladimir Kotal     String[] rev;
52*379f387bSVladimir Kotal     /** the content of the original and new file line-by-line corresponding with {@link #rev}. */
53*379f387bSVladimir Kotal     String[][] file;
54*379f387bSVladimir Kotal     /** error message to show, if diffs are not available. */
55*379f387bSVladimir Kotal     String errorMsg;
56*379f387bSVladimir Kotal     /** If {@code true} a full diff is desired. */
57*379f387bSVladimir Kotal     boolean full;
58*379f387bSVladimir Kotal     /** How should the data be displayed (request parameter {@code format}. */
59*379f387bSVladimir Kotal     DiffType type;
60*379f387bSVladimir Kotal 
DiffData(String path, String filename)61*379f387bSVladimir Kotal     public DiffData(String path, String filename) {
62*379f387bSVladimir Kotal         this.path = path;
63*379f387bSVladimir Kotal         this.filename = filename;
64*379f387bSVladimir Kotal 
65*379f387bSVladimir Kotal         this.rev = new String[2];
66*379f387bSVladimir Kotal         this.file = new String[2][];
67*379f387bSVladimir Kotal         this.param = new String[2];
68*379f387bSVladimir Kotal     }
69*379f387bSVladimir Kotal 
getPath()70*379f387bSVladimir Kotal     public String getPath() {
71*379f387bSVladimir Kotal         return path;
72*379f387bSVladimir Kotal     }
73*379f387bSVladimir Kotal 
getFilename()74*379f387bSVladimir Kotal     public String getFilename() {
75*379f387bSVladimir Kotal         return filename;
76*379f387bSVladimir Kotal     }
77*379f387bSVladimir Kotal 
getGenre()78*379f387bSVladimir Kotal     public AbstractAnalyzer.Genre getGenre() {
79*379f387bSVladimir Kotal         return genre;
80*379f387bSVladimir Kotal     }
81*379f387bSVladimir Kotal 
getRevision()82*379f387bSVladimir Kotal     public Revision getRevision() {
83*379f387bSVladimir Kotal         return revision;
84*379f387bSVladimir Kotal     }
85*379f387bSVladimir Kotal 
getParam(int index)86*379f387bSVladimir Kotal     public String getParam(int index) {
87*379f387bSVladimir Kotal         return param[index];
88*379f387bSVladimir Kotal     }
89*379f387bSVladimir Kotal 
getRev(int index)90*379f387bSVladimir Kotal     public String getRev(int index) {
91*379f387bSVladimir Kotal         return rev[index];
92*379f387bSVladimir Kotal     }
93*379f387bSVladimir Kotal 
getFile(int index)94*379f387bSVladimir Kotal     public String[] getFile(int index) {
95*379f387bSVladimir Kotal         return file[index];
96*379f387bSVladimir Kotal     }
97*379f387bSVladimir Kotal 
getErrorMsg()98*379f387bSVladimir Kotal     public String getErrorMsg() {
99*379f387bSVladimir Kotal         return errorMsg;
100*379f387bSVladimir Kotal     }
101*379f387bSVladimir Kotal 
isFull()102*379f387bSVladimir Kotal     public boolean isFull() {
103*379f387bSVladimir Kotal         return full;
104*379f387bSVladimir Kotal     }
105*379f387bSVladimir Kotal 
getType()106*379f387bSVladimir Kotal     public DiffType getType() {
107*379f387bSVladimir Kotal         return type;
108*379f387bSVladimir Kotal     }
109*379f387bSVladimir Kotal }
110