All Downloads are FREE. Search and download functionalities are using the official Maven repository.

j4cups.protocol.IppRequest Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
/*
 * Copyright (c) 2018 by Oliver Boehm
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * (c)reated 09.02.2018 by oboehm ([email protected])
 */
package j4cups.protocol;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.ByteBuffer;

/**
 * The IppRequest represents an IPP request as is defined in RFC-2910.
 * 
 *  -----------------------------------------------
 *  |                  version-number             |   2 bytes  - required
 *  -----------------------------------------------
 *  |               operation-id (request)        |   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
 *  -----------------------------------------------
 * 
* * @author oboehm * @since 0.0.1 (09.02.2018) */ public class IppRequest extends AbstractIpp { private static final Logger LOG = LoggerFactory.getLogger(IppRequest.class); /** * Instantiates a new IPP request from the given bytes. * * @param bytes the bytes of the IPP request */ public IppRequest(byte[] bytes) { this(ByteBuffer.wrap(bytes)); } /** * Instantiates a new IPP request from the given bytes. * * @param bytes the bytes of the IPP request */ public IppRequest(ByteBuffer bytes) { super(bytes); } /** * Returns the 2nd part (byte 2-3) with the operation-id. * * @return e.g. {@link IppOperations#CREATE_JOB} */ public IppOperations getOperation() { return IppOperations.of(super.getOpCode()); } /** * Returns the 2nd part (byte 2-3) with the operation-id as string. * * @return e.g. "Create-Job" */ @Override protected String getOpCodeAsString() { return getOperation().toString(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy