osd = OSD.FromBoolean(true);
break;
case trueNotationValueTwo:
matching = BufferCharactersEqual(reader, trueNotationValueTwoFull, 1);
if (matching > 1 && matching < trueNotationValueTwoFull.length)
throw new OSDException("Notation LLSD parsing: True value parsing error:");
osd = OSD.FromBoolean(true);
break;
case trueNotationValueThree:
matching = BufferCharactersEqual(reader, trueNotationValueThreeFull, 1);
if (matching > 1 && matching < trueNotationValueThreeFull.length)
throw new OSDException("Notation LLSD parsing: True value parsing error:");
osd = OSD.FromBoolean(true);
break;
case falseNotationValueOne:
osd = OSD.FromBoolean(false);
break;
case falseNotationValueTwo:
matching = BufferCharactersEqual(reader, falseNotationValueTwoFull, 1);
if (matching > 1 && matching < falseNotationValueTwoFull.length)
throw new OSDException("Notation LLSD parsing: True value parsing error:");
osd = OSD.FromBoolean(false);
break;
case falseNotationValueThree:
matching = BufferCharactersEqual(reader, falseNotationValueThreeFull, 1);
if (matching > 1 && matching < falseNotationValueThreeFull.length)
throw new OSDException("Notation LLSD parsing: True value parsing error:");
osd = OSD.FromBoolean(false);
break;
case integerNotationMarker:
osd = DeserializeLLSDNotationInteger(reader);
break;
case realNotationMarker:
osd = DeserializeLLSDNotationReal(reader);
break;
case uuidNotationMarker:
char[] uuidBuf = new char[36];
if (reader.read(uuidBuf, 0, 36) < 36)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in UUID.");
UUID[] lluuid = new UUID[1];
if (!UUID.TryParse(new String(uuidBuf), lluuid))
throw new OSDException("Notation LLSD parsing: Invalid UUID discovered.");
osd = OSD.FromUUID(lluuid[0]);
break;
case binaryNotationMarker:
byte[] bytes = Utils.EmptyBytes;
reader.mark(2);
int bChar = reader.read();
if (bChar < 0)
{
reader.reset();
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
}
if ((char)bChar == sizeBeginNotationMarker)
{
reader.reset();
throw new OSDException("Notation LLSD parsing: Raw binary encoding not supported.");
}
else if (Character.isDigit((char)bChar))
{
reader.reset();
char[] charsBaseEncoding = new char[2];
if (reader.read(charsBaseEncoding, 0, 2) < 2)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
int baseEncoding[] = new int[1];
if (!Utils.tryParseInt(new String(charsBaseEncoding), baseEncoding))
throw new OSDException("Notation LLSD parsing: Invalid binary encoding base.");
if (baseEncoding[0] == 64)
{
if (reader.read() < 0)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in binary.");
String bytes64 = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
bytes = Utils.decodeBase64String(bytes64);
}
else
{
throw new OSDException("Notation LLSD parsing: Encoding base" + baseEncoding + " + not supported.");
}
}
osd = OSD.FromBinary(bytes);
break;
case StringNotationMarker:
int numChars = GetLengthInBrackets(reader);
if (reader.read() < 0)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in String.");
char[] chars = new char[numChars];
if (reader.read(chars, 0, numChars) < numChars)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in String.");
if (reader.read() < 0)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in String.");
osd = OSD.FromString(new String(chars));
break;
case singleQuotesNotationMarker:
String sOne = GetStringDelimitedBy(reader, singleQuotesNotationMarker);
osd = OSD.FromString(sOne);
break;
case doubleQuotesNotationMarker:
String sTwo = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
osd = OSD.FromString(sTwo);
break;
case uriNotationMarker:
if (reader.read() < 0)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in String.");
String sUri = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
//System.out.println("URI: " + sUri);
URI[] uri = new URI[1];
if(Utils.tryParseUri(sUri, uri))
{
osd = OSD.FromUri(uri[0]);
}
else
throw new OSDException("Notation LLSD parsing: Invalid Uri format detected.");
break;
case dateNotationMarker:
if (reader.read() < 0)
throw new OSDException("Notation LLSD parsing: Unexpected end of stream in date.");
String date = GetStringDelimitedBy(reader, doubleQuotesNotationMarker);
Date dt[] = new Date[1];
if (!Utils.tryParseDate(date, dt))
throw new OSDException("Notation LLSD parsing: Invalid date discovered.");
osd = OSD.FromDate(dt[0]);
break;
case arrayBeginNotationMarker:
osd = DeserializeLLSDNotationArray(reader);
break;
case mapBeginNotationMarker:
osd = DeserializeLLSDNotationMap(reader);
break;
default:
throw new OSDException("Notation LLSD parsing: Unknown type marker '" + (char)character + "'.");
}
return osd;
}