JavaTM Platform
Standard Ed. 6

javax.xml.bind.annotation
주석형 XmlMixed



@Retention (value =RUNTIME )
@Target (value ={FIELD ,METHOD })
public @interface XmlMixed

혼합 컨텐츠를 지원하는 복수치의 JavaBean 프로퍼티을 주석 합니다.

사용에는 다음의 제약이 있습니다.

@XmlMixed 로 주석 된 복수치 프로퍼티에, 다음을 삽입할 수가 있습니다.

다음에, 혼합 컨텐츠의 바인딩과 작성의 예를 나타냅니다.

  <!-- schema fragment having  mixed content -->
  <xs:complexType name="letterBody" mixed="true">
    <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="quantity" type="xs:positiveInteger"/>
        <xs:element name="productName" type="xs:string"/>
        <!-- etc. -->
    </xs:sequence>
  </xs:complexType>
  <xs:element name="letterBody" type="letterBody"/>
 
 // Schema-derived Java code: 
 // (Only annotations relevant to mixed content are shown below, 
 //  others are ommitted. )
 import java.math.BigInteger;
 public class ObjectFactory {
        // element instance factories
        JAXBElement<LetterBody> createLetterBody(LetterBody value);
        JAXBElement<String>     createLetterBodyName(String value);
        JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
        JAXBElement<String>     createLetterBodyProductName(String value);
      // type instance factory
        LetterBody> createLetterBody();
 }
 
 public class LetterBody {
        // Mixed content can contain instances of Element classes
        // Name, Quantity and ProductName.Text data is represented as
        // java.util.String for text.
        @XmlMixed 
        @XmlElementRefs({
                @XmlElementRef(name="productName", type=JAXBElement.class),
                @XmlElementRef(name="quantity", type=JAXBElement.class),
                @XmlElementRef(name="name", type=JAXBElement.class)})
        List getContent(){...}
 }
 
다음에, 혼합 컨텐츠를 포함한 XML 인스턴스 문서를 나타냅니다.

 <letterBody>
 Dear Mr. <name>Robert Smith</name>
 Your order of <quantity>1</quantity> <productName>Baby
 Monitor</productName> shipped from our warehouse.  ....
 </letterBody>
 
상기는, 다음의 JAXB API 호출을 사용해 작성할 수가 있습니다.

 LetterBody lb = ObjectFactory.createLetterBody();
 JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
 List gcl = lb.getContent();  //add mixed content to general content property.
 gcl.add("Dear Mr. ");  // add text information item as a String.
 
 // add child element information item
 gcl.add(ObjectFactory.createLetterBodyName("Robert Smith"));
 gcl.add("Your order of "); // add text information item as a String
 
 // add children element information items
 gcl.add(ObjectFactory.
                        createLetterBodyQuantity(new BigInteger("1")));
 gcl.add(ObjectFactory.createLetterBodyProductName("Baby Monitor"));
 gcl.add("shipped from our warehouse");  // add text information item
 

추가의 일반적인 정보에 대해서는, javax.xml.bind.package javadoc 의 「패키지의 스펙」을 참조해 주세요.

도입된 버젼:
JAXB2. 0


JavaTM Platform
Standard Ed. 6

버그의 보고와 기능의 요청
한층 더 자세한 API 레퍼런스 및 개발자 문서에 대해서는,Java SE 개발자용 문서를 참조해 주세요. 개발자전용의 상세한 해설, 개념의 개요, 용어의 정의, 버그의 회피책, 및 코드 실례가 포함되어 있습니다.

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.