All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.legaldocml.akn.element.CitationHierarchy Maven / Gradle / Ivy

The newest version!
package io.legaldocml.akn.element;

import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AkomaNtosoContext;
import io.legaldocml.akn.attribute.CoreReq;
import io.legaldocml.akn.util.AknList;
import io.legaldocml.akn.util.XmlReaderHelper;
import io.legaldocml.io.QName;
import io.legaldocml.io.XmlReader;
import io.legaldocml.io.XmlWriter;

import javax.xml.stream.XMLStreamConstants;
import java.io.IOException;
import java.util.function.Supplier;

import static io.legaldocml.akn.AknElements.CITATION;
import static io.legaldocml.akn.AknElements.COMPONENT_REF;
import static io.legaldocml.akn.AknElements.INTRO;
import static io.legaldocml.akn.AknElements.WRAP;
import static io.legaldocml.akn.AknElements.WRAP_UP;

/**
 *
 * 
 *   
 *     
 * 	     
 * 		   
 * 			 
 * 			 
 * 		       
 * 			   
 * 			 
 * 			 
 * 		   
 * 		   
 * 	     
 * 	   
 *   
 * 
* * @author Jacques Militello */ public abstract class CitationHierarchy extends BaseHierarchy implements CoreReq { private static final ImmutableMap> ELEMS; static { ELEMS = ImmutableMap.>builder() .put(COMPONENT_REF, ComponentRef::new) .put(CITATION, Citation::new) .build(); } private Intro intro; private final AknList elements = new AknList<>(new CitationHierarchyElement[4]); private WrapUp wrapUp; /** * {@inheritDoc} */ @Override public void write(XmlWriter writer) throws IOException { CoreReq.super.write(writer); super.write(writer); if (this.intro != null) { this.intro.write(writer); } if (this.elements.size() > 0) { this.elements.write(writer); } if (this.wrapUp != null) { this.wrapUp.write(writer); } } /** * {@inheritDoc} */ @Override public void read(XmlReader reader) { QName qName = reader.getQName(); super.read(reader); // if (LOGGER.isTraceEnabled()) { // LOGGER.trace("Hierarchy -> [{}] -> [{}]" , getClass().getSimpleName(), this); // } if (reader.getQName().equalsLocalName(INTRO)) { this.intro = new Intro(); this.intro.read(reader); reader.nextStartOrEndElement(); } XmlReaderHelper.read(reader, this.elements, ELEMS, qName, WRAP_UP); if (reader.getContext().getAkoXmlModule().getVersion() == 3 && reader.getEventType() == XMLStreamConstants.START_ELEMENT && reader.getQName().equalsLocalName(WRAP)) { this.wrapUp = new WrapUp(); this.wrapUp.read(reader); reader.nextStartOrEndElement(); } } public final void setIntro(Intro intro) { this.intro = intro; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy