WebSphere Enterprise Service Bus, 버전 6.2.0 운영 체제: AIX, HP-UX, i5/OS, Linux, Solaris, Windows


중첩 비즈니스 오브젝트의 다중 인스턴스 작성

setWithCreate 기능을 사용하여 중첩 비즈니스 오브젝트의 다중 인스턴스를 작성하십시오.

시작하기 전에

아래 예제 XSD 파일은 맨 위(상위) 비즈니스 오브젝트의 한 레벨(하위) 및 두 레벨(하위의 하위) 아래에 중첩 오브젝트를 포함합니다.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:complexType name="Parent">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="child" type="Child" maxOccurs="5"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="Child">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="grandChild" type="GrandChild"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="GrandChild">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  
</xsd:schema>
상위 오브젝트는 maxOccurs 값에 지정된 대로 최대 5개의 하위 오브젝트를 포함할 수 있습니다.

이 태스크 정보

배열의 누락된 순서에 대해 허용하지 않는 더 엄격한 정책에 따라 목록을 작성할 수 있습니다. setWithGet 메소드를 사용함과 동시에 특정 목록 색인 항목에 표시되는 데이터를 지정할 수 있습니다.
DataObject parent = ...
parent.setString("child[3]/grandchild/name", "Bob");
이 경우 결과 배열의 크기는 3이지만 child[1]child[2] 목록 색인 항목의 값은 정의되지 않습니다. 항목은 널값이 되거나 연관된 데이터 값을 가질 수도 있습니다. 위 시나리오에서는 처음 두 개의 배열 색인 항목 값이 정의되지 않아서 예외가 처리됩니다.
목록의 색인에 값을 정의하여 이 상황을 개선할 수 있습니다. 색인 항목이 배열의 기존 요소를 나타내는 경우, 해당 요소가 널이 아니면(데이터를 포함함) 사용됩니다. 널이면 요소가 작성되고 사용됩니다. 목록의 색인이 목록의 크기보다 더 큰 값이면 새 값이 작성되고 추가됩니다. 다음 예제 코드는 크기가 2인 목록에서 어떤 일이 일어나는지를 보여줍니다. 여기서, child[1]은 널로 지정되어 있고 child[2]는 데이터를 포함합니다.
DataObject parent = ...
// child[1] = null
// child[2] = existing Child
// This code will work because child[1] is null and will be created.
parent.setString("child[1]/grandchild/name", "Bob");

// This code will work because child[2] exists and will be used.
parent.setString("child[2]/grandchild/name", "Dan");

// This code will work because the child list is of size 2, and adding
// one more list item will increase the list size.
parent.setString("child[3]/grandchild/name", "Sam");

결과

두 개의 기존 항목 값을 대체하고 목록 색인에 세 번째 항목을 추가했습니다. 그러나 크기가 4가 아니거나 maxOccurs에 지정된 크기보다 큰 또 다른 항목을 추가하는 경우 예외가 처리됩니다. 이 메소드의 더 엄격한 정책은 다음 예제 코드에서 설명합니다.
주: 아래 코드는 위의 기존 코드에 추가되는 것으로 가정합니다.
// This code will throw an exception because the list is of size 3
// and you have not created an item to increase the size to 4.
parent.setString("child[5]/grandchild/name", "Billy");

task 타스크 주제

이용약관 | 피드백


시간소인 아이콘 마지막 갱신 날짜: 2010년 7월 7일 수요일


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.doc/doc/cpro_multipleinstances.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
이 Information Center는 Eclipse 기술을 기반으로 합니다(http://www.eclipse.org 웹 사이트 참조).