⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractcell.java

📁 java的共享内存管理.基于MMF设计。封装了java.nio.MappedByteBuffer.在大流量实时业务系统时
💻 JAVA
字号:
/*
 * @(#)AbstractCell.java	1.00 2007-12-5
 *
 * Copyright 2007 BCINFO. All Rights Reserved.
 * 
 * Programmer: Xuym.
 */
package com.bci.commons.mmf.cell;

/**
 * 共享内存数据抽象类,即映射文件中的消息实体结构的顶层抽象。
 * 
 * @author xuym
 * @version 1.00, 2007-12-5
 * @since JDK 1.5
 */
public abstract class AbstractCell {

	public static final byte USED = 0x01;

	public static final byte UNUSED = 0x00;

	/**
	 * 当前消息单元在内存的位置
	 */
	private int position;

	/**
	 * 当前消息单元是否有数据 0表示没有数据 是空闲节点 1表示占用
	 */
	protected byte used;

	/**
	 * 消息进入系统时间 毫秒数
	 */
	protected long inTime;

	/**
	 * 消息操作时间 毫秒数
	 */
	protected long opTime;

	/**
	 * 消息状态
	 */
	protected byte status;

	/**
	 * 消息单元长度 字节数
	 */
	private int length;

	/**
	 * 消息单元二进制数据
	 */
	protected byte[] bytes;

	public AbstractCell() {
		super();
	}

	public AbstractCell(byte[] buf) throws MemoryMessageException {
		this();
		this.decode(buf, 0);
	}

	/**
	 * @return the inTime
	 */
	public long getInTime() {
		return inTime;
	}

	/**
	 * @param inTime
	 *            the inTime to set
	 */
	public void setInTime(long inTime) {
		this.inTime = inTime;
	}

	/**
	 * @return the opTime
	 */
	public long getOpTime() {
		return opTime;
	}

	/**
	 * @param opTime
	 *            the opTime to set
	 */
	public void setOpTime(long opTime) {
		this.opTime = opTime;
	}

	/**
	 * @return the position
	 */
	public int getPosition() {
		return position;
	}

	/**
	 * @param position
	 *            the position to set
	 */
	public void setPosition(int position) {
		this.position = position;
	}

	/**
	 * @return the status
	 */
	public byte getStatus() {
		return status;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(byte status) {
		this.status = status;
	}

	/**
	 * @return the used
	 */
	public byte getUsed() {
		return used;
	}

	/**
	 * @param used
	 *            the used to set
	 */
	public void setUsed(byte used) {
		this.used = used;
	}

	/**
	 * 生成当前消息单元对象的字节数组
	 * 
	 * @return the bytes
	 */
	public abstract byte[] encode();

	/**
	 * 从字节数组解析成对象
	 * 
	 * @param bytes
	 *            the bytes to set
	 * @param offset
	 *            the offset of the bytes
	 */
	public abstract void decode(byte[] bytes, int offset)
			throws MemoryMessageException;

	/**
	 * @return the length
	 */
	public int getLength() {
		return length;
	}

	/**
	 * @param length
	 *            the length to set
	 */
	public void setLength(int length) {
		this.length = length;
	}

	public byte[] getBytes() {
		return bytes;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -