Package org.exoplatform.xml.object

Examples of org.exoplatform.xml.object.XMLObject


   }

   public void testConvert() throws Exception
   {
      String projectdir = System.getProperty("basedir");
      XMLObject xmlobj = new XMLObject(new TestObject());
      String xml1 = new String(xmlobj.toByteArray("UTF-8"));
      FileOutputStream os = new FileOutputStream(projectdir + "/target/test-object-1.xml");
      os.write(xml1.getBytes());
      os.close();

      File file = new File(projectdir + "/target/test-object-1.xml");
      FileInputStream is = new FileInputStream(file);

      FileChannel fchan = is.getChannel();
      ByteBuffer buff = ByteBuffer.allocate((int)file.length());
      fchan.read(buff);
      buff.rewind();
      byte[] data = buff.array();
      buff.clear();
      fchan.close();
      is.close();

      TestObject tobject = (TestObject)XMLObject.getObject(new ByteArrayInputStream(data));
      assertTrue(tobject.nested.intarray.length == 10);
      os = new FileOutputStream(projectdir + "/target/test-object-2.xml");
      xmlobj = new XMLObject(tobject);
      String xml2 = new String(xmlobj.toByteArray("UTF-8"));
      os.write(xml2.getBytes());
      os.close();
      assertTrue(xml1.equals(xml2));
      is.close();
View Full Code Here


   public XMLObject getXMLObject() throws Exception
   {
      if (object == null)
         return null;
      return new XMLObject(object);
   }
View Full Code Here

   public XMLObject getXMLObject() throws Exception
   {
      if (object == null)
         return null;
      return new XMLObject(object);
   }
View Full Code Here

   }

   public void testConvert() throws Exception
   {
      String projectdir = System.getProperty("basedir");
      XMLObject xmlobj = new XMLObject(new TestObject());
      String xml1 = new String(xmlobj.toByteArray("UTF-8"));
      FileOutputStream os = new FileOutputStream(projectdir + "/target/test-object-1.xml");
      os.write(xml1.getBytes());
      os.close();

      File file = new File(projectdir + "/target/test-object-1.xml");
      FileInputStream is = new FileInputStream(file);

      FileChannel fchan = is.getChannel();
      ByteBuffer buff = ByteBuffer.allocate((int)file.length());
      fchan.read(buff);
      buff.rewind();
      byte[] data = buff.array();
      buff.clear();
      fchan.close();
      is.close();

      TestObject tobject = (TestObject)XMLObject.getObject(new ByteArrayInputStream(data));
      assertTrue(tobject.nested.intarray.length == 10);
      os = new FileOutputStream(projectdir + "/target/test-object-2.xml");
      xmlobj = new XMLObject(tobject);
      String xml2 = new String(xmlobj.toByteArray("UTF-8"));
      os.write(xml2.getBytes());
      os.close();
      assertTrue(xml1.equals(xml2));
      is.close();
View Full Code Here

      throws Exception
   {
      Configuration config = getConfiguration("collection-configuration.xml", profiles);
      Component a = config.getComponent(InitParamsHolder.class.getName());
      ObjectParameter op = a.getInitParams().getObjectParam("test.configuration");
      XMLObject o = op.getXMLObject();
      XMLField xf = o.getField("role");
      return xf.getCollection();
   }
View Full Code Here

      throws Exception
   {
      Configuration config = getConfiguration("field-configuration.xml", profiles);
      Component a = config.getComponent(InitParamsHolder.class.getName());
      ObjectParameter op = a.getInitParams().getObjectParam("test.configuration");
      XMLObject o = op.getXMLObject();
      XMLField xf = o.getField("role");
      return xf.getCollection();
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.xml.object.XMLObject

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.