/** * Creates a new element metadata instance based on this transform. */ <D, E extends Element> ElementMetadata<D, E> toMetadata( Schema schema, ElementKey<?, ?> parent, ElementKey<D, E> key, MetadataContext context) { return new ElementMetadataImpl<D, E>(schema, this, parent, key, context); }
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 boolean isReferenced() { return isVisible(); }
this.cardinality = firstNonNull( transform.getCardinality(), Cardinality.SINGLE); this.isContentRequired = firstNonNull(transform.getContentRequired(), true); this.validator = firstNonNull(transform.getValidator(), DEFAULT_VALIDATOR); this.properties = transform.getProperties(); this.virtualElementHolder = transform.getVirtualElementHolder(); this.isFlattened = transform.isFlattened(); this.attributes = getAttributes(transform.getAttributes().values()); this.renamedAttributes = getRenamedAttributes(); this.elements = getElements(transform.getElements().values()); this.renamedElements = getRenamedElements();
public XmlNamespace getDefaultNamespace() { // The default implementation uses the default namespace for the in-use name return getName().getNs(); }
/** * Creates an immutable map of renamed attributes from the collection of * attribute keys. This binds the attributes and checks if they have a * different name under the context of this metadata, and returns any * attributes with an alternate name in the map. */ private ImmutableMap<QName, AttributeKey<?>> getRenamedAttributes() { Builder<QName, AttributeKey<?>> builder = ImmutableMap.builder(); for (AttributeKey<?> key : attributes.values()) { AttributeMetadata<?> bound = bindAttribute(key); QName boundName = bound.getName(); if (!boundName.equals(key.getId())) { builder.put(boundName, key); } } return builder.build(); }
this.cardinality = firstNonNull( transform.getCardinality(), Cardinality.SINGLE); this.isContentRequired = firstNonNull(transform.getContentRequired(), true); this.validator = firstNonNull(transform.getValidator(), DEFAULT_VALIDATOR); this.properties = transform.getProperties(); this.virtualElementHolder = transform.getVirtualElementHolder(); this.isFlattened = transform.isFlattened(); this.attributes = getAttributes(transform.getAttributes().values()); this.renamedAttributes = getRenamedAttributes(); this.elements = getElements(transform.getElements().values()); this.renamedElements = getRenamedElements();
public XmlNamespace getDefaultNamespace() { // The default implementation uses the default namespace for the in-use name return getName().getNs(); }
/** * Creates an immutable map of renamed attributes from the collection of * attribute keys. This binds the attributes and checks if they have a * different name under the context of this metadata, and returns any * attributes with an alternate name in the map. */ private ImmutableMap<QName, AttributeKey<?>> getRenamedAttributes() { Builder<QName, AttributeKey<?>> builder = ImmutableMap.builder(); for (AttributeKey<?> key : attributes.values()) { AttributeMetadata<?> bound = bindAttribute(key); QName boundName = bound.getName(); if (!boundName.equals(key.getId())) { builder.put(boundName, key); } } return builder.build(); }
this.cardinality = firstNonNull( transform.getCardinality(), Cardinality.SINGLE); this.isContentRequired = firstNonNull(transform.getContentRequired(), true); this.validator = firstNonNull(transform.getValidator(), DEFAULT_VALIDATOR); this.properties = transform.getProperties(); this.virtualElementHolder = transform.getVirtualElementHolder(); this.isFlattened = transform.isFlattened(); this.attributes = getAttributes(transform.getAttributes().values()); this.renamedAttributes = getRenamedAttributes(); this.elements = getElements(transform.getElements().values()); this.renamedElements = getRenamedElements();
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 boolean isSelected(Element e) { return isVisible(); }
/** * Creates a new element metadata instance based on this transform. */ <D, E extends Element> ElementMetadata<D, E> toMetadata( Schema schema, ElementKey<?, ?> parent, ElementKey<D, E> key, MetadataContext context) { return new ElementMetadataImpl<D, E>(schema, this, parent, key, context); }
public XmlNamespace getDefaultNamespace() { // The default implementation uses the default namespace for the in-use name return getName().getNs(); }
/** * Creates an immutable map of renamed attributes from the collection of * attribute keys. This binds the attributes and checks if they have a * different name under the context of this metadata, and returns any * attributes with an alternate name in the map. */ private ImmutableMap<QName, AttributeKey<?>> getRenamedAttributes() { Builder<QName, AttributeKey<?>> builder = ImmutableMap.builder(); for (AttributeKey<?> key : attributes.values()) { AttributeMetadata<?> bound = bindAttribute(key); QName boundName = bound.getName(); if (!boundName.equals(key.getId())) { builder.put(boundName, key); } } return builder.build(); }
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 boolean isSelected(Element e) { return isVisible(); }
/** * Creates a new element metadata instance based on this transform. */ <D, E extends Element> ElementMetadata<D, E> toMetadata( Schema schema, ElementKey<?, ?> parent, ElementKey<D, E> key, MetadataContext context) { return new ElementMetadataImpl<D, E>(schema, this, parent, key, context); }
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); } }
public boolean isReferenced() { return isVisible(); }