aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-04-02 18:13:52 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-04-07 17:21:33 +0200
commitb16c02760d933b45d519b2f5c1f4529aac574df5 (patch)
tree7730fc290bcf4f3fe978399d5bda328cf191f687 /sonar-plugin-api/src/main/java
parenta9de737d0e2b6342c55a946665af99a35a7f2cb8 (diff)
downloadsonarqube-b16c02760d933b45d519b2f5c1f4529aac574df5.tar.gz
sonarqube-b16c02760d933b45d519b2f5c1f4529aac574df5.zip
SONAR-6277 Feed file sources in compute report
Diffstat (limited to 'sonar-plugin-api/src/main/java')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java38
1 files changed, 19 insertions, 19 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
index 40a0cb87d89..ea7b38ce9c7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java
@@ -50,18 +50,18 @@ public class FileMetadata implements BatchComponent {
private static final char LINE_FEED = '\n';
private static final char CARRIAGE_RETURN = '\r';
- private abstract static class CharHandler {
+ public abstract static class CharHandler {
- void handleAll(char c) {
+ protected void handleAll(char c) {
}
- void handleIgnoreEoL(char c) {
+ protected void handleIgnoreEoL(char c) {
}
- void newLine() {
+ protected void newLine() {
}
- void eof() {
+ protected void eof() {
}
}
@@ -79,7 +79,7 @@ public class FileMetadata implements BatchComponent {
}
@Override
- void handleAll(char c) {
+ protected void handleAll(char c) {
if (this.lines == 0) {
this.lines = 1;
}
@@ -91,7 +91,7 @@ public class FileMetadata implements BatchComponent {
}
@Override
- void newLine() {
+ protected void newLine() {
lines++;
if (!blankLine) {
nonBlankLines++;
@@ -100,14 +100,14 @@ public class FileMetadata implements BatchComponent {
}
@Override
- void handleIgnoreEoL(char c) {
+ protected void handleIgnoreEoL(char c) {
if (!Character.isWhitespace(c)) {
blankLine = false;
}
}
@Override
- void eof() {
+ protected void eof() {
if (!blankLine) {
nonBlankLines++;
}
@@ -128,19 +128,19 @@ public class FileMetadata implements BatchComponent {
private StringBuilder sb = new StringBuilder();
@Override
- void handleIgnoreEoL(char c) {
+ protected void handleIgnoreEoL(char c) {
sb.append(c);
}
@Override
- void newLine() {
+ protected void newLine() {
sb.append(LINE_FEED);
globalMd5Digest.update(sb.toString().getBytes(Charsets.UTF_8));
sb.setLength(0);
}
@Override
- void eof() {
+ protected void eof() {
if (sb.length() > 0) {
globalMd5Digest.update(sb.toString().getBytes(Charsets.UTF_8));
}
@@ -163,21 +163,21 @@ public class FileMetadata implements BatchComponent {
}
@Override
- void handleIgnoreEoL(char c) {
+ protected void handleIgnoreEoL(char c) {
if (!Character.isWhitespace(c)) {
sb.append(c);
}
}
@Override
- void newLine() {
+ protected void newLine() {
consumer.consume(line, sb.length() > 0 ? lineMd5Digest.digest(sb.toString().getBytes(Charsets.UTF_8)) : null);
sb.setLength(0);
line++;
}
@Override
- void eof() {
+ protected void eof() {
consumer.consume(line, sb.length() > 0 ? lineMd5Digest.digest(sb.toString().getBytes(Charsets.UTF_8)) : null);
}
@@ -193,17 +193,17 @@ public class FileMetadata implements BatchComponent {
}
@Override
- void handleAll(char c) {
+ protected void handleAll(char c) {
currentOriginalOffset++;
}
@Override
- void newLine() {
+ protected void newLine() {
originalLineOffsets.add(currentOriginalOffset);
}
@Override
- void eof() {
+ protected void eof() {
lastValidOffset = currentOriginalOffset;
}
@@ -246,7 +246,7 @@ public class FileMetadata implements BatchComponent {
lineOffsetCounter.getLastValidOffset());
}
- private static void readFile(File file, Charset encoding, CharHandler... handlers) {
+ public static void readFile(File file, Charset encoding, CharHandler... handlers) {
try (BOMInputStream bomIn = new BOMInputStream(new FileInputStream(file),
ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE);
Reader reader = new BufferedReader(new InputStreamReader(bomIn, encoding))) {