org.xmlet.xsdparser.xsdelements.XsdAll Maven / Gradle / Ivy
package org.xmlet.xsdparser.xsdelements;
import org.xmlet.xsdparser.core.XsdParserCore;
import org.xmlet.xsdparser.core.utils.ParseData;
import org.xmlet.xsdparser.xsdelements.elementswrapper.ReferenceBase;
import org.xmlet.xsdparser.xsdelements.elementswrapper.UnsolvedReference;
import org.xmlet.xsdparser.xsdelements.visitors.XsdAbstractElementVisitor;
import javax.validation.constraints.NotNull;
import java.util.Map;
import java.util.function.Function;
/**
* A class representing the xsd:all element. Since it shares the same attributes as {@link XsdChoice} or {@link XsdSequence}
* it extends {@link XsdMultipleElements}. For more information check {@link XsdMultipleElements}.
*
* @see xsd:all element definition and usage
*/
public class XsdAll extends XsdMultipleElements {
public static final String XSD_TAG = "xsd:all";
public static final String XS_TAG = "xs:all";
public static final String TAG = "all";
/**
* Specifies the minimum number of times this element can occur in the parent element. The value can be any
* number bigger or equal to 0. Default value is 1. This attribute cannot be used if the parent element is the
* XsdSchema element.
*/
private Integer minOccurs;
/**
* Specifies the maximum number of times this element can occur in the parent element. The value can be any
* number bigger or equal to 0. Default value is 1. This attribute cannot be used if the parent element is the
* XsdSchema element.
*/
private Integer maxOccurs;
private XsdAll(@NotNull XsdParserCore parser, @NotNull Map attributesMap, @NotNull Function visitorFunction){
super(parser, attributesMap, visitorFunction);
this.minOccurs = AttributeValidations.validateNonNegativeInteger(XSD_TAG, MIN_OCCURS_TAG, attributesMap.getOrDefault(MIN_OCCURS_TAG, "1"));
this.maxOccurs = AttributeValidations.validateNonNegativeInteger(XSD_TAG, MAX_OCCURS_TAG, attributesMap.getOrDefault(MAX_OCCURS_TAG, "1"));
}
@Override
public void accept(XsdAbstractElementVisitor visitorParam) {
super.accept(visitorParam);
visitorParam.visit(this);
}
public static ReferenceBase parse(@NotNull ParseData parseData){
return xsdParseSkeleton(parseData.node, new XsdAll(parseData.parserInstance, convertNodeMap(parseData.node.getAttributes()), parseData.visitorFunction));
}
/**
* Performs a copy of the current object for replacing purposes. The cloned objects are used to replace
* {@link UnsolvedReference} objects in the reference solving process.
* @param placeHolderAttributes The additional attributes to add to the clone.
* @return A copy of the object from which is called upon.
*/
@Override
public XsdAll clone(@NotNull Map placeHolderAttributes) {
placeHolderAttributes.putAll(attributesMap);
XsdAll elementCopy = new XsdAll(this.getParser(), placeHolderAttributes, visitorFunction);
for(ReferenceBase element: getElements()){
elementCopy.elements.add(ReferenceBase.clone(parser, element, elementCopy));
}
elementCopy.cloneOf = this;
elementCopy.setParent(null);
return elementCopy;
}
@SuppressWarnings("unused")
public Integer getMinOccurs() {
return minOccurs;
}
@SuppressWarnings("unused")
public Integer getMaxOccurs() {
return maxOccurs;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy