Skip to content

Package: AbstractType

AbstractType

nameinstructionbranchcomplexitylinemethod
AbstractType()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
AbstractType(RegEx)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getExpression()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
matches(String)
M: 3 C: 14
82%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 4
67%
M: 0 C: 1
100%
setExpression(RegEx)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package model.type;
2:
3: import dk.brics.automaton.Automaton;
4: import dk.brics.automaton.RegExp;
5:
6: /**
7: * AbstractType.
8: *
9: * @author Erik, Julian und Jannik
10: *
11: */
12: public abstract class AbstractType {
13:         /**
14:          * Represents the regular expression.
15:          */
16:         private RegEx expression;
17:
18:         /**
19:          * Constructor for AbstractVariableType, just sets the field.
20:          */
21:         public AbstractType() {
22:                 this.expression = new RegEx();
23:         }
24:
25:         /**
26:          * Constructor for AbstractVariableType, just sets the field.
27:          *
28:          * @param expression
29:          * The expression to set.
30:          */
31:         AbstractType(final RegEx expression) {
32:                 this.expression = expression;
33:         }
34:
35:         /**
36:          * Return the field expression. No side effects.
37:          *
38:          * @return this.expression
39:          */
40:         public RegEx getExpression() {
41:                 return this.expression;
42:         }
43:
44:         /**
45:          * @param expression
46:          * the expression to set
47:          */
48:         public void setExpression(final RegEx expression) {
49:                 this.expression = expression;
50:         }
51:
52:         /**
53:          * Returns the resolved string of the regexpart, with extensions and withOUT references like
54:          * (RE:LABEL).
55:          *
56:          * @return string
57:          * @throws ReferenceIsUnresolvedException
58:          * If a part is unresolved.
59:          */
60:         public abstract String toStringResolved() throws ReferenceIsUnresolvedException;
61:
62:         /**
63:          * Returns {@code true} if passed value matches this type, else {@code false}.
64:          *
65:          * @param value
66:          * @return
67:          */
68:         public boolean matches(final String value) {
69:                 RegExp completeRegEx;
70:                 try {
71:                         completeRegEx = new RegExp(this.toStringResolved());
72:                 } catch (IllegalArgumentException | ReferenceIsUnresolvedException e) {
73:                         return false;
74:                 }
75:                 final Automaton automatonRegEx = completeRegEx.toAutomaton();
76:                 return automatonRegEx.run(value);
77:         }
78: }