-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nam-ng/dev
update model and refactor API
- Loading branch information
Showing
17 changed files
with
428 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import org.w3c.dom.Element; | ||
|
||
public class AbstractNode { | ||
private Collection<String> toolchains = new ArrayList<>(); | ||
private Collection<String> boards = new ArrayList<>(); | ||
|
||
protected void parseFilter(String name, Element element) { | ||
switch (name) { | ||
case "toolchain": | ||
addToolchains(element.getTextContent()); | ||
break; | ||
case "board": | ||
addBoard(element.getTextContent()); | ||
break; | ||
default: | ||
return; | ||
} | ||
} | ||
|
||
private void addToolchains(String toolchain) { | ||
toolchains.add(toolchain); | ||
} | ||
|
||
public Collection<String> getToolchains() { | ||
return toolchains; | ||
} | ||
|
||
private void addBoard(String board) { | ||
boards.add(board); | ||
} | ||
|
||
public Collection<String> getBoards() { | ||
return boards; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package model; | ||
|
||
import org.w3c.dom.Element; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
|
||
public class Language extends AbstractNode { | ||
private String id; | ||
|
||
public Language(Element element) { | ||
parseAttribute(element); | ||
NodeList children = element.getChildNodes(); | ||
for (int i = 0; i < children.getLength(); i++) { | ||
Node childNode = children.item(i); | ||
if (childNode.getNodeType() == Node.ELEMENT_NODE) { | ||
Element childElement = (Element) childNode; | ||
String name = childElement.getTagName(); | ||
parseFilter(name, childElement); | ||
} | ||
} | ||
} | ||
|
||
private void parseAttribute(Element element) { | ||
id = element.getAttribute("id"); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package model; | ||
|
||
import org.w3c.dom.Element; | ||
|
||
public class Toolchain { | ||
private String version; | ||
private String name; | ||
|
||
public Toolchain(Element element) { | ||
parseAttribute(element); | ||
name = element.getTextContent(); | ||
} | ||
|
||
private void parseAttribute(Element element) { | ||
version = element.getAttribute("version"); | ||
} | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.