diff --git a/src/Regex.java b/src/Regex.java index b979ddf..49452ce 100644 --- a/src/Regex.java +++ b/src/Regex.java @@ -5,9 +5,30 @@ import java.util.regex.Pattern; */ public abstract class Regex { + /** + * Matches any method in the UML format, including a constructor, encapsulation optional + * + *

Examples:

+ * + * + *

Groups: + *

+ * + */ + public static final Pattern METHOD_FIND_REGEX = Pattern.compile(" *(?[+\\-~#])? *(?\\w+) *\\( *(?(?: *\\w+ *: *[\\w<>]+ *,? *)*) *\\) *(?:: *(?[\\w<>]+))?"); + /** - * Matches any method in the UML format, including a constructor + * Matches any method in the UML format, including a constructor, forces the encapsulation modifier * *

Examples:

*
    @@ -25,10 +46,32 @@ public abstract class Regex { *
* */ - public static final Pattern METHOD_FIND_REGEX = Pattern.compile(" *(?[+\\-~#]) *(?\\w+) *\\( *(?(?: *\\w+ *: *[\\w<>]+ *,? *)*) *\\) *(?:: *(?[\\w<>]+))?"); + public static final Pattern METHOD_FIND_REGEX_FORCE_ENCAPSULATION = Pattern.compile(" *(?[+\\-~#]) *(?\\w+) *\\( *(?(?: *\\w+ *: *[\\w<>]+ *,? *)*) *\\) *(?:: *(?[\\w<>]+))?"); + /** - * Matches any Field in the UML format, including a constructor + * Matches any Field in the UML format, including a constructor, encapsulation optional + *y + *

Examples:

+ *
    + *
  • - age: int
  • + *
  • - name: String
  • + *
  • age: int
  • + *
+ * + *

Groups: + *

    + *
  • 1 The encapsulate modifier (+-~#)
  • + *
  • 2 The name
  • + *
  • 3 The datatype
  • + *
+ * + */ + public static final Pattern FIELD_FIND_REGEX = Pattern.compile(" *(?[+\\-~#])? *(?\\w+) *: *(?[\\w<>]+)"); + + + /** + * Matches any Field in the UML format, including a constructor, forces the encapsulation modifier *y *

Examples:

*
    @@ -45,7 +88,8 @@ public abstract class Regex { *
* */ - public static final Pattern FIELD_FIND_REGEX = Pattern.compile(" *(?[+\\-~#]) *(?\\w+) *: *(?[\\w<>]+)"); + public static final Pattern FIELD_FIND_REGEX_FORCE_ENCAPSULATION = Pattern.compile(" *(?[+\\-~#]) *(?\\w+) *: *(?[\\w<>]+)"); + /** * Matches a single arg in a method @@ -58,17 +102,22 @@ public abstract class Regex { */ public static final Pattern ARG_SPLIT_REGEX = Pattern.compile(" *(\\w+) *: *([\\w<>]+)"); - public static final Pattern FIELD_FIND_REGEX_NO_ENCAPSULATION = Pattern.compile(" *(?[+\\-~#])? *(?\\w+) *: *(?[\\w<>]+)"); - - public static final Pattern METHOD_FIND_REGEX_NO_ENCAPSULATION = Pattern.compile(" *(?[+\\-~#])? *(?\\w+) *\\( *(?(?: *\\w+ *: *[\\w<>]+ *,? *)*) *\\) *(?:: *(?[\\w<>]+))?"); - - - public static String getMethodPattern(boolean encapsulation){ - return encapsulation ? METHOD_FIND_REGEX_NO_ENCAPSULATION.pattern() : METHOD_FIND_REGEX.pattern(); + /** + * Get a method pattern + * @param encapsulationOptional True: Do not force encapsulation, False: Force encapsulation + * @return The pattern as a String + */ + public static String getMethodPattern(boolean encapsulationOptional){ + return encapsulationOptional ? METHOD_FIND_REGEX.pattern() : METHOD_FIND_REGEX_FORCE_ENCAPSULATION.pattern(); } - public static String getFieldPattern(boolean encapsulation){ - return encapsulation ? FIELD_FIND_REGEX_NO_ENCAPSULATION.pattern() : FIELD_FIND_REGEX.pattern(); + /** + * Get a field pattern + * @param encapsulationOptional True: Do not force encapsulation, False: Force encapsulation + * @return The pattern as a String + */ + public static String getFieldPattern(boolean encapsulationOptional){ + return encapsulationOptional ? FIELD_FIND_REGEX.pattern() : FIELD_FIND_REGEX_FORCE_ENCAPSULATION.pattern(); } } diff --git a/src/UMLMethod.java b/src/UMLMethod.java index ffdd628..0a8c542 100644 --- a/src/UMLMethod.java +++ b/src/UMLMethod.java @@ -1,4 +1,5 @@ import java.util.ArrayList; +import java.util.Arrays; /** * Stores all information about a method in a class and converts it into Java code using the {@link #toString()} method @@ -42,7 +43,6 @@ public class UMLMethod { }; } else { this.encapsulation = manager.getDefaultEncapsulation(); - System.out.println(manager.getDefaultEncapsulation()); } this.name = parts[2];