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

io.legaldocml.akn.element.Identification 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.Source;
import io.legaldocml.akn.type.AgentRef;
import io.legaldocml.akn.visitor.AknVisitor;
import io.legaldocml.io.AttributeGetterSetter;
import io.legaldocml.io.XmlReader;
import io.legaldocml.io.XmlWriter;
import io.legaldocml.io.impl.Buffers;

import java.io.IOException;

import static io.legaldocml.akn.AknAttributes.SOURCE;
import static io.legaldocml.akn.AknElements.FRBR_EXPRESSION;
import static io.legaldocml.akn.AknElements.FRBR_ITEM;
import static io.legaldocml.akn.AknElements.FRBR_MANIFESTATION;
import static io.legaldocml.akn.AknElements.FRBR_WORK;
import static io.legaldocml.akn.AknElements.IDENTIFICATION;
import static io.legaldocml.akn.element.Attributes.attributeGetterSetter4AgentRef;
import static io.legaldocml.akn.util.XmlWriterHelper.writeSource;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;

/**
 * 
 *   
 * 	   
 * 	     
 * 		   
 * 		   
 * 		   
 * 		   
 * 		 
 * 	   
 *     
 *   
 * 
* * @author Jacques Militello */ public final class Identification implements AknObject, Source { private static final long ADDRESS_IDENTIFICATION = Buffers.address(IDENTIFICATION); private static final ImmutableMap> ATTRIBUTES; static { ATTRIBUTES = ImmutableMap.>builder() .put(SOURCE, attributeGetterSetter4AgentRef(SOURCE, getFieldOffset(Identification.class, "source"))) .build(); } // Mandatory private final FRBRWork work = new FRBRWork(); // Mandatory private final FRBRExpression expression = new FRBRExpression(); // Mandatory private final FRBRManifestation manifestation = new FRBRManifestation(); // Optional private FRBRItem item; // Mandatory private AgentRef source; public FRBRWork getFRBRWork() { return this.work; } public FRBRExpression getFRBRExpression() { return this.expression; } public FRBRManifestation getFRBRManifestation() { return this.manifestation; } public FRBRItem getFRBRItem() { return this.item; } public void setFRBRItem(FRBRItem fRBRItem) { this.item = fRBRItem; } /** * {@inheritDoc} */ public AgentRef getSource() { return this.source; } /** * {@inheritDoc} */ public void setSource(AgentRef source) { this.source = source; } /** * {@inheritDoc} */ @Override public String name() { return IDENTIFICATION; } /** * {@inheritDoc} */ @Override public void write(XmlWriter writer) throws IOException { writer.writeStart(ADDRESS_IDENTIFICATION, 14); writeSource(writer, this); this.work.write(writer); this.expression.write(writer); this.manifestation.write(writer); if (this.item != null) { this.item.write(writer); } writer.writeEnd(ADDRESS_IDENTIFICATION, 14); } /** * {@inheritDoc} */ @Override public void read(XmlReader reader) { Attributes.read(reader, this); reader.nextStartOrEndElement(); if (reader.getQName().equalsLocalName(FRBR_WORK)) { this.work.read(reader); } if (reader.getQName().equalsLocalName(FRBR_EXPRESSION)) { this.expression.read(reader); } if (reader.getQName().equalsLocalName(FRBR_MANIFESTATION)) { this.manifestation.read(reader); } if (reader.getQName().equalsLocalName(FRBR_ITEM)) { this.item = new FRBRItem(); this.item.read(reader); } if (reader.getQName().equalsLocalName(IDENTIFICATION)) { reader.nextStartOrEndElement(); } else { throw new IllegalStateException(); } } /** * {@inheritDoc} */ @Override public ImmutableMap> attributes() { return ATTRIBUTES; } /** * {@inheritDoc} */ @Override public void accept(AknVisitor visitor) { if (visitor.visitEnter(this)) { this.work.accept(visitor); this.expression.accept(visitor); this.manifestation.accept(visitor); if (this.item != null) { this.item.accept(visitor); } visitor.visitLeave(this); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy