//That might happen during recovery runs : TODO, investigate
if (owner == null) {
buf.append("(Can't read data, owner is null)");
} else {
try {
final NodeId nodeId = ((NativeBroker)owner).getBrokerPool()
.getNodeFactory().createFromData(dlnLen, page.data, readOffset);
readOffset += nodeId.size();
buf.append("(" + nodeId.toString() + ")");
final short attributes = ByteConversion.byteToShort(page.data, readOffset);
buf.append(" children: " + children);
buf.append(" attributes: " + attributes);
} catch (final Exception e) {
//TODO : more friendly message. Provide the array of bytes ?
buf.append("(Unable to read the node ID at: " + readOffset);
buf.append(" children : " + children);
//Probably a wrong offset so... don't read it
buf.append(" attributes : unknown");
}
}
break;
}
case Node.TEXT_NODE:
case Node.CDATA_SECTION_NODE:
{
if (Signatures.getType(page.data[pos]) == Node.TEXT_NODE)
{buf.append("text ");}
else
{buf.append("CDATA ");}
int readOffset = pos;
readOffset += 1;
final int dlnLen = ByteConversion.byteToShort(page.data, readOffset);
readOffset += NodeId.LENGTH_NODE_ID_UNITS;
//That might happen during recovery runs : TODO, investigate
if (owner == null) {
buf.append("(Can't read data, owner is null)");
} else {
try {
final NodeId nodeId = ((NativeBroker)owner).getBrokerPool()
.getNodeFactory().createFromData(dlnLen, page.data, readOffset);
readOffset += nodeId.size();
buf.append("(" + nodeId.toString() + ")");
final ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write(page.data, readOffset, valueLength - (readOffset - pos));
String value = new String(os.toByteArray(),UTF_8);
if (value.length() > 15) {
value = value.substring(0,8) + "..." + value.substring(value.length() - 8);
}
buf.append(":'" + value + "'");
} catch (final Exception e) {
//TODO : more friendly message. Provide the array of bytes ?
buf.append("(unable to read the node ID at : " + readOffset);
}
}
break;
}
case Node.ATTRIBUTE_NODE:
{
buf.append("[");
buf.append("attribute ");
int readOffset = pos;
final byte idSizeType = (byte) (page.data[readOffset] & 0x3);
final boolean hasNamespace = (page.data[readOffset] & 0x10) == 0x10;
readOffset += 1;
final int dlnLen = ByteConversion.byteToShort(page.data, readOffset);
readOffset += NodeId.LENGTH_NODE_ID_UNITS;
//That might happen during recovery runs : TODO, investigate
if (owner == null) {
buf.append("(can't read data, owner is null)");
} else {
try {
final NodeId nodeId = ((NativeBroker)owner).getBrokerPool()
.getNodeFactory().createFromData(dlnLen, page.data, readOffset);
readOffset += nodeId.size();
buf.append("(" + nodeId.toString() + ")");
readOffset += Signatures.getLength(idSizeType);
if (hasNamespace) {
//Untested
final short NSId = ByteConversion.byteToShort(page.data, readOffset);
readOffset += AttrImpl.LENGTH_NS_ID;