Package com.ngt.jopenmetaverse.shared.structureddata

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


    /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
    public OSDMap Serialize()
    {
      OSDMap map = new OSDMap(1);

      OSDArray array = new OSDArray(Simulators.length);
      for (int i = 0; i < Simulators.length; i++)
      {
        SimulatorInfoBlock block = Simulators[i];

        OSDMap blockMap = new OSDMap(3);
        blockMap.put("Handle", OSD.FromULong(block.RegionHandle));
        blockMap.put("IP", MessageUtils.FromIP(block.IP));
        blockMap.put("Port", OSD.FromInteger(block.Port));
        array.add(blockMap);
      }

      map.put("SimulatorInfo", array);
      return map;
    }
View Full Code Here


    /// Deserialize the message
    /// </summary>
    /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
    public void Deserialize(OSDMap map) throws UnknownHostException
    {
      OSDArray array = (OSDArray)map.get("SimulatorInfo");
      Simulators = new SimulatorInfoBlock[array.count()];

      for (int i = 0; i < array.count(); i++)
      {
        OSDMap blockMap = (OSDMap)array.get(i);

        SimulatorInfoBlock block = new SimulatorInfoBlock();
        block.RegionHandle = blockMap.get("Handle").asULong();
        block.IP = MessageUtils.ToIP(blockMap.get("IP"));
        block.Port = blockMap.get("Port").asInteger();
View Full Code Here

      OSDMap alertInfoMap = new OSDMap(2);

      alertInfoMap.put("ExtraParams", OSD.FromString(ExtraParams));
      alertInfoMap.put("Message", OSD.FromString(MessageKey));
      OSDArray alertArray = new OSDArray();
      alertArray.add(alertInfoMap);
      map.put("AlertInfo",  alertArray);

      OSDMap infoMap = new OSDMap(2);
      infoMap.put("AgentID", OSD.FromUUID(AgentID));
      infoMap.put("Reason", OSD.FromString(Reason));
      OSDArray infoArray = new OSDArray();
      infoArray.add(infoMap);
      map.put("Info", infoArray);

      return map;
    }
View Full Code Here

    /// </summary>
    /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
    public void Deserialize(OSDMap map)
    {

      OSDArray alertInfoArray = (OSDArray)map.get("AlertInfo");

      OSDMap alertInfoMap = (OSDMap)alertInfoArray.get(0);
      ExtraParams = alertInfoMap.get("ExtraParams").asString();
      MessageKey = alertInfoMap.get("Message").asString();

      OSDArray infoArray = (OSDArray)map.get("Info");
      OSDMap infoMap = (OSDMap)infoArray.get(0);
      AgentID = infoMap.get("AgentID").asUUID();
      Reason = infoMap.get("Reason").asString();
    }
View Full Code Here

      OSDMap requestDataMap = new OSDMap(3);
      requestDataMap.put("ReportType", OSD.FromUInteger(this.ReportType));
      requestDataMap.put("RequestFlags", OSD.FromUInteger(this.RequestFlags));
      requestDataMap.put("TotalObjectCount", OSD.FromUInteger(this.TotalObjectCount));

      OSDArray requestDatArray = new OSDArray();
      requestDatArray.add(requestDataMap);
      map.put("RequestData", requestDatArray);

      OSDArray reportDataArray = new OSDArray();
      OSDArray dataExtendedArray = new OSDArray();
      for (int i = 0; i < ReportDataBlocks.length; i++)
      {
        OSDMap reportMap = new OSDMap(8);
        reportMap.put("LocationX", OSD.FromReal(ReportDataBlocks[i].Location.X));
        reportMap.put("LocationY", OSD.FromReal(ReportDataBlocks[i].Location.Y));
        reportMap.put("LocationZ", OSD.FromReal(ReportDataBlocks[i].Location.Z));
        reportMap.put("OwnerName", OSD.FromString(ReportDataBlocks[i].OwnerName));
        reportMap.put("Score", OSD.FromReal(ReportDataBlocks[i].Score));
        reportMap.put("TaskID", OSD.FromUUID(ReportDataBlocks[i].TaskID));
        reportMap.put("TaskLocalID", OSD.FromReal(ReportDataBlocks[i].TaskLocalID));
        reportMap.put("TaskName", OSD.FromString(ReportDataBlocks[i].TaskName));
        reportDataArray.add(reportMap);

        OSDMap extendedMap = new OSDMap(2);
        extendedMap.put("MonoScore", OSD.FromReal(ReportDataBlocks[i].MonoScore));
        extendedMap.put("TimeStamp", OSD.FromDate(ReportDataBlocks[i].TimeStamp));
        dataExtendedArray.add(extendedMap);
      }

      map.put("ReportData", reportDataArray);
      map.put("DataExtended", dataExtendedArray);
View Full Code Here

    /// </summary>
    /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
    public void Deserialize(OSDMap map)
    {

      OSDArray requestDataArray = (OSDArray)map.get("RequestData");
      OSDMap requestMap = (OSDMap)requestDataArray.get(0);

      this.ReportType = requestMap.get("ReportType").asUInteger();
      this.RequestFlags = requestMap.get("RequestFlags").asUInteger();
      this.TotalObjectCount = requestMap.get("TotalObjectCount").asUInteger();

      if(TotalObjectCount < 1)
      {
        ReportDataBlocks = new ReportDataBlock[0];
        return;
      }

      OSDArray dataArray = (OSDArray)map.get("ReportData");
      OSDArray dataExtendedArray = (OSDArray)map.get("DataExtended");

      ReportDataBlocks = new ReportDataBlock[dataArray.count()];
      for (int i = 0; i < dataArray.count(); i++)
      {
        OSDMap blockMap = (OSDMap)dataArray.get(i);
        OSDMap extMap = (OSDMap)dataExtendedArray.get(i);
        ReportDataBlock block = new ReportDataBlock();
        block.Location = new Vector3(
            (float)blockMap.get("LocationX").asReal(),
            (float)blockMap.get("LocationY").asReal(),
            (float)blockMap.get("LocationZ").asReal());
View Full Code Here

                        compareOSD(entry.getValue(), tmap.get(entry.getKey()));

                     }                   
                      break;
                  case Array:
                      OSDArray sarray = (OSDArray)source;
                      OSDArray tarray = (OSDArray)target;
                                           
                      for (int i = 0; i < sarray.count(); i++)
                      {
                        Assert.assertNotNull(tarray.get(i));
                        compareOSD(sarray.get(i), tarray.get(i));
                      }
                      break;
              }
          }
