View Javadoc
1   /*
2   VariableDeclarationUsageDistance
3   allowedDistance = (default)3
4   ignoreVariablePattern = (default)
5   validateBetweenScopes = true
6   ignoreFinal = false
7   
8   
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance;
12  
13  import com.google.common.base.Preconditions;
14  
15  import java.io.IOException;
16  import java.io.OutputStream;
17  
18  public class InputVariableDeclarationUsageDistance3 {
19       private void encodeLine(
20           byte[] data, int offset, int length, OutputStream out)
21           throws IOException {
22           out.write((byte) ((length & 0x3F) + ' '));
23           byte a;
24           byte b;
25           byte c;
26  
27           for (int i = 0; i < length;) {
28               b = 1;
29               c = 1;
30               a = data[offset + i++];
31               if (i < length) {
32                   b = data[offset + i++];
33                   if (i < length) {
34                       c = data[offset + i++];
35                   }
36               }
37  
38               byte d1 = (byte) (((a >>> 2) & 0x3F) + ' ');
39               byte d2 = (byte) ((((a << 4) & 0x30) | ((b >>> 4) & 0x0F)) + ' ');
40               byte d3 = (byte) ((((b << 2) & 0x3C) | ((c >>> 6) & 0x3)) + ' ');
41               byte d4 = (byte) ((c & 0x3F) + ' ');
42  
43               out.write(d1);
44               out.write(d2);
45               out.write(d3);
46               out.write(d4);
47           }
48           out.write('\n');
49       }
50  
51      public void test() {
52            char char1 = 0;
53            Tester tester = new Tester();
54            Preconditions.checkNotNull(char1);
55            Preconditions.checkNotNull(tester.hasId());
56            Preconditions.checkNotNull(tester.hasId(), "Must have ID!");
57            Preconditions.checkNotNull(tester.hasId(), "Must have %s!", "ID");
58      }
59  }
60  
61  class Tester2 { }
62  
63  class Tester {
64      public Object hasId() {
65          return null;
66      }
67  }