Module tools.jackson.dataformat.xml
Package tools.jackson.dataformat.xml.ser
Record Class RootAttribute
java.lang.Object
java.lang.Record
tools.jackson.dataformat.xml.ser.RootAttribute
- All Implemented Interfaces:
XmlGeneratorWritable
public record RootAttribute(QName name, String value)
extends Record
implements XmlGeneratorWritable
Value container to represent an attribute to add to the root XML element
being written, to be registered via
XmlGeneratorInitializer.addRootAttribute(QName, String)
(or its String-name overload).
Typical use case is adding XML Schema instance attributes such as
xsi:schemaLocation or xsi:noNamespaceSchemaLocation,
but any attribute can be added.
NOTE: root attributes are only emitted when the root value being serialized
produces a structured (object) start element; scalar root values (e.g.
a bare String) do not currently get root attributes attached.
- Since:
- 3.2
-
Constructor Summary
ConstructorsConstructorDescriptionRootAttribute(QName name, String value) Creates an instance of aRootAttributerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.voidwrite(ToXmlGenerator xmlGen, org.codehaus.stax2.XMLStreamWriter2 sw) Method to call to actually write out the entity using givenXMLStreamWriter2.
-
Constructor Details
-
RootAttribute
Creates an instance of aRootAttributerecord class.- Parameters:
name- the value for thenamerecord componentvalue- the value for thevaluerecord component
-
-
Method Details
-
write
public void write(ToXmlGenerator xmlGen, org.codehaus.stax2.XMLStreamWriter2 sw) throws XMLStreamException Description copied from interface:XmlGeneratorWritableMethod to call to actually write out the entity using givenXMLStreamWriter2.ToXmlGeneratoris only passed in case access to configuration was needed.- Specified by:
writein interfaceXmlGeneratorWritable- Parameters:
xmlGen- Generator that called this method: MUST NOT call its output methods, only to be used for configuration accesssw- Writer to use for actual output of XML event- Throws:
XMLStreamException
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-