mirror of
https://github.com/Noratrieb/UMLetClassParser.git
synced 2026-01-15 17:15:08 +01:00
added uml parser classes
This commit is contained in:
parent
796e786d00
commit
09b837ca29
8 changed files with 398 additions and 0 deletions
44
src/UMLField.java
Normal file
44
src/UMLField.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
public class UMLField {
|
||||
|
||||
private String dataType;
|
||||
private String name;
|
||||
private String encapsulation;
|
||||
|
||||
private boolean valid;
|
||||
|
||||
public UMLField(String dataType, String name, String encapsulation) {
|
||||
this.dataType = dataType;
|
||||
this.name = name;
|
||||
this.encapsulation = encapsulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* New Field from UML line
|
||||
*
|
||||
* @param line Format: "- name: String"
|
||||
*/
|
||||
public UMLField(String line) {
|
||||
|
||||
String formatted = line.replaceAll("([+\\-~#]) ((?:[a-z]|[A-Z]|[0-1])+): (.*)", "$1;$3;$2");
|
||||
System.out.println(formatted);
|
||||
String[] formattedSplit = formatted.split(";");
|
||||
|
||||
this.encapsulation = switch (formattedSplit[0]) {
|
||||
case "+" -> "public ";
|
||||
case "-" -> "private ";
|
||||
case "#" -> "protected ";
|
||||
case "~" -> "";
|
||||
default -> "[undefined] ";
|
||||
};
|
||||
|
||||
this.name = formattedSplit[2];
|
||||
this.dataType = formattedSplit[1];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return " " + encapsulation + dataType + " " + name + ";\n";
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue