인스턴스 특성을 확인하여 열린 특성 중에 속성이 있는지 확인함으로써 DataObject의 인스턴스에 any 값이 설정되었는지 여부를 간단히 판별할 수 있습니다.
DataObject는 DataObject 유형에 any 태그가 있는지 판별할 수 있는 메커니즘을 제공하지 않습니다. DataObject에는 any 및 anyAttribute 둘 다에 적용되고 모든 특성을 자유롭게 추가할 수 있도록 허용하는 "열림" 개념만 있습니다. any 태그가 있는 경우 DataObject에서 isOpen() = true, isSequenced() = true가 되지만, anyAttribute 태그 및 순서 주제에서 설명한 순서 지정 이유 중 하나가 있을 수도 있습니다. 다음 예제는 이러한 개념에 대해 설명합니다.
DataObject dobj = ... // Check to see if the type is open, if it isn't then it can't have // any values set in it. boolean isOpen = dobj.getType().isOpen(); if (!isOpen) return false; // Does not have any values set // Open Properties are added to the Instance Property list, but not // the Property list, so comparing their sizes can easily determine // if any open data is set int instancePropertyCount = dobj.getInstanceProperties().size(); int definedPropertyCount = dobj.getType().getProperties().size(); // If equal, does not have any open content set if (instancePropertyCount == definedPropertyCount) return false; // Check the open content Properties to determine if any are Elements for (int i=definedPropertyCount; i < instancePropertyCount; i++) { Property prop = (Property)dobj.getInstanceProperties().get(i); if (boXsdHelper.isElement(prop)) { return true; // Found an any value } } return false; // Does not have any values set