Package commonj.sdo

Examples of commonj.sdo.Sequence


  }
 
  public String getInstanceClassName()
  {
    EStructuralFeature javaClassFeature = JavaPackageImpl.eINSTANCE.getDocumentRoot_JavaClass();
    Sequence anyAttribute = getAnyAttribute();
    int count = anyAttribute.size();
    for (int i = 0; i < count; i++)
    {
      EStructuralFeature eFeature = (EStructuralFeature)anyAttribute.getProperty(i);
      if (eFeature == javaClassFeature)
      {
        return (String)anyAttribute.getValue(i);
      }
    }
    return null;
  }
View Full Code Here


     */
    public void testSequencedType() throws IOException {
        Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote");
        DataObject quote = DataFactory.INSTANCE.create(quoteType);

        Sequence sequence = quote.getSequence();

        sequence.add("\n  ");

        quote.setString("symbol", "fbnt");

        sequence.add("\n  ");

        quote.setString("companyName", "FlyByNightTechnology");

        sequence.add("\n  some text\n  ");

        DataObject child = quote.createDataObject("quotes");
        child.setBigDecimal("price", new BigDecimal("2000.0"));

        sequence.add("\n  more text\n  ");

        // quote.setBigDecimal("price", new BigDecimal("1000.0"));
        sequence.add("price", new BigDecimal("1000.0"));

        sequence.add("\n");

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "mixedStockQuote", baos);

        assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
View Full Code Here

   
    DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote");

    assertTrue(quote.getType().isSequenced());
   
    Sequence sequence = quote.getSequence();

    sequence.add("\n  ");

    quote.setString("symbol", "fbnt");

    sequence.add("\n  ");

    quote.setString("companyName", "FlyByNightTechnology");

    sequence.add("\n  some text\n  ");

    DataObject child = quote.createDataObject("quotes");
    child.setBigDecimal("price", new BigDecimal("2000.0"));

    sequence.add("\n  more text\n  ");

    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
    sequence.add("price", new BigDecimal("1000.0"));

    sequence.add("\n");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos);
    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML)));
  }
View Full Code Here

   
    DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");

    assertTrue(quote.getType().isSequenced());
   
    Sequence sequence = quote.getSequence();

    sequence.add("\n  ");

    Type definedGlobalType = types.getType("http://www.example.com/open", null);
   
    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
    quote.setString(definedSymbolProperty, "fbnt");

    sequence.add("\n  ");

    quote.setString("companyName", "FlyByNightTechnology");

    sequence.add("\n  some text\n  ");

    DataObject child = quote.createDataObject("quotes");
    child.setBigDecimal("price", new BigDecimal("2000.0"));

    sequence.add("\n  more text\n  ");

    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
    sequence.add("price", new BigDecimal("1000.0"));

    sequence.add("\n");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos);
    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML)));
  }
View Full Code Here

       
        Type t = ((DataObject)quote).getType();
        List ps = t.getProperties();


        Sequence sequence = quote.getMixed();

        sequence.add("\n  ");

        quote.setSymbol("fbnt");

        sequence.add("\n  ");

        quote.setCompanyName("FlyByNightTechnology");

        sequence.add("\n  some text\n  ");

        List quotes = quote.getQuotes();
        MixedQuote child = SequencesFactory.INSTANCE.createMixedQuote();
        quotes.add(child);
       
        child.setPrice(new BigDecimal("2000.0"));

        sequence.add("\n  more text\n  ");

        sequence.add("price", new BigDecimal("1000.0"));

        sequence.add("\n");
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLHelper.INSTANCE.save((DataObject)quote, TEST_NAMESPACE, "mixedStockQuote", baos);
        assertTrue(baos.toString(), TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MQ_TEST_DATA)));
    }
View Full Code Here

      bs.add(new Integer(2));
    

     
    
      Sequence group = rc.getGroup();
      assertEquals(group.size(), 4);
      assertEquals(rc.getA().size(), 2);
      assertEquals(rc.getB().size(),2);
     
      assertEquals(group.getValue(0), new Integer(1));
      assertEquals(group.getValue(1), "foo");
      assertEquals(group.getValue(2), "bar");
      assertEquals(group.getValue(3), new Integer(2));
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
      XMLHelper.INSTANCE.save((DataObject)rc, TEST_NAMESPACE, "rc", baos);
      assertTrue(baos.toString(), TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(RC_TEST_DATA)));
    }
