Class NatureHelper
- java.lang.Object
-
- net.ssehub.easy.producer.core.persistence.standard.NatureHelper
-
public class NatureHelper extends java.lang.ObjectThe NatureHelper supports querying and modifying Eclipse nature-like elements without having an Eclipse running.- Author:
- Niko Nowatzki, Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classNatureHelper.ProjectHandlerImplements core functionality accessing the project file.
-
Constructor Summary
Constructors Constructor Description NatureHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddNature(java.io.File project, java.lang.String nature)Adds a nature.private static booleancheckNature(org.w3c.dom.Node node, java.lang.String nature)Checks whether the text content of the givennodematches the givennature.private static booleancontainsNature(org.w3c.dom.NodeList nodes, java.lang.String nature)Check whether the givennatureis represented by at least one node innodes.static booleanhasNature(java.io.File project, java.lang.String... natures)Returns whether at least one of the givennaturesare attached toproject.private static booleanhasNature(NatureHelper.ProjectHandler handler, java.lang.String... natures)Returns whether at least one of the givennaturesare attached to the project represented byhandler.private static voidremoveElements(org.w3c.dom.Node parent, java.lang.String nature)Removes all elements with a given nature (as content).static voidremoveNature(java.io.File project, java.lang.String nature)Remove a nature.
-
-
-
Field Detail
-
FILE_NAME
public static final java.lang.String FILE_NAME
- See Also:
- Constant Field Values
-
dbFactory
private static javax.xml.parsers.DocumentBuilderFactory dbFactory
-
-
Method Detail
-
hasNature
public static boolean hasNature(java.io.File project, java.lang.String... natures) throws java.io.IOExceptionReturns whether at least one of the givennaturesare attached toproject.- Parameters:
project- the folder representing the "Eclipse" projectnatures- natures which should be included in file.- Returns:
trueif the nature is attached toproject,falseelse- Throws:
java.io.IOException- if reading or writing the project file fails
-
hasNature
private static boolean hasNature(NatureHelper.ProjectHandler handler, java.lang.String... natures)
Returns whether at least one of the givennaturesare attached to the project represented byhandler.- Parameters:
handler- the hendler representing the projectnatures- natures which should be included in file.- Returns:
trueif the nature is attached toproject,falseelse
-
checkNature
private static boolean checkNature(org.w3c.dom.Node node, java.lang.String nature)Checks whether the text content of the givennodematches the givennature.- Parameters:
node- the node to be checkednature- the nature to be considered- Returns:
trueif the nature is represented bynode,falseelse
-
containsNature
private static boolean containsNature(org.w3c.dom.NodeList nodes, java.lang.String nature)Check whether the givennatureis represented by at least one node innodes.- Parameters:
nodes- list of nodes to be considerednature- the nature to search for- Returns:
trueif the nature is represented by at least one node innodes,falseelse
-
addNature
public static void addNature(java.io.File project, java.lang.String nature) throws java.io.IOExceptionAdds a nature.- Parameters:
project- the folder representing the "Eclipse" projectnature- String which should be removed.- Throws:
java.io.IOException- if reading or writing the project file fails
-
removeNature
public static void removeNature(java.io.File project, java.lang.String nature) throws java.io.IOExceptionRemove a nature.- Parameters:
project- the folder representing the "Eclipse" projectnature- String which should be removed.- Throws:
java.io.IOException- if reading or writing the project file fails
-
removeElements
private static void removeElements(org.w3c.dom.Node parent, java.lang.String nature)Removes all elements with a given nature (as content).- Parameters:
parent- the parent node to start atnature- the nature as content to be removed
-
-