View Full Code Here

    @Test
    public void DeserializeArray() throws IOException, OSDException
    {
        OSD llsdEmptyArray = BinaryLLSDOSDParser.DeserializeLLSDBinary(binaryEmptyArray);
        Assert.assertEquals(OSDType.Array, llsdEmptyArray.getType());
        OSDArray llsdEmptyArrayArray = (OSDArray)llsdEmptyArray;
        Assert.assertEquals(0, llsdEmptyArrayArray.count());


        OSD llsdSimpleArray = BinaryLLSDOSDParser.DeserializeLLSDBinary(binarySimpleArray);
        Assert.assertEquals(OSDType.Array, llsdSimpleArray.getType());
        OSDArray llsdArray = (OSDArray)llsdSimpleArray;
        Assert.assertEquals(OSDType.Integer, llsdArray.get(0).getType());
        Assert.assertEquals(0, llsdArray.get(0).asInteger());


        OSD llsdSimpleArrayTwo = BinaryLLSDOSDParser.DeserializeLLSDBinary(binarySimpleArrayTwo);
        Assert.assertEquals(OSDType.Array, llsdSimpleArrayTwo.getType());
        OSDArray llsdArrayTwo = (OSDArray)llsdSimpleArrayTwo;
        Assert.assertEquals(2, llsdArrayTwo.count());

        Assert.assertEquals(OSDType.Integer, llsdArrayTwo.get(0).getType());
        Assert.assertEquals(0, llsdArrayTwo.get(0).asInteger());
        Assert.assertEquals(OSDType.Integer, llsdArrayTwo.get(1).getType());
        Assert.assertEquals(0, llsdArrayTwo.get(1).asInteger());
    }
View Full Code Here

    }

    @Test
    public void SerializeArray() throws Exception
    {
        OSDArray llsdEmptyArray = new OSDArray();
        byte[] binaryEmptyArraySerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdEmptyArray);
        Assert.assertArrayEquals(binaryEmptyArray, binaryEmptyArraySerialized);

        binaryEmptyArraySerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdEmptyArray, false);
        Assert.assertArrayEquals(binaryEmptyArrayValue, binaryEmptyArraySerialized);

        OSDArray llsdSimpleArray = new OSDArray();
        llsdSimpleArray.add(OSD.FromInteger(0));
        byte[] binarySimpleArraySerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleArray);
        Assert.assertArrayEquals(binarySimpleArray, binarySimpleArraySerialized);

        binarySimpleArraySerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleArray, false);
        Assert.assertArrayEquals(binarySimpleArrayValue, binarySimpleArraySerialized);

        OSDArray llsdSimpleArrayTwo = new OSDArray();
        llsdSimpleArrayTwo.add(OSD.FromInteger(0));
        llsdSimpleArrayTwo.add(OSD.FromInteger(0));
        byte[] binarySimpleArrayTwoSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleArrayTwo);
        Assert.assertArrayEquals(binarySimpleArrayTwo, binarySimpleArrayTwoSerialized);

        binarySimpleArrayTwoSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdSimpleArrayTwo, false);
        Assert.assertArrayEquals(binarySimpleArrayTwoValue, binarySimpleArrayTwoSerialized);
View Full Code Here

    @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());
        Assert.assertEquals(2, llsdMap.count());

        OSDArray llsdNestedArray = (OSDArray)llsdMap.get("t0st");
        Assert.assertEquals(OSDType.Array, llsdNestedArray.getType());
        OSDInteger llsdNestedIntOne = (OSDInteger)llsdNestedArray.get(0);
        Assert.assertEquals(OSDType.Integer, llsdNestedIntOne.getType());
        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());
View Full Code Here

TOP

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

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.