File: MayNotEndWithValidator.java

package info (click to toggle)
libsimple-validation-java 0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 640 kB
  • sloc: java: 3,858; xml: 53; sh: 14; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.netbeans.validation.api.builtin.stringvalidation;

import org.netbeans.validation.api.Problems;
import org.netbeans.validation.api.Validator;
import org.openide.util.NbBundle;

/**
 * Does not allow a string to terminate with a particular character
 *
 * @author Tim Boudreau
 */
final class MayNotEndWithValidator extends StringValidator {
    private final char c;
    public MayNotEndWithValidator(char c) {
        this.c = c;
    }

    @Override
    public void validate(Problems problems, String compName, String model) {
        if (model != null && model.charAt(model.length() - 1) == c) {
            problems.add(NbBundle.getMessage(MayNotEndWithValidator.class,
                    "MAY_NOT_END_WITH", compName, new String(new char[] { c })));
        }
    }

}