Package: CollectionVdmType

CollectionVdmType

nameinstructionbranchcomplexitylinemethod
CollectionVdmType(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
buildDetailString(IVariable)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
formatDetails(IVdmValue)
M: 55 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
formatValue(IVdmValue)
M: 36 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getCloseBrace()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getOpenBrace()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isAtomic()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isCollection()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.debug
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.debug.core.model;
23:
24: import org.eclipse.debug.core.DebugException;
25: import org.eclipse.debug.core.model.IVariable;
26:
27: public class CollectionVdmType extends AtomicVdmType
28: {
29:
30:         protected CollectionVdmType(String name)
31:         {
32:                 super(name);
33:         }
34:
35:         public boolean isAtomic()
36:         {
37:                 return false;
38:         }
39:
40:         public boolean isCollection()
41:         {
42:                 return true;
43:         }
44:
45:         public String formatDetails(IVdmValue value)
46:         {
47:                 final StringBuffer sb = new StringBuffer();
48:                 try
49:                 {
50:                         IVariable[] variables2 = value.getVariables();
51:•                        if (variables2.length > 0)
52:                         {
53:                                 sb.append(getOpenBrace());
54:•                                for (int i = 0; i < variables2.length; i++)
55:                                 {
56:                                         String details = buildDetailString(variables2[i]);
57:                                         sb.append(details);
58:                                         sb.append(","); //$NON-NLS-1$
59:                                 }
60:                                 sb.setLength(sb.length() - 1);
61:                                 sb.append(getCloseBrace());
62:                         }
63:                 } catch (DebugException ex)
64:                 {
65:                         ex.printStackTrace();
66:                 }
67:
68:                 return sb.toString();
69:         }
70:
71:         public String formatValue(IVdmValue value)
72:         {
73:                 StringBuffer sb = new StringBuffer();
74:
75:                 sb.append(getName());
76:
77:                 try
78:                 {
79:                         sb.append("[" + value.getVariables().length + "]"); //$NON-NLS-1$ //$NON-NLS-2$
80:                 } catch (DebugException e)
81:                 {
82:                         sb.append("[]"); //$NON-NLS-1$
83:                 }
84:
85:                 appendInstanceId(value, sb);
86:
87:                 return sb.toString();
88:         }
89:
90:         /**
91:          * Build the detail string for the given variable.
92:          * <p>
93:          * Default implementation just returns the value of the specified variable. Subclasses may override if they wish to
94:          * return something different. For example, a hash collection may wish to return key/value pairs.
95:          * </p>
96:          */
97:         protected String buildDetailString(IVariable variable)
98:                         throws DebugException
99:         {
100:                 return variable.getValue().getValueString();
101:         }
102:
103:         /**
104:          * Returns the brace that will be used to close the collection.
105:          * <p>
106:          * Default implementation returns <code>[</code>. Subclasses may override if they wish to use something different.
107:          * </p>
108:          */
109:         protected char getCloseBrace()
110:         {
111:                 return ']';
112:         }
113:
114:         /**
115:          * Returns the brace that will be used to close the collection.
116:          * <p>
117:          * Default implementation returns <code>]</code>. Subclasses may override if they wish to use something different.
118:          * </p>
119:          */
120:         protected char getOpenBrace()
121:         {
122:                 return '[';
123:         }
124:
125: }