Package commonj.sdo

Examples of commonj.sdo.Sequence


        }
   
    if (newProperty.getType().isDataType()) {
        // Setting xmlElement to FALSE only makes sense here
        Boolean isXmlElement = Boolean.TRUE;    // By default, a SDO property is an XSD element
        Sequence anyAttr = modeledProperty.getAnyAttribute();
        for (int i=0; i<anyAttr.size(); i++) {
            Property anyProp = anyAttr.getProperty(i);
            if (XMLFactoryImpl.NAMESPACE_URI.equals(anyProp.getContainingType().getURI())) {
                String propName = anyProp.getName();
                if ("xmlElement".equals(propName)) {
                    isXmlElement = (Boolean)anyAttr.getValue(i);
                }
            }
        }
        if (!isXmlElement.booleanValue()) {
            SDOUtil.setPropertyXMLKind(newProperty, false);
View Full Code Here


                attributeList.add(new NameValuePair(XSI_TYPE_QNAME, typeQName));
            }
        }
       
        if (type.isSequenced()) {
            Sequence sequence = dataObject.getSequence();
            for (int i = 0; i < sequence.size(); i++) {
                Property property = sequence.getProperty(i);
                Object value = sequence.getValue(i);
                if (property == null) {
                    // property == null for text in mixed content
                    elementList.add(new NameValuePair(ELEMENT_TEXT, value));
                } else {
                    addProperty(property, value, elementList);
View Full Code Here

                }
            }
        }
       
        if (type.isSequenced()) {
            Sequence sequence = dataObject.getSequence();
            for (int i = 0; i < sequence.size(); i++) {
                Property property = sequence.getProperty(i);
                Object value = sequence.getValue(i);
                if (property == null) {
                    // property == null for text in mixed content
                    elementList.add(new NameValuePair(ELEMENT_TEXT, value));
                } else {
                    addProperty(property, value, elementList);
View Full Code Here

        open = xsdHelper.getGlobalProperty("testNS", "open", true);
    }

    public void testSequenced() {
        DataObject dataObject = hc.getDataFactory().create(type);
        Sequence sequence = dataObject.getSequence();
       
        sequence.add(choiceX, "x1");
        sequence.add(0, localA, "a");
        sequence.add(choiceY, "y1");
        sequence.add(choiceX, "x2");
        sequence.add(localB, "b");
        sequence.add(open, "open");
       
        List list = dataObject.getList(localA);
        assertEquals(list.size(), 1);
        assertEquals(list.get(0), "a");
View Full Code Here

    XMLHelper xmlHelper = hc.getXMLHelper();
    DataObject loadedObject =
        xmlHelper.load(getClass().getResourceAsStream("/substitutionValues1.xml")).getRootObject();
    Type type = loadedObject.getType();
    Sequence groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead"));
    assertNotNull(groupHeadSubstitutionValues);
    assertNull(SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("nonGroupHead")));
   
    String nsURI = "http://www.apache.org/tuscany/SubstitutionValues";
    DataObject createdObject = hc.getDataFactory().create(nsURI, "TestObject");
    Property groupMemberProperty = xsdHelper.getGlobalProperty(nsURI, "groupMember", true);
    createdObject.set(groupMemberProperty, groupHeadSubstitutionValues.getValue(0));
    createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead"));
  
    assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject));
   
    ByteArrayOutputStream loadedBaos = new ByteArrayOutputStream();
    xmlHelper.save(loadedObject, nsURI, "testObject", loadedBaos);
    ByteArrayOutputStream createdBaos = new ByteArrayOutputStream();
    xmlHelper.save(createdObject, nsURI, "testObject", createdBaos);
    assertTrue(
        TestUtil.equalXmlFiles(
            new ByteArrayInputStream(loadedBaos.toByteArray()),
            new ByteArrayInputStream(createdBaos.toByteArray())));
   
    loadedObject =
      xmlHelper.load(getClass().getResourceAsStream("/substitutionValues2.xml")).getRootObject();
    groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead"));
   
    createdObject = hc.getDataFactory().create(nsURI, "TestObject");
    createdObject.set("groupHead", groupHeadSubstitutionValues.getValue(0));
    createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead"));
   
    assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject));
  }
View Full Code Here

    {
      //FB TODO figure out what helper to use
      javaClassFeature = (EStructuralFeature)TypeHelper.INSTANCE.getOpenContentProperty("commonj.sdo/java", "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

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

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

    sequence.addText("\n  ");

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

    sequence.addText("\n  ");

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

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

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

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

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

    sequence.addText("\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.addText("\n  ");

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

    sequence.addText("\n  ");

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

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

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

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

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

    sequence.addText("\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

     * @param dataObj3
     */
    private void sequenceSingleValueOneMember(final DataObject dataObj1) {
        assertTrue("DataObject is not Sequenced.  Test case may not proceed.", dataObj1.getType().isSequenced());
       
        final Sequence sequence = dataObj1.getSequence();

        sequence.add("Contain", dataObj1);
    }
View Full Code Here

     * @param dataObj3
     */
    private void sequenceSingleValueNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) {
        assertTrue("DataObject is not Sequenced.  Test case may not proceed.", dataObj1.getType().isSequenced());

        final Sequence sequence1 = dataObj1.getSequence();
        final Sequence sequence2 = dataObj2.getSequence();
        final Sequence sequence3 = dataObj3.getSequence();

        sequence1.add("Contain", (Object) dataObj2);
        sequence2.add("Contain", (Object) dataObj3);

        sequence3.add("Contain", (Object) dataObj1);
    }
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.