Package com.ngt.jopenmetaverse.shared.structureddata

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSDString


  {
    OSD theSD = null;
    OSDMap map = null;
    OSD tempSD = null;
    OSDUUID tempUUID = null;
    OSDString tempStr = null;
    OSDReal tempReal = null;

    String testSD = "<?xml version='1.0' encoding='UTF-8'?> \n" +
        "<llsd> \n" +
        "<map> \n" +
        "<key>region_id</key> \n" +
        "<uuid>67153d5b-3659-afb4-8510-adda2c034649</uuid> \n" +
        "<key>scale</key> \n" +
        "<string>one minute</string> \n" +
        "<key>simulator statistics</key> \n" +
        "<map> \n" +
        "<key>time dilation</key> \n" +
        "<real>0.9878624</real> \n" +
        "<key>sim fps</key> \n" +
        "<real>44.38898</real> \n" +
        "<key>agent updates per second</key> \n" +
        "<real>nan</real> \n" +
        "<key>total task count</key> \n" +
        "<real>4</real> \n" +
        "<key>active task count</key> \n" +
        "<real>0</real> \n" +
        "<key>pending uploads</key> \n" +
        "<real>0.0001096525</real> \n" +
        "</map> \n" +
        "</map> \n" +
        "</llsd>";

    //Deserialize the string
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =XmlLLSDOSDParser.DeserializeLLSDXml(bytes);

    //Confirm the contents
    Assert.assertNotNull(theSD);
    Assert.assertTrue(theSD instanceof OSDMap);
    System.out.println(theSD.getType().toString());
    Assert.assertTrue(theSD.getType() == OSDType.Map);
    map = (OSDMap)theSD;

    tempSD = map.get("region_id");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDUUID);
    Assert.assertTrue(tempSD.getType() == OSDType.UUID);
    tempUUID = (OSDUUID)tempSD;
    Assert.assertEquals(new UUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.asUUID());

    tempSD = map.get("scale");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDString);
    Assert.assertTrue(tempSD.getType() == OSDType.String);
    tempStr = (OSDString)tempSD;
    Assert.assertEquals("one minute", tempStr.asString());

    tempSD = map.get("simulator statistics");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDMap);
    Assert.assertTrue(tempSD.getType() == OSDType.Map);
View Full Code Here


  @Test
  public void DeserializeStrings()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDString tempStr = null;

    String testSD = "<?xml version='1.0' encoding='UTF-8'?> \n" +
        "<llsd> \n" +
        "<array> \n" +
        "<string>Kissling</string> \n" +
        "<string>Attack ships on fire off the shoulder of Orion</string> \n" +
        "<string>&lt; &gt; &amp; &apos; &quot;</string> \n" +
        "<string/> \n" +
        "</array> \n" +
        "</llsd>";
    //Deserialize the string
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =XmlLLSDOSDParser.DeserializeLLSDXml(bytes);

    Assert.assertTrue(theSD instanceof OSDArray);
    array = (OSDArray)theSD;

    Assert.assertEquals(OSDType.String, array.get(0).getType());
    tempStr = (OSDString)array.get(0);
    Assert.assertEquals("Kissling", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(1).getType());
    tempStr = (OSDString)array.get(1);
    Assert.assertEquals("Attack ships on fire off the shoulder of Orion", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(2).getType());
    tempStr = (OSDString)array.get(2);
    Assert.assertEquals("< > & \' \"", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(3).getType());
    tempStr = (OSDString)array.get(3);
    Assert.assertEquals("", tempStr.asString());

  }
View Full Code Here

        Assert.assertEquals(1, llsdNestedIntOne.asInteger());
        OSDInteger llsdNestedIntTwo = (OSDInteger)llsdNestedArray.get(1);
        Assert.assertEquals(OSDType.Integer, llsdNestedIntTwo.getType());
        Assert.assertEquals(2, llsdNestedIntTwo.asInteger());

        OSDString llsdString = (OSDString)llsdMap.get("test");
        Assert.assertEquals(OSDType.String, llsdString.getType());
        Assert.assertEquals("what", llsdString.asString());

        OSDInteger llsdIntOne = (OSDInteger)llsdArray.get(1);
        Assert.assertEquals(OSDType.Integer, llsdIntOne.getType());
        Assert.assertEquals(124, llsdIntOne.asInteger());
        OSDInteger llsdIntTwo = (OSDInteger)llsdArray.get(2);
View Full Code Here

  {
    OSD theSD = null;
    OSDMap map = null;
    OSD tempSD = null;
    OSDUUID tempUUID = null;
    OSDString tempStr = null;
    OSDReal tempReal = null;

    String testSD = "[ \n" +
        "{ \n" +
        "\"region_id\": \"67153d5b-3659-afb4-8510-adda2c034649\", \n" +
        "\"scale\": \"one minute\", \n" +
        "\"simulator statistics\": { \n" +
        "\"time dilation\": 0.9878624, \n" +
        "\"sim fps\": 44.38898, \n" +
//        "\"agent updates per second\": NaN, \n" +
        "\"total task count\": 4.0, \n" +
        "\"active task count\": 0.0, \n" +
        "\"pending uploads\": 0.0001096525 \n" +
        "}\n" +
        "}\n" +
        "]";

    //Deserialize the string
    System.out.println(testSD);
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =JsonLLSDOSDParser.DeserializeLLSDJson(bytes);

    //Confirm the contents
    Assert.assertNotNull(theSD);
    Assert.assertTrue(theSD instanceof OSDMap);
    System.out.println(theSD.getType().toString());
    Assert.assertTrue(theSD.getType() == OSDType.Map);
    map = (OSDMap)theSD;

    tempSD = map.get("region_id");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDUUID);
    Assert.assertTrue(tempSD.getType() == OSDType.UUID);
    tempUUID = (OSDUUID)tempSD;
    Assert.assertEquals(new UUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.asUUID());

    tempSD = map.get("scale");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDString);
    Assert.assertTrue(tempSD.getType() == OSDType.String);
    tempStr = (OSDString)tempSD;
    Assert.assertEquals("one minute", tempStr.asString());

    tempSD = map.get("simulator statistics");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDMap);
    Assert.assertTrue(tempSD.getType() == OSDType.Map);
View Full Code Here

  @Test
  public void DeserializeStrings()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDString tempStr = null;

    String testSD = "[ \n" +
        "[ \n" +
        "\"Kissling\", \n" +
        "\"Attack ships on fire off the shoulder of Orion\", \n" +
        "\"&lt; &gt; &amp; &apos; &quot;\", \n" +
        "\"\", \n" +
        "\"    \" \n" +
        "] \n" +
        "]";
    //Deserialize the string
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =JsonLLSDOSDParser.DeserializeLLSDJson(bytes);

    Assert.assertTrue(theSD instanceof OSDArray);
    array = (OSDArray)theSD;

    Assert.assertEquals(OSDType.String, array.get(0).getType());
    tempStr = (OSDString)array.get(0);
    Assert.assertEquals("Kissling", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(1).getType());
    tempStr = (OSDString)array.get(1);
    Assert.assertEquals("Attack ships on fire off the shoulder of Orion", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(2).getType());
    tempStr = (OSDString)array.get(2);
    Assert.assertEquals("&lt; &gt; &amp; &apos; &quot;", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(3).getType());
    tempStr = (OSDString)array.get(3);
    Assert.assertEquals("", tempStr.asString());

    Assert.assertEquals(OSDType.String, array.get(4).getType());
    tempStr = (OSDString)array.get(4);
    Assert.assertEquals("    ", tempStr.asString());
   
  }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.structureddata.OSDString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.