-
Notifications
You must be signed in to change notification settings - Fork 4
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 #3 from JakobGretenkort/main
add capabilities to TraVarT and restructure interfaces
- Loading branch information
Showing
18 changed files
with
669 additions
and
214 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 |
---|---|---|
|
@@ -361,4 +361,4 @@ | |
<property name="optional" value="true"/> | ||
</module> | ||
</module> | ||
</module> | ||
</module> |
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
69 changes: 69 additions & 0 deletions
69
src/main/java/at/jku/cps/travart/core/basic/DefaultPrettyPrinter.java
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,69 @@ | ||
/******************************************************************************* | ||
* This Source Code Form is subject to the terms of the Mozilla | ||
* Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at | ||
* https://mozilla.org/MPL/2.0/. | ||
* | ||
* Contributors: | ||
* @author Jakob Gretenkort | ||
* | ||
* The base interface for obtaining statistical data of a variability artifact. | ||
* | ||
* Copyright 2023 Johannes Kepler University Linz | ||
* LIT Cyber-Physical Systems Lab | ||
* All rights reserved | ||
*******************************************************************************/ | ||
package at.jku.cps.travart.core.basic; | ||
|
||
import java.util.List; | ||
|
||
import at.jku.cps.travart.core.common.IPrettyPrinter; | ||
import at.jku.cps.travart.core.common.ISerializer; | ||
import at.jku.cps.travart.core.exception.NotSupportedVariabilityTypeException; | ||
|
||
/** | ||
* A pretty printer that supports a text-based representation based on the | ||
* serialization provided by an | ||
* {@link at.jku.cps.travart.core.common.ISerializer}. | ||
*/ | ||
public class DefaultPrettyPrinter<T> implements IPrettyPrinter<T> { | ||
private final ISerializer<T> serializer; | ||
|
||
/** | ||
* Creates a default pretty printer. | ||
* | ||
* @param serializer the serializer which will provide the text-based | ||
* representation of this printer. It must use a text-based and human | ||
* readable format. | ||
*/ | ||
public DefaultPrettyPrinter(ISerializer<T> serializer) { | ||
this.serializer = serializer; | ||
} | ||
|
||
@Override | ||
public List<REPRESENTATION> representations() { | ||
return List.of(REPRESENTATION.TEXT); | ||
} | ||
|
||
@Override | ||
public String toText(T model) throws NotSupportedVariabilityTypeException { | ||
if(!serializer.getFormat().isText() || !serializer.getFormat().isHumanReadable()) { | ||
throw new NotSupportedVariabilityTypeException( | ||
"The default pretty printer could not be generated from the given serializer. " + | ||
"The given serializer does not have a human-readable text-based format!" | ||
); | ||
} | ||
return serializer.serialize(model); | ||
} | ||
|
||
@Override | ||
public String[][] toTable(T model) throws NotSupportedVariabilityTypeException { | ||
throw new NotSupportedVariabilityTypeException("The default pretty printer does not support tabular representation for any model."); | ||
} | ||
|
||
@Override | ||
public String toSvg(T model) throws NotSupportedVariabilityTypeException { | ||
throw new NotSupportedVariabilityTypeException("The default pretty printer does not support svg representation for any model."); | ||
} | ||
|
||
} |
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,63 @@ | ||
/******************************************************************************* | ||
* This Source Code Form is subject to the terms of the Mozilla | ||
* Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at | ||
* https://mozilla.org/MPL/2.0/. | ||
* | ||
* Contributors: | ||
* @author Kevin Feichtinger | ||
* @author Prankur Agarwal | ||
* @author Jakob Gretenkort | ||
* | ||
* An implementation of the universal variability language. | ||
* | ||
* Copyright 2023 Johannes Kepler University Linz | ||
* LIT Cyber-Physical Systems Lab | ||
* All rights reserved | ||
*******************************************************************************/ | ||
package at.jku.cps.travart.core.basic; | ||
|
||
import at.jku.cps.travart.core.FeatureModelStatistics; | ||
import at.jku.cps.travart.core.common.IDeserializer; | ||
import at.jku.cps.travart.core.common.ILanguage; | ||
import at.jku.cps.travart.core.common.ISerializer; | ||
import at.jku.cps.travart.core.common.IStatistics; | ||
import at.jku.cps.travart.core.io.UVLDeserializer; | ||
import at.jku.cps.travart.core.io.UVLSerializer; | ||
import de.vill.model.FeatureModel; | ||
|
||
/** | ||
* An implementation of the universal variability language, providing | ||
*/ | ||
public class UVL implements ILanguage<FeatureModel> { | ||
|
||
@Override | ||
public IDeserializer<FeatureModel> getDeserializer() { | ||
return new UVLDeserializer(); | ||
} | ||
|
||
@Override | ||
public IStatistics<FeatureModel> getStatistics() { | ||
return FeatureModelStatistics.getInstance(); | ||
} | ||
|
||
@Override | ||
public ISerializer<FeatureModel> getSerializer() { | ||
return new UVLSerializer(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Universal Variability Language"; | ||
} | ||
|
||
@Override | ||
public String getAbbreviation(){ | ||
return "UVL"; | ||
} | ||
|
||
@Override | ||
public Iterable<String> getSupportedFileExtensions() { | ||
return getDeserializer().fileExtensions(); | ||
} | ||
} |
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
107 changes: 107 additions & 0 deletions
107
src/main/java/at/jku/cps/travart/core/common/Format.java
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,107 @@ | ||
/******************************************************************************* | ||
* This Source Code Form is subject to the terms of the Mozilla | ||
* Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at | ||
* https://mozilla.org/MPL/2.0/. | ||
* | ||
* Contributors: | ||
* @author Jakob Gretenkort | ||
* | ||
* The base interface for obtaining statistical data of a variability artifact. | ||
* | ||
* Copyright 2023 Johannes Kepler University Linz | ||
* LIT Cyber-Physical Systems Lab | ||
* All rights reserved | ||
*******************************************************************************/ | ||
package at.jku.cps.travart.core.common; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* This class represents a data storage or serialization format in which a | ||
* variability model might be represented. | ||
* | ||
* @author Jakob Gretenkort | ||
*/ | ||
public class Format { | ||
private final String name; | ||
private final String extension; | ||
private final boolean isText; | ||
private final boolean isHumanReadable; | ||
|
||
/** | ||
* Create a format. | ||
* | ||
* @param name The name of the format. | ||
* @param extension The file extension used when writing models to | ||
* disk in this format. | ||
* @param isText Whether the format is text-based. | ||
* @param isHumanReadable Whether the format is human readable. | ||
*/ | ||
public Format(String name, String extension, boolean isText, boolean isHumanReadable) { | ||
this.name = name; | ||
this.extension = extension; | ||
this.isText = isText; | ||
this.isHumanReadable = isHumanReadable; | ||
} | ||
|
||
/** | ||
* The name of the format. | ||
* @return the name of the format. | ||
*/ | ||
public String name() { | ||
return name; | ||
} | ||
|
||
/** | ||
* The file extension used when writing models to disk in this format. | ||
* @return the file extension used when writing models to disk in this format. | ||
*/ | ||
public String extension() { | ||
return extension; | ||
} | ||
|
||
/** | ||
* Whether the format is text-based. | ||
* @return whether the format is text-based. | ||
*/ | ||
public boolean isText() { | ||
return isText; | ||
} | ||
|
||
/** | ||
* Whether the format is human readable. | ||
* @return whether the format is human readable. | ||
*/ | ||
public boolean isHumanReadable() { | ||
return isHumanReadable; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, extension, isText, isHumanReadable); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} else if (!(obj instanceof Format)) { | ||
return false; | ||
} else { | ||
Format other = (Format) obj; | ||
return Objects.equals(this.name, other.name) && | ||
Objects.equals(this.extension, other.extension) && | ||
Objects.equals(this.isText, other.isText) && | ||
Objects.equals(this.isHumanReadable, other.isHumanReadable); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Format [name=" + this.name + | ||
"extension=" + this.extension + | ||
"isText=" + this.isText + | ||
"isHumanReadable=" + this.isHumanReadable + "]"; | ||
} | ||
} |
Oops, something went wrong.