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

com.aoindustries.aoserv.client.LinuxIDTable Maven / Gradle / Ivy

There is a newer version: 1.92.0
Show newest version
/*
 * aoserv-client - Java client for the AOServ platform.
 * Copyright (C) 2001-2009, 2016  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoserv-client.
 *
 * aoserv-client is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aoserv-client is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with aoserv-client.  If not, see .
 */
package com.aoindustries.aoserv.client;

import java.util.AbstractList;
import java.util.List;

/**
 * LinuxIDs are not transferred over the network.  Instead,
 * they are generated on the client upon first use.
 *
 * @see  LinuxID
 *
 * @author  AO Industries, Inc.
 */
final public class LinuxIDTable extends AOServTable {

	private static final List ids = new AbstractList() {

		@Override
		public LinuxID get(int index) {
			if(index<0) throw new IndexOutOfBoundsException("Index below zero: "+index);
			if(index>65535) throw new IndexOutOfBoundsException("Index above 65535: "+index);
			return new LinuxID(index);
		}

		@Override
		public int size() {
			return 65536;
		}

		@Override
		public int indexOf(Object o) {
			if(o!=null && (o instanceof LinuxID)) {
				return ((LinuxID)o).getID();
			}
			return -1;
		}

		@Override
		public int lastIndexOf(Object o) {
			return indexOf(o);
		}
	};

	LinuxIDTable(AOServConnector connector) {
		super(connector, LinuxID.class);
	}

	@Override
	OrderBy[] getDefaultOrderBy() {
		return null;
	}

	@Override
	public LinuxID get(Object id) {
		return get(((Integer)id).intValue());
	}

	public LinuxID get(int id) {
		if(id>=0 && id<=65535) return new LinuxID(id);
		return null;
	}

	@Override
	public List getRows() {
		return ids;
	}

	@Override
	public SchemaTable.TableID getTableID() {
		return SchemaTable.TableID.LINUX_IDS;
	}

	@Override
	protected LinuxID getUniqueRowImpl(int col, Object value) {
		if(col!=0) throw new IllegalArgumentException("Not a unique column: "+col);
		return get(value);
	}

	@Override
	public boolean isLoaded() {
		return true;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy