aboutsummaryrefslogtreecommitdiffstats
path: root/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend')
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend35
1 files changed, 0 insertions, 35 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend
deleted file mode 100644
index ba3d39e6..00000000
--- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend
+++ /dev/null
@@ -1,35 +0,0 @@
1package hu.bme.mit.inf.dslreasoner.faulttree.components.conversion
2
3import org.eclipse.xtext.conversion.ValueConverterException
4import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter
5import org.eclipse.xtext.nodemodel.INode
6
7class OF_INTValueConverter extends AbstractLexerBasedConverter<Integer> {
8 static val PREFIX = "of"
9
10 override toValue(String string, INode node) throws ValueConverterException {
11 if (string === null) {
12 return null
13 }
14 if (string.length < PREFIX.length || string.substring(0, PREFIX.length) != PREFIX) {
15 throw new ValueConverterException("'" + string + "' must start with the characters 'of'.", node, null);
16 }
17 try {
18 val intValue = Integer.parseInt(string.substring(PREFIX.length), 10)
19 Integer.valueOf(intValue)
20 } catch (NumberFormatException e) {
21 throw new ValueConverterException("Couldn't convert '" + string + "' to an int value.", node, e);
22 }
23 }
24
25 override protected toEscapedString(Integer value) {
26 PREFIX + value
27 }
28
29 override protected assertValidValue(Integer value) {
30 super.assertValidValue(value)
31 if (value < 0) {
32 throw new ValueConverterException(getRuleName() + " may not be negative.", null, null);
33 }
34 }
35}