public final class Attribute extends Object implements Binary
----------------------------------------------- | attribute-with-one-value | q bytes ---------------------------------------------------------- | additional-value | r bytes |- 0 or more ----------------------------------------------------------
When an attribute is single valued (e.g. "copies" with value of 10) or multi-valued with one value (e.g. "sides-supported" with just the value 'one-sided') it is encoded with just an "attribute-with-one- value" field. When an attribute is multi-valued with n values (e.g. "sides-supported" with the values 'one-sided' and 'two-sided-long- edge'), it is encoded with an "attribute-with-one-value" field followed by n-1 "additional-value" fields.
| Modifier and Type | Class and Description |
|---|---|
static class |
Attribute.AdditionalValue
An "additional-value" has four entries.
|
static class |
Attribute.AttributeWithOneValue
An "attribute-with-one-value" field is encoded with five subfields.
|
| Constructor and Description |
|---|
Attribute(ByteBuffer bytes)
Instantiates a new (single valued or multi-valued) attribute from the
given bytes.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getName()
The "name" field contains the textual name of the attribute.
|
String |
getStringValue()
The "value" field contains the value of a charset attribute.
|
URI |
getUriValue()
The "value" field contains the value of a URI attribute.
|
byte[] |
getValue()
The "value" field contains the value of the attribute.
|
ValueTags |
getValueTag()
The "value-tag" field specifies the attribute syntax, e.g. 0x44
for the attribute syntax 'keyword'.
|
boolean |
isMultiValue()
When the attribte value is multi-valued this method returns true.
|
static Attribute |
of(String name,
Charset value)
Creates a singe-value attribute for charset values.
|
static Attribute |
of(String name,
int value)
Creates a singe-value attribute for integer values.
|
static Attribute |
of(String name,
Locale value)
Creates a singe-value attribute for the given language.
|
static Attribute |
of(String name,
URI value)
Creates a singe-value attribute for URI values.
|
static Attribute |
of(ValueTags tag,
String name,
byte[] value)
Creates a singe-value attribute.
|
static Attribute |
of(ValueTags tag,
String name,
int value)
Creates a singe-value attribute for integer based values.
|
static Attribute |
of(ValueTags tag,
String name,
String value)
Creates a singe-value attribute for character-string values.
|
String |
toLongString()
This method shows a short representation of an attribute.
|
String |
toString()
This method shows a short representation of an attribute.
|
void |
writeBinaryTo(OutputStream ostream)
Converts the attribute to a byte array as described in RFC-2910 and
writes it to the given output-stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waittoByteArraypublic Attribute(ByteBuffer bytes)
ByteBuffer must be positioned at the
beginning of the attribute.bytes - ByteBuffer positioned at the beginningpublic static Attribute of(String name, int value)
name - e.g. "job-id"value - e.g. 42public static Attribute of(String name, URI value)
name - e.g. "job-uri"value - an URIpublic static Attribute of(String name, Charset value)
name - e.g. "attributes-charset"value - e.g. StandardCharsets.UTF_8public static Attribute of(String name, Locale value)
name - e.g. "attributes-natural-language"value - e.g. the English Localepublic static Attribute of(ValueTags tag, String name, int value)
tag - the value-tagname - the name of the attributevalue - the string value of the attributepublic static Attribute of(ValueTags tag, String name, String value)
tag - the value-tagname - the name of the attributevalue - the string value of the attributepublic static Attribute of(ValueTags tag, String name, byte[] value)
tag - the value-tagname - the name of the attributevalue - the binary value of the attributepublic ValueTags getValueTag()
ValueTags.KEYWORDpublic String getName()
public byte[] getValue()
public String getStringValue()
public URI getUriValue()
public boolean isMultiValue()
public String toString()
toLongString() is, that in case of a multi-value
attribute only the first value is shown.public String toLongString()
public void writeBinaryTo(OutputStream ostream) throws IOException
writeBinaryTo in interface Binaryostream - an output streamIOException - in case of I/O problemsCopyright © 2018. All rights reserved.