public final class Attribute extends java.lang.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(java.nio.ByteBuffer bytes)
Instantiates a new (single valued or multi-valued) attribute from the
given bytes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Attribute value)
For multi-value attributes you can use this method to add the single
values to the attribute.
|
java.util.List<Attribute.AdditionalValue> |
getAdditionalValues()
Gets the different values for a multi-value attribute.
|
boolean |
getBooleanValue()
The "value" field contains the value of a boolean attribute.
|
int |
getIntValue()
The "value" field contains the value of a integer attribute.
|
java.lang.String |
getName()
The "name" field contains the textual name of the attribute.
|
java.lang.String |
getStringValue()
The "value" field contains the value of a charset attribute.
|
java.net.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(java.lang.String name,
boolean value)
Creates a singe-value attribute for boolean values.
|
static Attribute |
of(java.lang.String name,
java.nio.charset.Charset value)
Creates a singe-value attribute for charset values.
|
static Attribute |
of(java.lang.String name,
int value)
Creates a singe-value attribute for integer values.
|
static Attribute |
of(java.lang.String name,
int min,
int max)
Creates a singe-value attribute for a range of integer values.
|
static Attribute |
of(java.lang.String name,
java.util.Locale value)
Creates a singe-value attribute for the given language.
|
static Attribute |
of(java.lang.String name,
PrinterResolution... resolutions)
Creates a multi-value attribute with the different printer resolutions.
|
static Attribute |
of(java.lang.String name,
java.net.URI value)
Creates a singe-value attribute for URI values.
|
static Attribute |
of(ValueTags tag,
java.lang.String name,
byte[]... additionalValues)
Creates a multi-value attribute for the given value-tag.
|
static Attribute |
of(ValueTags tag,
java.lang.String name,
byte[] value)
Creates a singe-value attribute.
|
static Attribute |
of(ValueTags tag,
java.lang.String name,
int value)
Creates a singe-value attribute for integer based values.
|
static Attribute |
of(ValueTags tag,
java.lang.String name,
java.lang.String... additionalValues)
Creates a multi-value attribute for character-string values.
|
static Attribute |
of(ValueTags tag,
java.lang.String name,
java.lang.String value)
Creates a single-value attribute for character-string values.
|
void |
setValue(byte[] value)
Sets the value of the attribute.
|
java.lang.String |
toLongString()
This method shows a short representation of an attribute.
|
java.lang.String |
toString()
This method shows a short representation of an attribute.
|
void |
writeBinaryTo(java.io.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(java.nio.ByteBuffer bytes)
ByteBuffer must be positioned at the
beginning of the attribute.bytes - ByteBuffer positioned at the beginningpublic static Attribute of(java.lang.String name, int value)
name - e.g. "job-id"value - e.g. 42public static Attribute of(java.lang.String name, int min, int max)
name - e.g. "copies-supported"min - e.g. 1max - e.g. 9999public static Attribute of(java.lang.String name, boolean value)
name - e.g. "last-document"value - true or falcepublic static Attribute of(java.lang.String name, java.net.URI value)
name - e.g. "job-uri"value - an URIpublic static Attribute of(java.lang.String name, java.nio.charset.Charset value)
name - e.g. "attributes-charset"value - e.g. StandardCharsets.UTF_8public static Attribute of(java.lang.String name, java.util.Locale value)
name - e.g. "attributes-natural-language"value - e.g. the English Localepublic static Attribute of(ValueTags tag, java.lang.String name, int value)
tag - the value-tagname - the name of the attributevalue - the string value of the attributepublic static Attribute of(ValueTags tag, java.lang.String name, byte[] value)
tag - the value-tagname - the name of the attributevalue - the binary value of the attributepublic static Attribute of(ValueTags tag, java.lang.String name, byte[]... additionalValues)
tag - the value-tagname - the name of the attributeadditionalValues - the additional valuespublic static Attribute of(ValueTags tag, java.lang.String name, java.lang.String... additionalValues)
tag - the value-tagname - the name of the attributeadditionalValues - additional valuespublic static Attribute of(ValueTags tag, java.lang.String name, java.lang.String value)
tag - the value-tagname - the name of the attributevalue - the valuepublic static Attribute of(java.lang.String name, PrinterResolution... resolutions)
name - the nameresolutions - the different printer resolutionspublic ValueTags getValueTag()
ValueTags.KEYWORDpublic java.lang.String getName()
public void setValue(byte[] value)
value - value as byte arraypublic byte[] getValue()
public java.util.List<Attribute.AdditionalValue> getAdditionalValues()
public int getIntValue()
public boolean getBooleanValue()
public java.lang.String getStringValue()
public java.net.URI getUriValue()
public boolean isMultiValue()
public java.lang.String toString()
toLongString() is, that in case of a multi-value
attribute only the first value is shown.toString in class java.lang.Objectpublic java.lang.String toLongString()
public void writeBinaryTo(java.io.OutputStream ostream)
throws java.io.IOException
writeBinaryTo in interface Binaryostream - an output streamjava.io.IOException - in case of I/O problemspublic void add(Attribute value)
value - the valueCopyright © 2018–2020. All rights reserved.