Examples of OSD


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

  }

  public InventoryFolder[] ParseInventorySkeleton(String key, OSDMap reply)
  {
    List<InventoryFolder> folders = new ArrayList<InventoryFolder>();
    OSD skeleton = reply.get(key);
    if (skeleton != null && skeleton.getType() == OSDType.Array)
    {
      OSDArray array = (OSDArray)skeleton;
      for (int i = 0; i < array.count(); i++)
      {
        if (array.get(i).getType().equals(OSDType.Map))
View Full Code Here

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

    public static OSD FromIP(InetAddress address)
    {
        if (address != null && address.isAnyLocalAddress())
            return OSD.FromBinary(address.getAddress());
        else
            return new OSD();
    }
View Full Code Here

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

          {
        @Override
        public void handleEvent(Observable o,
            CapsHttpRequestCompletedArg arg) {
          CapsHttpClient client = arg.getClient();
          OSD result = arg.getResult();
          Exception error = arg.getError();

          try
          {
            if (error != null) throw error;
View Full Code Here

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

        Assert.assertArrayEquals(binarySimpleMap, binarySimpleMapSerialized);

        OSDMap llsdSimpleMapTwo = new OSDMap();
        llsdSimpleMapTwo.put("t0st", OSD.FromInteger(241));
        llsdSimpleMapTwo.put("tes1", OSD.FromString("aha"));
        llsdSimpleMapTwo.put("test", new OSD());
        byte[] binarySimpleMapTwoSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleMapTwo);

        // We dont compare here to the original serialized value, because, as maps dont preserve order,
        // the original serialized value is not *exactly* the same. Instead we compare to a deserialized
        // version created by this deserializer.
        OSDMap llsdSimpleMapDeserialized = (OSDMap)BinaryLLSDOSDParser.DeserializeLLSDBinary(binarySimpleMapTwoSerialized);
        Assert.assertEquals(OSDType.Map, llsdSimpleMapDeserialized.getType());
        Assert.assertEquals(3, llsdSimpleMapDeserialized.count());
        Assert.assertEquals(OSDType.Integer, llsdSimpleMapDeserialized.get("t0st").getType());
        Assert.assertEquals(241, llsdSimpleMapDeserialized.get("t0st").asInteger());
        Assert.assertEquals(OSDType.String, llsdSimpleMapDeserialized.get("tes1").getType());
        Assert.assertEquals("aha", llsdSimpleMapDeserialized.get("tes1").asString());
        Assert.assertEquals(OSDType.Unknown, llsdSimpleMapDeserialized.get("test").getType());

        // we also test for a 4byte key character.
        String xml = "<x>&#x10137;</x>";       
        byte[] bytes = xml.getBytes(Charset.forName("UTF8"));
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(new ByteArrayInputStream(bytes));
        Element rootNode = doc.getDocumentElement();
        rootNode.normalize();
      
        String content = rootNode.getChildNodes().item(0).getNodeValue();
       
        OSDMap llsdSimpleMapThree = new OSDMap();
        OSD llsdSimpleValue = OSD.FromString(content);
        llsdSimpleMapThree.put(content, llsdSimpleValue);
        Assert.assertEquals(content, llsdSimpleMapThree.get(content).asString());

        byte[] binarySimpleMapThree = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleMapThree);
        OSDMap llsdSimpleMapThreeDS = (OSDMap)BinaryLLSDOSDParser.DeserializeLLSDBinary(binarySimpleMapThree);
View Full Code Here

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

    private static byte[] binaryNested = (byte[])mergeArrays(binaryHead, binaryNestedValue);

    @Test
    public void DeserializeNestedComposite() throws IOException, OSDException
    {
        OSD llsdNested = BinaryLLSDOSDParser.DeserializeLLSDBinary(binaryNested);
        Assert.assertEquals(OSDType.Array, llsdNested.getType());
        OSDArray llsdArray = (OSDArray)llsdNested;
        Assert.assertEquals(3, llsdArray.count());

        OSDMap llsdMap = (OSDMap)llsdArray.get(0);
        Assert.assertEquals(OSDType.Map, llsdMap.getType());
View Full Code Here

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

    {
        // each 80 chars
        String sOne = "asdklfjasadlfkjaerotiudfgjkhsdklgjhsdklfghasdfklhjasdfkjhasdfkljahsdfjklaasdfkj8";
        String sTwo = "asdfkjlaaweoiugsdfjkhsdfg,.mnasdgfkljhrtuiohfglökajsdfoiwghjkdlaaaaseldkfjgheus9";
       
        OSD stringOne = OSD.FromString( sOne );
        OSD stringTwo = OSD.FromString(sTwo);

        OSDMap llsdMap = new OSDMap();
        llsdMap.put("testOne", stringOne);
        llsdMap.put("testTwo", stringTwo);
        llsdMap.put("testThree", stringOne);
View Full Code Here

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

        "</map> \n" +
        "</map> \n" +
        "</llsd>";
   
    byte[] bytes = Utils.stringToBytes(testSD);
    OSD sourceSD =XmlLLSDOSDParser.DeserializeLLSDXml(bytes);
   
    String targetSSD = XmlLLSDOSDParser.SerializeLLSDXmlString(sourceSD);
    System.out.println(targetSSD);
    bytes = Utils.stringToBytes(targetSSD);
    OSD targetSD =XmlLLSDOSDParser.DeserializeLLSDXml(targetSSD);
    TestHelper.compareOSD(sourceSD, targetSD);
  }
View Full Code Here

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

  }
 
  @Test
  public void DeserializeLLSDSample()
  {
    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);
    map = (OSDMap)tempSD;

    tempSD = map.get("time dilation");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;

    Assert.assertEquals(0.9878624d, tempReal.asReal(), 0);
    //TODO - figure out any relevant rounding variability for 64 bit reals
    tempSD = map.get("sim fps");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;
    Assert.assertEquals(44.38898d, tempReal.asReal(), 0);

    tempSD = map.get("agent updates per second");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;
    Assert.assertEquals(Double.NaN, tempSD.asReal(), 0);

    tempSD = map.get("total task count");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;
    Assert.assertEquals(4.0d, tempReal.asReal(), 0);

    tempSD = map.get("active task count");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;
    Assert.assertEquals(0.0d, tempReal.asReal(), 0);

    tempSD = map.get("pending uploads");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDReal);
    Assert.assertTrue(tempSD.getType() == OSDType.Real);
    tempReal = (OSDReal)tempSD;
    Assert.assertEquals(0.0001096525d, tempReal.asReal(), 0);

  }
View Full Code Here

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

  /// Test that various Real representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeReals()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDReal tempReal = null;

    String testSD = "<?xml version='1.0' encoding='UTF-8'?> \n" +
        "<llsd> \n" +
View Full Code Here

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

  /// Test that various String representations are parsed correctly.
  /// </summary>
  @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" +
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.