View Full Code Here

      List bs = mrc.getB();
     

      bs.add(new Integer(1));
      as.add("foo");
      Sequence mixed = mrc.getMixed();
      mixed.add("some mixed text");
      as.add("bar");
      bs.add(new Integer(2));
     
      // FIXME reintroduce check
      // assertEquals(4, mrc.getGroup().size());
      assertEquals(5, mrc.getMixed().size());
      assertEquals(2, mrc.getA().size());
      assertEquals(2, mrc.getB().size(),2);
     
     
      
      assertEquals(mixed.getValue(0), new Integer(1));
      assertEquals(mixed.getValue(1), "foo");
      assertEquals(mixed.getValue(3), "bar");
      assertEquals(mixed.getValue(4), new Integer(2));
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
     
      XMLHelper.INSTANCE.save((DataObject)mrc, TEST_NAMESPACE, "mrc", baos);
View Full Code Here

      as.add("bar");
      bs.add(new Integer(2));
      rc2.setSplit("banana");
    
    
      Sequence group = rc2.getGroup();
      assertEquals(group.size(), 4);
      assertEquals(rc2.getA().size(), 2);
      assertEquals(rc2.getB().size(),2);
     
      Sequence group1 = rc2.getGroup1();
      assertEquals(group1.size(), 2);
      assertEquals(rc2.getY().size(), 1);
      assertEquals(rc2.getZ().size(),1);
     
      assertEquals(group.getValue(0), new Integer(1));
      assertEquals(group.getValue(1), "foo");
      assertEquals(group.getValue(2), "bar");
      assertEquals(group.getValue(3), new Integer(2));
      assertEquals(group1.getValue(0), new Integer(99));
      assertEquals(group1.getValue(1), "fred");
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
     

      XMLHelper.INSTANCE.save((DataObject)rc2, TEST_NAMESPACE, "rc2", baos);
      assertTrue(baos.toString(), TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(RC2_TEST_DATA)));
View Full Code Here

     
      List as = rc2m.getA();
      List bs = rc2m.getB();
      List ys = rc2m.getY();
      List zs = rc2m.getZ();
      Sequence mixed = rc2m.getMixed();
     
      bs.add(new Integer(1));
      mixed.add("where will this appear?");
      as.add("foo");
      as.add("bar");
      bs.add(new Integer(2));
      rc2m.setSplit("pea");
      zs.add(new Integer(99));
      ys.add("fred");

   
      assertEquals(8, mixed.size());
     
      Sequence group = rc2m.getGroup();
      // FIXME reintroduce test assertEquals(4, group.size());
      assertEquals(rc2m.getA().size(), 2);
      assertEquals(rc2m.getB().size(),2);
     
      Sequence group1 = rc2m.getGroup1();
      // FIXME ditto assertEquals(group1.size(), 2);
      assertEquals(rc2m.getY().size(), 1);
      assertEquals(rc2m.getZ().size(),1);
     
      int i = 0;
View Full Code Here

          lineBreak();
        }

      }
      decrementIndent();
      Sequence seq = dataObject.getSequence();

      commentary(
          "The Property/Value pairs of a Sequence can be accessed via the getProperty(int) and getValue(int)\n"
              + "accessor methods of the Sequence interface.  The size() method of the Sequence tells us how many there are.\n"
              + "If the getProperty(int) method retunes null,  then the value is text.  These text values may be encountered\n"
              + "when the DataObject's type is 'mixed' (dataObject.getType().isMixed() == true). A typical example of this\n"
              + "is when the data graph represents a form letter.",
     
          "Inspecting the Property/Value pairs of another Sequence");
     
      incrementIndent();
      indent();
      buf.append("Sequence: {\n");
     
      incrementIndent();
      for (int i = 0; i < seq.size(); i++) {
        Property p = seq.getProperty(i);
        if (p == null) {
          indent();
          buf.append("text: ").append(seq.getValue(i));
          lineBreak();
        } else if(!xsdHelper.isAttribute(p)){
          printPropertyValuePair(p, seq.getValue(i));
       }
      }
      decrementIndent();
     
      indent();
View Full Code Here

TOP

Related Classes of commonj.sdo.Sequence

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.