• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nulab / zxcvbn4j / #141

pending completion
#141

push

github-actions

web-flow
Merge pull request #135 from manchilop/master

Added feedback messages translated into Spanish

1392 of 1507 relevant lines covered (92.37%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/src/main/java/com/nulabinc/zxcvbn/matchers/KeyboardLoader.java
1
package com.nulabinc.zxcvbn.matchers;
2

3
import com.nulabinc.zxcvbn.io.Resource;
4

5
import java.io.BufferedReader;
6
import java.io.IOException;
7
import java.io.InputStream;
8
import java.io.InputStreamReader;
9

10
public abstract class KeyboardLoader {
11

12
    private final String name;
13

14
    private final Resource resource;
15

16
    public KeyboardLoader(final String name, final Resource resource) {
1✔
17
        this.name = name;
1✔
18
        this.resource = resource;
1✔
19
    }
1✔
20

21
    public Keyboard load() throws IOException {
22
        InputStream inputStream = resource.getInputStream();
1✔
23
        String layout = loadAsString(inputStream);
1✔
24
        return new Keyboard(name, buildAdjacentGraphBuilder(layout));
1✔
25
    }
26

27
    protected abstract Keyboard.AdjacentGraphBuilder buildAdjacentGraphBuilder(final String layout);
28

29
    private static String loadAsString(final InputStream input) {
30
        try (final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"))) {
1✔
31
            final StringBuilder sb = new StringBuilder(1024 * 4);
1✔
32
            String str;
33
            while ((str = reader.readLine()) != null) {
1✔
34
                sb.append(str);
1✔
35
                sb.append('\n');
1✔
36
            }
37
            return sb.toString();
1✔
38
        } catch (final IOException e) {
×
39
            throw new IllegalArgumentException(e);
×
40
        }
41
    }
42

43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc