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

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

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.io.impl.Buffers;
import io.legaldocml.io.CharArray;
import io.legaldocml.io.XmlWriter;

import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.function.BiConsumer;

import static io.legaldocml.akn.element.Attributes.biConsumerDateTime;
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.
 *
 * 
 *   <xsd:element name="docDate">
 * 	   <xsd:complexType mixed="true">
 * 	     <xsd:complexContent>
 * 		   <xsd:extension base="inline">
 * 		     <xsd:attributeGroup ref="date"/>
 * 		   <xsd:extension>
 * 	     <xsd:complexContent>
 * 	   <xsd:complexType>
 *   <xsd:element>
 * 
* * @author Jacques Militello */ public final class DocDate extends InlineType implements Date, ANtitleInline { /** * Xml Element Name. */ public static final String ELEMENT = "docDate"; /** * Memory address. */ private static final long ADDRESS = Buffers.address(ELEMENT); private static final ImmutableMap> ATTRIBUTES; static { ATTRIBUTES = ImmutableMap.>builder() .putAll(InlineType.ATTRIBUTES) .put("date", biConsumerDateTime(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, 7); writeDate(writer, this); super.write(writer); writer.writeEnd(ADDRESS, 7); } /** * {@inheritDoc} */ @Override public ImmutableMap> attributes() { return ATTRIBUTES; } /** * {@inheritDoc} */ @Override public String name() { return ELEMENT; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy