public Collection<XmlNamespace> getReferencedNamespaces() { // The referencedNamespaces field is lazily initialized because it is // only required for top-level types. A race condition is // harmless and will just result in multiple computations. if (referencedNamespaces == null) { ImmutableSet.Builder<XmlNamespace> builder = ImmutableSet.builder(); Set<ElementKey<?, ?>> added = Sets.newHashSet(); addReferencedNamespaces(this, builder, added); referencedNamespaces = builder.build(); } return referencedNamespaces; }
public Collection<XmlNamespace> getReferencedNamespaces() { // The referencedNamespaces field is lazily initialized because it is // only required for top-level types. A race condition is // harmless and will just result in multiple computations. if (referencedNamespaces == null) { ImmutableSet.Builder<XmlNamespace> builder = ImmutableSet.builder(); Set<ElementKey<?, ?>> added = Sets.newHashSet(); addReferencedNamespaces(this, builder, added); referencedNamespaces = builder.build(); } return referencedNamespaces; }
public Collection<XmlNamespace> getReferencedNamespaces() { // The referencedNamespaces field is lazily initialized because it is // only required for top-level types. A race condition is // harmless and will just result in multiple computations. if (referencedNamespaces == null) { ImmutableSet.Builder<XmlNamespace> builder = ImmutableSet.builder(); Set<ElementKey<?, ?>> added = Sets.newHashSet(); addReferencedNamespaces(this, builder, added); referencedNamespaces = builder.build(); } return referencedNamespaces; }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }
private static void addReferencedNamespaces(ElementMetadata<?, ?> metadata, ImmutableSet.Builder<XmlNamespace> builder, Set<ElementKey<?, ?>> added) { // Avoid recursive looping if (added.contains(metadata.getKey())) { return; } added.add(metadata.getKey()); // Add namespace for this element (if any) XmlNamespace elemNs = metadata.getName().getNs(); if (elemNs != null) { builder.add(elemNs); } // Add namespace for all attributes (if any) for (AttributeKey<?> attrKey : metadata.getAttributes()) { AttributeMetadata<?> attrMetadata = metadata.bindAttribute(attrKey); XmlNamespace attrNs = attrMetadata.getName().getNs(); if (attrNs != null) { builder.add(attrNs); } } // Add namespace for all child elements (recursively) for (ElementKey<?, ?> elemKey : metadata.getElements()) { ElementMetadata<?, ?> childMetadata = metadata.bindElement(elemKey); addReferencedNamespaces(childMetadata, builder, added); } }