public abstract class AbstractIpp extends Object
IppRequest and
IppResponse which encapsulates the common code of both classes.
An operation request or response is defined in RFC-2910:
----------------------------------------------- | version-number | 2 bytes - required ----------------------------------------------- | operation-id (request) | | or | 2 bytes - required | status-code (response) | ----------------------------------------------- | request-id | 4 bytes - required ----------------------------------------------- | attribute-group | n bytes - 0 or more ----------------------------------------------- | end-of-attributes-tag | 1 byte - required ----------------------------------------------- | data | q bytes - optional -----------------------------------------------
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractIpp.Version
Container for the version information.
|
| Modifier and Type | Field and Description |
|---|---|
protected static AbstractIpp.Version |
DEFAULT_VERSION
The actual supported version is 2.
|
| Modifier | Constructor and Description |
|---|---|
|
AbstractIpp(AbstractIpp.Version version,
short opCode,
int requestId,
List<AttributeGroup> groups)
Instantiates a new IPP request or response with no data.
|
|
AbstractIpp(AbstractIpp.Version version,
short opCode,
int requestId,
List<AttributeGroup> groups,
byte[] data)
Instantiates a new IPP request or response.
|
protected |
AbstractIpp(byte[] bytes)
Instantiates a new IPP request or responsel from the given bytes.
|
|
AbstractIpp(ByteBuffer bytes)
Instantiates a new IPP request or response from the given bytes.
|
| Modifier and Type | Method and Description |
|---|---|
Attribute |
getAttribute(String name)
Gets the attribute with the given name.
|
List<AttributeGroup> |
getAttributeGroups()
The fourth field is the "attribute-group" field, and it occurs 0 or
more times.
|
List<Attribute> |
getAttributeGroups(DelimiterTags tag)
Returns all attributes of the given delimiter-tag.
|
List<Attribute> |
getAttributes()
Gets a collected list of all attributes of the attribute-groups.
|
byte[] |
getData()
Returns the data part of the request.
|
short |
getOpCode()
Returns the 2nd part (byte 2-3) with the operation-id or status-code.
|
protected abstract String |
getOpCodeAsString()
Returns the 2nd part (byte 2-3) with the operation-id or status-code as
string.
|
int |
getRequestId()
Retunns the 3rd part (byte 4-7) of the request which
contains the request-id.
|
AbstractIpp.Version |
getVersion()
Gets the first part (byte 0-1) with the supported IPP version.
|
boolean |
hasData()
The data part of the request can be empty.
|
byte[] |
toByteArray()
Converts the IppResponse to a byte array as described in RFC-2910.
|
String |
toLongString()
Puts all attribute information into the resulting string.
|
String |
toString()
With this toString() implementation we want to provide the most
important values which are useful for logging and debugging.
|
protected static final AbstractIpp.Version DEFAULT_VERSION
protected AbstractIpp(byte[] bytes)
bytes - the bytes of the IPP requestpublic AbstractIpp(ByteBuffer bytes)
bytes - the bytes of the IPP requestpublic AbstractIpp(AbstractIpp.Version version, short opCode, int requestId, List<AttributeGroup> groups)
version - the versionopCode - the code for operation-id or status-coderequestId - the request idgroups - the attribute groupspublic AbstractIpp(AbstractIpp.Version version, short opCode, int requestId, List<AttributeGroup> groups, byte[] data)
version - the versionopCode - the code for operation-id or status-coderequestId - the request idgroups - the attribute groupsdata - the datapublic AbstractIpp.Version getVersion()
public short getOpCode()
protected abstract String getOpCodeAsString()
public int getRequestId()
public List<AttributeGroup> getAttributeGroups()
public List<Attribute> getAttributeGroups(DelimiterTags tag)
tag - the delimiter-tagpublic List<Attribute> getAttributes()
public Attribute getAttribute(String name)
IllegalArgumentException will be thrown.name - name of the attributepublic byte[] getData()
public boolean hasData()
public String toString()
public String toLongString()
public byte[] toByteArray()
----------------------------------------------- | version-number | 2 bytes - required ----------------------------------------------- | operation-id or status-code | 2 bytes - required ----------------------------------------------- | request-id | 4 bytes - required ----------------------------------------------- | attribute-group | n bytes - 0 or more ----------------------------------------------- | end-of-attributes-tag | 1 byte - required ----------------------------------------------- | data | q bytes - optional -----------------------------------------------
Copyright © 2018. All rights reserved.