// Copyright (C) 2011 jOVAL.org.  All rights reserved.
// This software is licensed under the AGPL 3.0 license available at http://www.joval.org/agpl_v3.txt

package org.joval.os.windows.registry;

import org.joval.intf.windows.registry.IKey;
import org.joval.intf.windows.registry.IMultiStringValue;

/**
 * Representation of a Windows registry multi-string value.
 *
 * @author David A. Solin
 * @version %I% %G%
 */
public class MultiStringValue extends Value implements IMultiStringValue {
    String[] data;

    public MultiStringValue(IKey parent, String name, String[] data) {
	type = Type.REG_MULTI_SZ;
	this.parent = parent;
	this.name = name;
	this.data = data;
    }

    public String[] getData() {
	return data;
    }

    public String toString() {
	StringBuffer sb = new StringBuffer("MultiStringValue [Name=\"").append(name).append("\" Value={");
	for (int i=0; i < data.length; i++) {
	    if (i > 0) {
		sb.append(", ");
	    }
	    sb.append("\"").append(data[i]).append("\"");
	}
	sb.append("}]");
	return sb.toString();
    }
}

@@ -885,15 +885,98 @@
 lue=
-%7B
 %22);%0D%0A%09
+if (data == null) %7B%0D%0A%09    sb.append(%22null%22);%0D%0A%09%7D else %7B%0D%0A%09    sb.append(%22%7B%22);%0D%0A%09    
 for 
@@ -1011,20 +1011,17 @@
 ++) %7B%0D%0A%09
-    
+%09
 if (i %3E 
@@ -1028,16 +1028,20 @@
 0) %7B%0D%0A%09%09
+    
 sb.appen
@@ -1055,20 +1055,14 @@
 ;%0D%0A%09
-    %7D%0D%0A%09    
+%09%7D%0D%0A%09%09
 sb.a
@@ -1105,16 +1105,46 @@
 %5C%22%22);%0D%0A%09
+    %7D%0D%0A%09    sb.append(%22%7D%22);%0D%0A%09
 %7D%0D%0A%09sb.a
@@ -1150,17 +1150,16 @@
 append(%22
-%7D
 %5D%22);%0D%0A%09r

Handle REG_MULTI_SZ.toString when there the value is null (i.e., raw data is a single \0, not a double \0\0).