Code example for Pattern

Methods: split

0
 
    static final Pattern pattern = Pattern.compile(":");
 
 
    public LocalTransactionId(final String key) {
        final String[] tmps = pattern.split(key);
        if (tmps.length != 3) {
            throw new IllegalArgumentException("Illegal transaction key:" + key);
        } 
        assert tmps[0].equals("TX");
        this.sessionId = tmps[1];
        this.value = Integer.parseInt(tmps[2]);
 
    } 
 
 
    public LocalTransactionId(final String sessionId, final long transactionId) {
        this.sessionId = sessionId;
        this.value = transactionId;
    } 
Experience pair programming with AI  Get Codota for Java