Skip to content

Commit 379f387

Browse files
author
Vladimir Kotal
authored
DiffData cleanup (#3823)
* adjust javadoc * local variable is not needed * move DiffData and DiffType to org.opengrok.web this allows to reduce field visibility in DiffData * introduce non-default constructor * refactor * adjust javadoc * fix comment * fix comments * fix more Sonar issues * fix nits * remove revision * fix style * add basic diff tests
1 parent 4323bb1 commit 379f387

File tree

6 files changed

+316
-145
lines changed

6 files changed

+316
-145
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private static boolean needsHtmlize(CharSequence q, boolean pre) {
348348
*
349349
* @param urlPrefix prefix to add to each url
350350
* @param path path to crack
351-
* @return HTML markup fro the breadcrumb or the path itself.
351+
* @return HTML markup for the breadcrumb or the path itself.
352352
*
353353
* @see #breadcrumbPath(String, String, char)
354354
*/
@@ -905,9 +905,8 @@ public static void writeHAD(Writer out, String ctxE, String entry, boolean isDir
905905
/**
906906
* Wrapper around UTF-8 URL encoding of a string.
907907
*
908-
* @param q query to be encoded. If {@code null}, an empty string will be
909-
* used instead.
910-
* @return null if fail, otherwise the encoded string
908+
* @param q query to be encoded. If {@code null}, an empty string will be used instead.
909+
* @return null if failed, otherwise the encoded string
911910
* @see URLEncoder#encode(String, String)
912911
*/
913912
public static String URIEncode(String q) {

opengrok-indexer/src/main/java/org/opengrok/indexer/web/DiffData.java renamed to opengrok-web/src/main/java/org/opengrok/web/DiffData.java

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,91 @@
1919

2020
/*
2121
* Copyright (c) 2009, 2011, Jens Elkner.
22-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
22+
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
2323
* Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
2424
*/
25-
package org.opengrok.indexer.web;
25+
package org.opengrok.web;
2626

2727
import org.opengrok.indexer.analysis.AbstractAnalyzer;
2828
import org.suigeneris.jrcs.diff.Revision;
2929

3030
/**
31-
* A simple container to store the data required to generated a view of diffs
31+
* A simple container to store the data required to generate a view of diffs
3232
* for a certain versioned file.
3333
*
3434
* @author Jens Elkner
35-
* @version $Revision$
3635
*/
3736
public class DiffData {
38-
3937
/** the directory which contains the given file wrt. to the source root directory. */
40-
public String path;
38+
private final String path;
4139
/** the HTML escaped filename used. */
42-
public String filename;
40+
private final String filename;
4341
/** the genre of the requested diff. */
44-
public AbstractAnalyzer.Genre genre;
42+
AbstractAnalyzer.Genre genre;
4543
/** the original and new revision container. */
46-
public Revision revision;
47-
/** the URI encoded parameter values of the request. {@code param[0]}
48-
* belongs to {@code r1}, {@code param[1]} to {@code r2}. */
49-
public String[] param;
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;
5050
/** the revision names extracted from {@link #param}. */
51-
public String[] rev;
52-
/** the content of the original and new file line-by-line corresponding
53-
* with {@link #rev}. */
54-
public String[][] file;
51+
String[] rev;
52+
/** the content of the original and new file line-by-line corresponding with {@link #rev}. */
53+
String[][] file;
5554
/** error message to show, if diffs are not available. */
56-
public String errorMsg;
55+
String errorMsg;
5756
/** If {@code true} a full diff is desired. */
58-
public boolean full;
57+
boolean full;
5958
/** How should the data be displayed (request parameter {@code format}. */
60-
public DiffType type;
59+
DiffType type;
60+
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+
70+
public String getPath() {
71+
return path;
72+
}
73+
74+
public String getFilename() {
75+
return filename;
76+
}
77+
78+
public AbstractAnalyzer.Genre getGenre() {
79+
return genre;
80+
}
81+
82+
public Revision getRevision() {
83+
return revision;
84+
}
85+
86+
public String getParam(int index) {
87+
return param[index];
88+
}
89+
90+
public String getRev(int index) {
91+
return rev[index];
92+
}
93+
94+
public String[] getFile(int index) {
95+
return file[index];
96+
}
97+
98+
public String getErrorMsg() {
99+
return errorMsg;
100+
}
101+
102+
public boolean isFull() {
103+
return full;
104+
}
105+
106+
public DiffType getType() {
107+
return type;
108+
}
61109
}

opengrok-indexer/src/main/java/org/opengrok/indexer/web/DiffType.java renamed to opengrok-web/src/main/java/org/opengrok/web/DiffType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
* Copyright (c) 2009, 2011, Jens Elkner.
2222
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2323
*/
24-
package org.opengrok.indexer.web;
24+
package org.opengrok.web;
2525

2626
/**
2727
* Known diff display types.
2828
*
2929
* @author Jens Elkner
30-
* @version $Revision$
3130
*/
3231
public enum DiffType {
3332

0 commit comments

Comments
 (0)