From f78b3437d6b0aa91f84fb2c61ddd9a464c46de9c Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Tue, 22 Dec 2015 14:22:25 +0000 Subject: [PATCH] ModelInfo: provide getVarIndex() and getVarName() Default implementation relies on the getVarNames() method git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11079 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/prism/DefaultModelGenerator.java | 14 +++++++++++++- prism/src/prism/ModelInfo.java | 8 +++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/prism/src/prism/DefaultModelGenerator.java b/prism/src/prism/DefaultModelGenerator.java index 02156a0a..64eeda02 100644 --- a/prism/src/prism/DefaultModelGenerator.java +++ b/prism/src/prism/DefaultModelGenerator.java @@ -70,7 +70,19 @@ public abstract class DefaultModelGenerator implements ModelGenerator @Override public abstract List getVarNames(); - + + @Override + public int getVarIndex(String name) + { + return getVarNames().indexOf(name); + } + + @Override + public String getVarName(int i) + { + return getVarNames().get(i); + } + @Override public abstract List getVarTypes(); diff --git a/prism/src/prism/ModelInfo.java b/prism/src/prism/ModelInfo.java index 51015461..c081160a 100644 --- a/prism/src/prism/ModelInfo.java +++ b/prism/src/prism/ModelInfo.java @@ -78,10 +78,16 @@ public interface ModelInfo */ public List getVarTypes(); + /** + * Look up the index of a variable in the model by name. + * Returns -1 if there is no such variable. + */ + public int getVarIndex(String name); + /** * Get the name of the {@code i}th variable in the model. */ - //public String getVarName(int i) throws PrismException; + public String getVarName(int i); /** * Get the type of the {@code i}th variable in the model.