Package nexj.core.util

Examples of nexj.core.util.Binary


      public void setBytes(int nParameterIndex, byte[] data) throws SQLException
      {
         int nOffset = initParam(nParameterIndex);

         m_paramArray[nOffset + PARAM_TYPE] = Primitive.BINARY;
         m_paramArray[nOffset + PARAM_VALUE] = (data == null) ? null : new Binary(data);
      }
View Full Code Here


      try
      {
         write(dos);
         dos.close();

         return new Binary(bos.toByteArray());
      }
      catch (IOException e)
      {
         throw new TypeConversionException(Primitive.ANY, e);
      }
View Full Code Here

      m_oid = new OID(new Object[]{"abc"});
      m_oid2 = new OID(new Object[]{"abc"});
      m_oid3 = new OID(new Object[]{"cde", new Integer(123), new Long(456)});
      m_oid9 = new OID(new Object[]{null, "a", new Integer(123), new Long(567),
         new Double(1.234), new BigDecimal("456.789"), new Date(1234567),
         Boolean.FALSE, new Binary(new byte[]{(byte)134, 45, (byte)173})});
      m_oidBad = new OID(new Object[]{"a", new Float(1), new Object()});
   }
View Full Code Here

      root.setValue("files", entryList);

      entry = new TransferObject(2);
      entry.setValue("fileName", "cat.txt");
      entry.setValue("data", new Binary("This is what should go in CAT.".getBytes("UTF-8")));
      entryList.add(entry);

      entry = new TransferObject(1);
      entry.setValue("fileName", "toy/");
      entryList.add(entry);

      entry = new TransferObject(2);
      entry.setValue("data", new Binary("This file has no name.".getBytes("UTF-8")));
      entry.setValue("comments", "This entry will not be written.");
      entryList.add(entry);

      entry = new TransferObject(3);
      entry.setValue("fileName", "toy/ball.txt");
      entry.setValue("data", new Binary("This is the cat's ball-toy.".getBytes("UTF-8")));
      entry.setValue("comments", "A toy");
      entryList.add(entry);

      // Format and check result
      ByteArrayOutputStream ostream = new ByteArrayOutputStream();
View Full Code Here

   public void testAddIntInstanceInt()
   {
      Instance instance = new Instance(m_metadata.getMetaclass("Address"), m_context);
     
      instance.cache(new OID(new Object[]{new Binary(new byte[]{1})}));
      instance.setValue("city", "c");
      m_list.add(1, instance, m_nFlags);

      assertEquals(3, m_list.size());
      assertEquals("c", m_list.getInstance(1).getValue("city"));

      instance = new Instance(m_metadata.getMetaclass("Address"), m_context);
     
      instance.setNew();
      instance.setOID(new OID(new Object[]{new Binary(new byte[]{2})}));
      instance.setValue("city", "d");
      m_list.add(2, instance, m_nFlags);

      try
      {
View Full Code Here

      contact.setValue("float", Primitive.createFloat(0.625f));
      contact.setValue("double", Primitive.createDouble(1.625));
      contact.setValue("decimal", new BigDecimal("1.2345"));
      contact.setValue("timestamp", new Timestamp(12345));
      contact.setValue("boolean", Boolean.TRUE);
      contact.setValue("binary", new Binary(new byte[]{1, 2, 3, 4, 5}));
      contact.setValue("binary2", new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}));
      contact.setValue("binary3", new Binary(new byte[]{1, 2}));
      contact.setValue("symbol", Symbol.define("sym"));
      contact.setValue("pair", new Pair("A", new Pair("B")));
      contact.setValue("cvector", new char[]{'a', 'b', 'c'});
      contact.setValue("bvector", new byte[]{0, (byte)0xAB, 0x12});
      contact.setValue("svector", new String[]{"a", "b", "c"});
View Full Code Here

      checkEquals(Primitive.createFloat(0.625f), (Number)contact.getValue("float"));
      checkEquals(Primitive.createDouble(1.625), (Number)contact.getValue("double"));
      checkEquals(new BigDecimal("1.2345"), (Number)contact.getValue("decimal"));
      assertEquals(new Timestamp(12345), contact.getValue("timestamp"));
      assertEquals(Boolean.TRUE, contact.getValue("boolean"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5}), contact.getValue("binary"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}), contact.getValue("binary2"));
      assertEquals(new Binary(new byte[]{1, 2}), contact.getValue("binary3"));
      assertEquals("sym", ((Symbol)contact.getValue("symbol")).getName());
      assertSame(Symbol.define("sym"), contact.getValue("symbol"));

      Pair pairA = (Pair)contact.getValue("pair");
      assertEquals("A", pairA.getHead());
View Full Code Here

      assertEquals(new Character('c'), c);

      clear();
      m_marshaller.serialize(new OID(new Object[] { null, "a", Primitive.createInteger(123), Primitive.createLong(567),
               Primitive.createDouble(1.234), new BigDecimal("456.789"), new Date(1234567), Boolean.FALSE,
               new Binary(new byte[] { (byte) 134, 45, (byte) 173 }) }), m_writer);
      assertEquals("{\":OID\":\"wEFhwQAAAHvCAAAAAAAAAjfEP/O+dsi0OViDAAAAAwb4VcUAAAAAABLWh8YDhi2t\"}", m_writer.toString());

      OID oid = (OID) m_unmarshaller.deserialize(new StringReader(m_writer.toString()));
      assertEquals(new OID(new Object[] { null, "a", Primitive.createInteger(123), Primitive.createLong(567), Primitive.createDouble(1.234),
               new BigDecimal("456.789"), new Date(1234567), Boolean.FALSE,
               new Binary(new byte[] { (byte) 134, 45, (byte) 173 }) }), oid);

      clear();
      m_marshaller.serialize(new Pair("A", new Pair(new Pair("B",Symbol.define("C")))), m_writer);
      assertEquals("{\":head\":\"A\",\":tail\":{\":head\":{\":head\":\"B\",\":tail\":{\":symbol\":\"C\"}}}}", m_writer.toString());
View Full Code Here

      assertNotNull(p.getNext().getTail());
      assertNull(p.getNext().getNext().getTail());

      assertEquals("+", ((Pair)m_parser.parse(new StringReader("(+ 1)"), null)).getHead().toString());
      assertEquals("+a", ((Pair)m_parser.parse(new StringReader("(+a 1 2 3)"), null)).getHead().toString());
      assertEquals(new Binary(new byte[]{0x01, 0x23 , 0x45, 0x6a, (byte)0xbc}), v[19]);
      assertEquals(new Timestamp(1068544800000L), v[20]);
      assertEquals(new Timestamp(1068508800000L), v[21]);
      assertEquals(new Timestamp(36000000), v[22]);

      assertTrue(v[23] instanceof byte[]);
View Full Code Here

    * @param sData The string to write.
    * @throws IOException
    */
   public synchronized void writeData(String sData) throws IOException
   {
      writeData(new Binary(sData.getBytes("utf-8")));
   }
View Full Code Here

TOP

Related Classes of nexj.core.util.Binary

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.