Skip to content

Commit 4240b29

Browse files
committed
BooleanFormatter
1 parent 07ee2ca commit 4240b29

File tree

1 file changed

+29
-1
lines changed
  • com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter

1 file changed

+29
-1
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter/BooleanFormatter.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,33 @@
1919
import com.sun.jdi.Value;
2020
import com.sun.jdi.VirtualMachine;
2121

22+
/**
23+
* Formatter for boolean values in the Java Debug Interface (JDI).
24+
* Implements the IValueFormatter interface to provide string representations
25+
* and value conversions for boolean types.
26+
*/
2227
public class BooleanFormatter implements IValueFormatter {
2328

29+
/**
30+
* Converts a JDI value object into its string representation.
31+
*
32+
* @param value The value to be formatted to string.
33+
* @param options Additional options affecting the format; unused in this formatter.
34+
* @return A string representation of the boolean value, or "null" if the value is null.
35+
*/
2436
@Override
2537
public String toString(Object value, Map<String, Object> options) {
2638
return value == null ? NullObjectFormatter.NULL_STRING : value.toString();
2739
}
2840

41+
/**
42+
* Determines if this formatter is applicable for the given type,
43+
* specifically checking for boolean types.
44+
*
45+
* @param type The JDI type of the object.
46+
* @param options Additional options that might influence the formatting; unused in this formatter.
47+
* @return True if the type is a boolean, false otherwise.
48+
*/
2949
@Override
3050
public boolean acceptType(Type type, Map<String, Object> options) {
3151
if (type == null) {
@@ -35,9 +55,17 @@ public boolean acceptType(Type type, Map<String, Object> options) {
3555
return signature0 == BOOLEAN;
3656
}
3757

58+
/**
59+
* Converts a string representation of a boolean into a JDI Value object.
60+
*
61+
* @param value The string value to convert.
62+
* @param type The expected JDI type; used to fetch the VirtualMachine reference.
63+
* @param options Additional conversion options; unused in this formatter.
64+
* @return A JDI Value representing the boolean state indicated by the input string.
65+
*/
3866
@Override
3967
public Value valueOf(String value, Type type, Map<String, Object> options) {
4068
VirtualMachine vm = type.virtualMachine();
4169
return vm.mirrorOf(Boolean.parseBoolean(value));
4270
}
43-
}
71+
}

0 commit comments

Comments
 (0)