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

org.jscsi.parser.datasegment.IDataSegment Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2012, University of Konstanz, Distributed Systems Group All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation and/or other materials provided with the
 * distribution. * Neither the name of the University of Konstanz nor the names of its contributors may be used to
 * endorse or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.jscsi.parser.datasegment;


import java.nio.ByteBuffer;

import org.jscsi.exception.InternetSCSIException;


/**
 * 

IDataSegment

*

* This interface defines all methods, which a class must to support, if it is a DataSegment. * * @author Volker Wildi */ public interface IDataSegment { // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /** * This method imports len bytes from the given ByteBuffer. * * @param src Source ByteBuffer object. * @param len The number of bytes to import from src. * @return The number of bytes, which are imported. Typically, this should be equal as len. */ @Deprecated public int deserialize (final ByteBuffer src, final int len); /** * This method appends len bytes from the given ByteBuffer at the end of the data buffer * of this instance. * * @param src Source ByteBuffer object. * @param len The number of bytes to append from src. * @return The number of bytes of the complete data buffer of this instance. */ public int append (final ByteBuffer src, final int len); /** * This method exports the data buffer to the given ByteBuffer object, which is padded to a integer * number of 4 byte words. * * @param dst Destination ByteBuffer object. * @param off Start position in dst, where to serialize. * @return The number of exported bytes (in bytes). */ @Deprecated public int serialize (final ByteBuffer dst, final int off); // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /** * Returns an iterator over the chunks of this data segment in proper sequence. * * @return an iterator over the chunks of this data segment in proper sequence. */ public IDataSegmentIterator iterator (); /** * Returns a SettingsMap instance of this IDataSegment instance. This is only useful with * a TextParameterDataSegment instance. * * @return The settings of this TextParameterDataSegment instance. * @throws InternetSCSIException if any violation of the iSCSI Standard occurs. */ public SettingsMap getSettings () throws InternetSCSIException; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /** * Clears all made settings of this object. After the call of this method, this object can be reused. */ public void clear (); // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /** * Returns the length, which is really used by the dataBuffer. * * @return The really used length. */ public int getLength (); /** * Sets the data buffer to the given buffer src. Starting from the position offset with * length of len. * * @param src The buffer to read from. * @param off The start offset to read from. * @param len The number of bytes to read. * @return The number of bytes really read. */ public int setDataBuffer (final ByteBuffer src, final int off, final int len); // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy