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