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

io.legaldocml.akn.element.FRBRlanguage 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.MandatoryAttributeException;
import io.legaldocml.akn.attribute.Language;
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 static io.legaldocml.akn.AknAttributes.LANGUAGE;
import static io.legaldocml.akn.AknElements.FRBR_LANGUAGE;
import static io.legaldocml.akn.element.Attributes.attributeGetterSetter4String;
import static io.legaldocml.akn.util.XmlWriterHelper.throwException;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;
import static io.legaldocml.unsafe.UnsafeString.getChars;

/**
 * The element FRBRlanguage is the metadata property containing a RFC4646 (three-letter code) of the main human language
 * used in the content of this expression.
 * 

*

 *   
 *     
 * 	     
 * 		   
 * 		     
 * 		   
 * 	     
 *     
 *   
 * 
* * @author Jacques Militello */ public final class FRBRlanguage extends MetaOpt implements Language { /** * Memory address. */ private static final long ADDRESS_FRBR_LANGUAGE = Buffers.address(FRBR_LANGUAGE); private static final ImmutableMap> ATTRIBUTES; static { ATTRIBUTES = ImmutableMap.>builder() .putAll(MetaOpt.ATTRIBUTES) .put(LANGUAGE, attributeGetterSetter4String(LANGUAGE, getFieldOffset(FRBRlanguage.class, "language"))) .build(); } private String language; /** * {@inheritDoc} */ public String getLanguage() { return language; } /** * {@inheritDoc} */ public void setLanguage(String language) { this.language = language; } /** * {@inheritDoc} */ @Override public void write(XmlWriter writer) throws IOException { writer.writeStart(ADDRESS_FRBR_LANGUAGE, 12); if (this.language != null) { writer.writeAttribute(Attributes.ADDRESS_LANGUAGE, 8, getChars(this.language)); } else { throwException(writer, new MandatoryAttributeException(this, LANGUAGE, writer)); } super.write(writer); writer.writeEnd(ADDRESS_FRBR_LANGUAGE, 12); } /** * {@inheritDoc} */ @Override public String name() { return FRBR_LANGUAGE; } /** * {@inheritDoc} */ @Override public ImmutableMap> attributes() { return ATTRIBUTES; } /** * {@inheritDoc} */ @Override public void accept(AknVisitor visitor) { visitor.visit(this); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy