class DataMetaDom::PojoLexer::JavaRegExRoster

Augment the class with Java specifics

Public Instance Methods

to_patterns() click to toggle source

converts the registry to the java declarations for the class

# File lib/dataMetaDom/pojo.rb, line 46
        def to_patterns
            i_to_r.keys.map { |ix|
               r = i_to_r[ix]
               rx = r.r.to_s
               %<#{INDENT}private static final java.util.regex.Pattern #{RegExRoster.ixToVarName(ix)} = // #{r.vars.to_a.sort.join(', ')}
#{INDENT*2}java.util.regex.Pattern.compile(#{rx.inspect});>
            }.join("\n\n")
        end
to_verifications() click to toggle source

converts the registry to the verification code for the verify() method

# File lib/dataMetaDom/pojo.rb, line 56
        def to_verifications
            result = (canned.keys.map { |r|
                r = canned[r]
                vs = r.vars.to_a.sort
                vs.map { |v|
                    rx = r.r.to_s
                    %<#{INDENT*2}if(#{r.req? ? '' : "#{v} != null && "}!getCannedRegEx(#{rx.inspect}).matcher(#{v}).matches())
#{INDENT*3}throw new VerificationException("Variable \\"#{v}\\" == {{" + #{v} + "}} didn't match canned expression \\"#{rx}\\"" );>
                }
            }).flatten
            (result << i_to_r.keys.map { |ix|
                r = i_to_r[ix]
                vs = r.vars.to_a.sort
                rv = RegExRoster.ixToVarName(ix)
                vs.map { |v|
                   %<#{INDENT*2}if(#{r.req? ? '' : "#{v} != null && "}!#{rv}.matcher(#{v}).matches())
#{INDENT*3}throw new VerificationException("Variable \\"#{v}\\" == {{" + #{v} + "}} didn't match custom expression {{" + #{rv} + "}}");>
                }
            }).flatten
            result.join("\n")

        end