in scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java [1448:1603]
void storePropertyValue(Object value, DataOutputStream out,
MetaDataWriter metaDataWriter) throws IOException
{
if (value == null)
{
// handle null value as a string
out.writeBoolean(false);
out.writeByte(TypeString);
metaDataWriter.writeString(null, out);
return;
}
Class<?> arrayType = value.getClass().getComponentType();
boolean isArray = arrayType != null;
out.writeBoolean(isArray);
byte valueType = getType(arrayType == null ? value.getClass() : arrayType);
out.writeByte(valueType);
switch (valueType)
{
case TypeBoolean:
if (isArray)
{
boolean[] vArray = (boolean[]) value;
out.writeInt(vArray.length);
for (boolean v : vArray)
{
out.writeBoolean(v);
}
}
else
{
out.writeBoolean((boolean) value);
}
break;
case TypeByte:
if (isArray)
{
byte[] vArray = (byte[]) value;
out.writeInt(vArray.length);
for (byte v : vArray)
{
out.writeByte(v);
}
}
else
{
out.writeByte((byte) value);
}
break;
case TypeChar:
if (isArray)
{
char[] vArray = (char[]) value;
out.writeInt(vArray.length);
for (char v : vArray)
{
out.writeChar(v);
}
}
else
{
out.writeChar((char) value);
}
break;
case TypeDouble:
if (isArray)
{
double[] vArray = (double[]) value;
out.writeInt(vArray.length);
for (double v : vArray)
{
out.writeDouble(v);
}
}
else
{
out.writeDouble((double) value);
}
break;
case TypeFloat:
if (isArray)
{
float[] vArray = (float[]) value;
out.writeInt(vArray.length);
for (float v : vArray)
{
out.writeFloat(v);
}
}
else
{
out.writeFloat((float) value);
}
break;
case TypeInteger:
if (isArray)
{
int[] vArray = (int[]) value;
out.writeInt(vArray.length);
for (int v : vArray)
{
out.writeInt(v);
}
}
else
{
out.writeInt((int) value);
}
break;
case TypeLong:
if (isArray)
{
long[] vArray = (long[]) value;
out.writeInt(vArray.length);
for (long v : vArray)
{
out.writeLong(v);
}
}
else
{
out.writeLong((long) value);
}
break;
case TypeShort:
if (isArray)
{
short[] vArray = (short[]) value;
out.writeInt(vArray.length);
for (short v : vArray)
{
out.writeShort(v);
}
}
else
{
out.writeShort((short) value);
}
break;
case TypeString:
if (isArray)
{
String[] vArray = (String[]) value;
out.writeInt(vArray.length);
for (String v : vArray)
{
metaDataWriter.writeString(v, out);
}
}
else
{
metaDataWriter.writeString((String) value, out);
}
break;
}
}