io.legaldocml.akn.element.Block Maven / Gradle / Ivy
package io.legaldocml.akn.element;
import com.google.common.collect.ImmutableMap;
import io.legaldocml.akn.AknObject;
import io.legaldocml.akn.attribute.Name;
import io.legaldocml.akn.group.BlockElements;
import io.legaldocml.io.impl.Buffers;
import io.legaldocml.io.CharArray;
import io.legaldocml.io.XmlWriter;
import java.io.IOException;
import java.util.function.BiConsumer;
import static io.legaldocml.akn.element.Attributes.biConsumerString;
import static io.legaldocml.akn.util.XmlWriterHelper.writeName;
import static io.legaldocml.unsafe.UnsafeHelper.getFieldOffset;
/**
* The element block is a generic element for a block. It can be placed in a container instead of any of the other
* blocks. The attribute name is required and gives a name to the element.
*
*
* <xsd:element name="block">
* <xsd:complexType mixed="true">
* <xsd:complexContent>
* <xsd:extension base="inline">
* <xsd:attributeGroup ref="name" />
* <xsd:extension>
* <xsd:complexContent>
* <xsd:complexType>
* <xsd:element>
*
*
* @author Jacques Militello
*/
public final class Block extends InlineType implements Name, BlockElements {
/**
* XML tag element name.
*/
public static final String ELEMENT = "block";
/**
* Memory address.
*/
private static final long ADDRESS = Buffers.address(ELEMENT);
private static final ImmutableMap> ATTRIBUTES;
static {
ATTRIBUTES = ImmutableMap.>builder()
.putAll(InlineType.ATTRIBUTES)
.put(Name.ATTRIBUTE, biConsumerString(getFieldOffset(Block.class, "name")))
.build();
}
/**
* Name of this block.
*/
private String name;
/**
* {@inheritDoc}
*/
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
public void setName(String name) {
this.name = name;
}
/**
* {@inheritDoc}
*/
@Override
public void write(XmlWriter writer) throws IOException {
writer.writeStart(ADDRESS, 5);
writeName(writer, this);
super.write(writer);
writer.writeEnd(ADDRESS, 5);
}
/**
* {@inheritDoc}
*/
@Override
public String name() {
return ELEMENT;
}
/**
* {@inheritDoc}
*/
@Override
public ImmutableMap> attributes() {
return ATTRIBUTES;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy