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

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

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

import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AknObject;
import io.legaldocml.akn.attribute.Date;
import io.legaldocml.akn.group.ANtitleInline;
import io.legaldocml.akn.visitor.AknVisitor;
import io.legaldocml.io.AttributeGetterSetter;
import io.legaldocml.io.XmlWriter;
import io.legaldocml.io.impl.Buffers;

import java.io.IOException;
import java.time.OffsetDateTime;

import static io.legaldocml.akn.AknAttributes.DATE;
import static io.legaldocml.akn.AknElements.DOC_DATE;
import static io.legaldocml.akn.element.Attributes.attributeGetterSetter4DateTime;
import static io.legaldocml.akn.util.XmlWriterHelper.writeDate;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;

/**
 * The element docDate is an inline element within preface to identify the string used by the document for its own
 * date(s). Documents with multiple dates may use multiple docDate elements.
 * 

*

 *   
 * 	   
 * 	     
 * 		   
 * 		     
 * 		   
 * 	     
 * 	   
 *   
 * 
* * @author Jacques Militello */ public final class DocDate extends InlineType implements Date, ANtitleInline { /** * Memory address. */ private static final long ADDRESS_DOC_DATE = Buffers.address(DOC_DATE); private static final ImmutableMap> ATTRIBUTES; static { ATTRIBUTES = ImmutableMap.>builder() .putAll(InlineType.ATTRIBUTES) .put(DATE, attributeGetterSetter4DateTime(DATE, getFieldOffset(DocDate.class, "date"))) .build(); } // Mandatory private OffsetDateTime date; /** * {@inheritDoc} */ @Override public OffsetDateTime getDate() { return this.date; } /** * {@inheritDoc} */ @Override public void setDate(OffsetDateTime date) { this.date = date; } /** * {@inheritDoc} */ @Override public void write(XmlWriter writer) throws IOException { writer.writeStart(ADDRESS_DOC_DATE, 7); writeDate(writer, this); super.write(writer); writer.writeEnd(ADDRESS_DOC_DATE, 7); } /** * {@inheritDoc} */ @Override public ImmutableMap> attributes() { return ATTRIBUTES; } /** * {@inheritDoc} */ @Override public String name() { return DOC_DATE; } /** * {@inheritDoc} */ @Override public void accept(AknVisitor visitor) { if (visitor.visitEnter(this)) { super.accept(visitor); visitor.visitLeave(this); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy