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


단순 유형에 대해 AnySimpleType 사용

AnySimpleType은 SDO API에서 기타 다른 단순 유형(문자열, 정수, 부울 등)과 유사하게 처리됩니다.

anySimpleType 과 기타 단순 유형 간의 유일한 차이점은 해당 인스턴스 데이터 및 직렬화/직렬화 해제뿐입니다. 이는 비즈니스 오브젝트에만 해당되는 내부 개념이며 데이터와 필드 간의 맵핑 방향이 유효한지 여부를 판별하는 데 사용됩니다. 문자열 유형에 대해 set(...) 메소드가 호출된 경우 데이터는 제일 먼저 문자열로 변환되고 원래 데이터 유형은 유실됩니다.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	targetNamespace="http://StringType">
  <xsd:complexType name="StringType">
    <xsd:sequence>
      <xsd:element name="foo" type="xsd:string"/>
	  </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

	DataObject stringType = ...

	// Set the data to a String
	stringType.set("foo", "bar");

	// The instance data will always be type String, regardless of the data set
	// Displays "java.lang.String"
	System.out.println(stringType.get("foo").getClass().getName());

	// Set the data to an Integer
	stringType.set("foo", new Integer(42));

	// The instance data will always be type String, regardless of the data set
	// Displays "java.lang.String"
	System.out.println(stringType.get("foo").getClass().getName());

대신 anySimpleType은 설정되어 있는 원래 데이터 유형 사용을 완화시키지 않습니다.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	targetNamespace="http://AnySimpleType">
  <xsd:complexType name="AnySimpleType">
    <xsd:sequence>
      <xsd:element name="foo" type="xsd:anySimpleType"/>
	  </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

	DataObject anySimpleType = ...

	// Set the data to a String
	stringType.set("foo", "bar");

	// The instance data will always be of the type of date used in the set
	// Displays "java.lang.String"
	System.out.println(stringType.get("foo").getClass().getName());

	// Set the data to an Integer
	stringType.set("foo", new Integer(42));

	// The instance data will always be of the type of date used in the set
	// Displays "java.lang.Integer"
	System.out.println(stringType.get("foo").getClass().getName());

이 데이터 유형은 또한 직렬화 및 직렬화 해제 중에도 xsi:type에 의해 유지됩니다. 따라서 anySimpleType 요소를 직렬화할 때마다 이 요소에는 해당 Java™ 유형을 기본으로 SDO 스펙에 정의된 것과 일치하는 xsi:type이 있습니다.

다음 예제에서는 데이터가 다음과 같이 표시되도록 위의 비즈니스 오브젝트를 직렬화합니다.

<?xml version="1.0" encoding="UTF-8"?>
<p:StringType xsi:type="p:StringType"
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
 xmlns:xsd=http://www.w3.org/2001/XMLSchema 
 xmlns:p="http://StringType">
  <foo xsi:type="xsd:int">42</foo>
<p:StringType></p:StringType>

직렬화 해제 시 xsi:type을 사용하여 데이터를 적합한 Java 인스턴스 클래스로 로드합니다. xsi:type이 지정되지 않은 경우 기본 직렬화 해제 유형은 문자열이 됩니다.

기타 단순 유형의 경우 맵핑 가능성을 판별하는 것은 상수입니다. 예를 들어, 부울은 항상 문자열에 맵핑할 수 있습니다. AnySimpleType에는 모든 단순 유형이 포함될 수 있으나, 이 때문에 필드의 인스턴스 데이터에 따라 맵핑할 수 있는지 여부가 결정됩니다.

특성 유형의 URI 및 이름을 사용하여 특성 유형이 anySimpleType인지 판별할 수 있습니다. URI는 "commonj.sdo"이고 이름은 "Object"입니다. 데이터가 anySimpleType에 삽입할 수 있는 유효한 데이터인지 판별하려면 DataObject의 인스턴스가 아닌지 확인하십시오. 문자열로 표시할 수 있고 DataObject가 아닌 모든 데이터를 anySimpleType 필드에 설정할 수 있습니다.

이로 인해 다음과 같은 맵핑 규칙이 적용됩니다.


concept 개념 주제

이용약관 | 피드백


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


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